// JavaScript Document

$(document).ready(function(){
	$('body#services #temp_wrapper').fadeTo(900, 1);
	$('body#portfolio #temp_wrapper').fadeTo(900, 1);
	$('body#startup #temp_wrapper').fadeTo(900, 1);
	$('body#videos #temp_wrapper').fadeTo(900, 1);
	$('body#why #temp_wrapper').fadeTo(900, 1);
	$('body#studio #temp_wrapper').fadeTo(900, 1);
		$('body#hp').fadeTo(900, 1);
	$('body#job_app #temp_wrapper').fadeTo(900, 1);
	
	imageresize();
	$(window).bind("resize", function(){//Adjusts image when browser resized  
		imageresize();
	});
	
//showreel animation
$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#reels').slideUp('fast');
 // shows the slickbox on clicking the noted link  
  $('.btn_sr').click(function() {
    $('#reels').slideDown('slow');
    return false;
  });
  
   $('.p_more_tags').click(function() {
    $('#reels').slideDown('slow');
    return false;
  });
 // hides the slickbox on clicking the noted link  
  $('.minimize').click(function() {
    $('#reels').slideUp('slow');
    return false;
  });
});

//jobs openings animation
$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#the_jobs').slideUp('fast');
 // shows the slickbox on clicking the noted link  
  $('.jobs_click').click(function() {
    $('#the_jobs').slideDown('slow');
    return false;
  });
 // hides the slickbox on clicking the noted link  
  $('.jobs_minimize').click(function() {
    $('#the_jobs').slideUp('slow');
    return false;
  });
});
	
  
  var currentPosition = 0;
  var slideWidth = 950;
  var slides = $('.slide');
  var numberOfSlides = slides.length;
  var textslideWidth = 553;
  var numberOfTextSlides = 10;
  var browserWidth = $(window).width();
// Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
// Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth,
	'position' : 'relative'
  });
// Set #slideInner width equal to total width of all slides
  $('#slideInner').css({
					   'width': slideWidth * numberOfSlides 
					   });
   $('#callouts_wrapper').css({
					   'width': textslideWidth * numberOfTextSlides 
					   });
// Hide left arrow control on first load
  manageControls(currentPosition);
// Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
// Determine new position
      currentPosition = ($(this).attr('id')=='right_arrow')
    ? currentPosition+1 : currentPosition-1;
// Hide / show controls
      manageControls(currentPosition);
// Move slideInner using margin-left
      $('#slideInner').stop().animate({
        'marginLeft' : slideWidth*(-currentPosition), 
      }, 1000);
	  $('#callouts_wrapper').stop().animate({
        'marginLeft' : textslideWidth*(-currentPosition), 
      }, 1000);
	 
    });
	
// manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
		
    // Hide left arrow if position is first slide
    if(position==0){ $('#left_arrow').hide() } 
    else{ $('#left_arrow').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#right_arrow').hide() }
    else{ $('#right_arrow').show() }
}
	

//resize case study image
	function imageresize() {  
	var casestudyWidth = $(window).width();  
	if (casestudyWidth < 950){  
		$('#case_study').css({'width':'983px'});
		$('.vid_vim').css({'margin':'0px'});
	                           } else {  
										$('#case_study').css({'width':'950px'}); 
										$('.vid_vim').css({'margin':'0px auto'});
	       							   }  
	}


//mouse overs
$('li img.nyt').mouseover(function() { $('#clients .nyt_pop').fadeIn('fast'); });
$('li img.nyt').mouseout(function() { $('#clients .nyt_pop').fadeOut('fast'); });

$('li img.ebay').mouseover(function() { $('#clients .ebay_pop').fadeIn('fast'); });
$('li img.ebay').mouseout(function() { $('#clients .ebay_pop').fadeOut('fast'); });

$('li img.att').mouseover(function() { $('#clients .att_pop').fadeIn('fast'); });
$('li img.att').mouseout(function() { $('#clients .att_pop').fadeOut('fast'); });

$('li img.heroes').mouseover(function() { $('#clients .nbc_pop').fadeIn('fast'); });
$('li img.heroes').mouseout(function() { $('#clients .nbc_pop').fadeOut('fast'); });

$('li img.cisco').mouseover(function() { $('#clients .cisco_pop').fadeIn('fast'); });
$('li img.cisco').mouseout(function() { $('#clients .cisco_pop').fadeOut('fast'); });

$('li img.suave').mouseover(function() { $('#clients .suave_pop').fadeIn('fast'); });
$('li img.suave').mouseout(function() { $('#clients .suave_pop').fadeOut('fast'); });

$('li img.amex').mouseover(function() { $('#clients .amex_pop').fadeIn('fast'); });
$('li img.amex').mouseout(function() { $('#clients .amex_pop').fadeOut('fast'); });

$('li img.target').mouseover(function() { $('#clients .target_pop').fadeIn('fast'); });
$('li img.target').mouseout(function() { $('#clients .target_pop').fadeOut('fast'); });

$('li img.tundra').mouseover(function() { $('#clients .tundra_pop').fadeIn('fast'); });
$('li img.tundra').mouseout(function() { $('#clients .tundra_pop').fadeOut('fast'); });

$('li img.ms').mouseover(function() { $('#clients .ms_pop').fadeIn('fast'); });
$('li img.ms').mouseout(function() { $('#clients .ms_pop').fadeOut('fast'); });

$('li img.emirates').mouseover(function() { $('#clients .emirates_pop').fadeIn('fast'); });
$('li img.emirates').mouseout(function() { $('#clients .emirates_pop').fadeOut('fast'); });

$('li img.armani').mouseover(function() { $('#clients .armani_pop').fadeIn('fast'); });
$('li img.armani').mouseout(function() { $('#clients .armani_pop').fadeOut('fast'); });

$('li img.kcet').mouseover(function() { $('#clients .kcet_pop').fadeIn('fast'); });
$('li img.kcet').mouseout(function() { $('#clients .kcet_pop').fadeOut('fast'); });

$('li img.pbs').mouseover(function() { $('#clients .pbs_pop').fadeIn('fast'); });
$('li img.pbs').mouseout(function() { $('#clients .pbs_pop').fadeOut('fast'); });

$('li img.ge').mouseover(function() { $('#clients .ge_pop').fadeIn('fast'); });
$('li img.ge').mouseout(function() { $('#clients .ge_pop').fadeOut('fast'); });

$('li img.kanye').mouseover(function() { $('#clients .kanye_pop').fadeIn('fast'); });
$('li img.kanye').mouseout(function() { $('#clients .kanye_pop').fadeOut('fast'); });

$('li img.burch').mouseover(function() { $('#clients .burch_pop').fadeIn('fast'); });
$('li img.burch').mouseout(function() { $('#clients .burch_pop').fadeOut('fast'); });

$('li img.narciso').mouseover(function() { $('#clients .narciso_pop').fadeIn('fast'); });
$('li img.narciso').mouseout(function() { $('#clients .narciso_pop').fadeOut('fast'); });

$('li img.barbie').mouseover(function() { $('#clients .barbie_pop').fadeIn('fast'); });
$('li img.barbie').mouseout(function() { $('#clients .barbie_pop').fadeOut('fast'); });

$('li img.lamag').mouseover(function() { $('#clients .lamag_pop').fadeIn('fast'); });
$('li img.lamag').mouseout(function() { $('#clients .lamag_pop').fadeOut('fast'); });

$('li img.hp').mouseover(function() { $('#clients .hp_pop').fadeIn('fast'); });
$('li img.hp').mouseout(function() { $('#clients .hp_pop').fadeOut('fast'); });


$('img.see_work').mouseover(function() { $(this).attr('src','_images/see_work_ro.jpg'); });
$('img.see_work').mouseout(function() { $(this).attr('src','_images/see_work.jpg'); });

$('img.visit_site').mouseover(function() { $(this).attr('src','_images/visit_website_ro.jpg'); });
$('img.visit_site').mouseout(function() { $(this).attr('src','_images/visit_website.jpg'); });

$('img.see_films').mouseover(function() { $(this).attr('src','_images/see_films_ro.jpg'); });
$('img.see_films').mouseout(function() { $(this).attr('src','_images/see_films.jpg'); });

$('img.visit_startup').mouseover(function() { $(this).attr('src','_images/visit_startup_ro.jpg'); });
$('img.visit_startup').mouseout(function() { $(this).attr('src','_images/visit_startup.jpg'); });

$('img.startup_info').mouseover(function() { $(this).attr('src','_images/startup_info_ro.png'); });
$('img.startup_info').mouseout(function() { $(this).attr('src','_images/startup_info.png'); });

$('img.startup_site').mouseover(function() { $(this).attr('src','_images/startup_website_ro.png'); });
$('img.startup_site').mouseout(function() { $(this).attr('src','_images/startup_website.png'); });

$('a.nav_dot').mouseover(function() { $(this).css({'background-image':'url(_images/blue_dot.jpg)'}); });
$('a.nav_dot').mouseout(function() { $(this).css({'background-image':'url(_images/nav_bullet_point.jpg)'}); });
$('.startups').mouseover(function() { $(this).css({'background-image':'url(_images/nav_bullet_point_ro.jpg)'}); });
$('.startups').mouseout(function() { $(this).css({'background-image':'url(_images/nav_bullet_point.jpg)'}); });
$('.nav_dot_cap').mouseover(function() { $(this).css({'background-image':'url(_images/purple_dot.jpg)'}); });
$('.nav_dot_cap').mouseout(function() { $(this).css({'background-image':'url(_images/nav_bullet_point.jpg)'}); });
$('.nav_dot_studio').mouseover(function() { $(this).css({'background-image':'url(_images/green_dot.jpg)'}); });
$('.nav_dot_studio').mouseout(function() { $(this).css({'background-image':'url(_images/nav_bullet_point.jpg)'}); });
$('.why').mouseover(function() { $(this).css({'background-image':'url(_images/nav_bullet_point_ro.jpg)'}); });
$('.why').mouseout(function() { $(this).css({'background-image':'url(_images/nav_bullet_point.jpg)'}); });
$('img.circles_about').mouseover(function() { $(this).attr('src','_images/circles_about_ro.jpg'); });
$('img.circles_about').mouseout(function() { $(this).attr('src','_images/circles_about.jpg'); });
$('img.circles_news').mouseover(function() { $(this).attr('src','_images/circles_news_ro.jpg'); });
$('img.circles_news').mouseout(function() { $(this).attr('src','_images/circles_news.jpg'); });
$('img.circles_unique').mouseover(function() { $(this).attr('src','_images/circles_unique_ro.jpg'); });
$('img.circles_unique').mouseout(function() { $(this).attr('src','_images/circles_unique.jpg'); });
$('.btn_sr').mouseover(function() { $('.dot_jo').css('background-image', 'url(_images/global_dot_ro.jpg)'); });
$('.btn_sr').mouseout(function() { $('.dot_jo').css('background-image', 'url(_images/global_dot.jpg)'); });
$('.btn_minimize').mouseover(function() { $('.dot_jo_m').css('background-image', 'url(_images/global_dot_ro.jpg)'); });
$('.btn_minimize').mouseout(function() { $('.dot_jo_m').css('background-image', 'url(_images/global_dot.jpg)'); });
$('.jobs_click').mouseover(function() { $('.dot_bf').css('background-image', 'url(_images/global_dot_ro.jpg)'); });
$('.jobs_click').mouseout(function() { $('.dot_bf').css('background-image', 'url(_images/global_dot.jpg)'); });
$('.jobs_minimize').mouseover(function() { $('.dot_bf_m').css('background-image', 'url(_images/global_dot_ro.jpg)'); });
$('.jobs_minimize').mouseout(function() { $('.dot_bf_m').css('background-image', 'url(_images/global_dot.jpg)'); });
$('img.frank').mouseover(function() { $('img.frank').attr('src', '_images/unique_frank_ro.jpg'); });
$('img.frank').mouseout(function() { $('img.frank').attr('src', '_images/unique_frank.jpg'); });
$('img.lac').mouseover(function() { $('img.lac').attr('src', '_images/unique_circles_ro.jpg'); });
$('img.lac').mouseout(function() { $('img.lac').attr('src', '_images/unique_circles.jpg'); });
$('a img.cs_img_link').mouseover(function() { $('img.cs_img_link').attr('src', '_images/case_study_link_ro.jpg'); });
$('a img.cs_img_link').mouseout(function() { $('img.cs_img_link').attr('src', '_images/case_study_link.jpg'); });
$('img.gen_inq').mouseover(function() { $(this).attr('src','_images/studio_gen_inquiries_ro.gif');});
$('img.gen_inq').mouseout(function() { $(this).attr('src','_images/studio_gen_inquiries.gif'); });
$('img.p_web').mouseover(function() { $(this).attr('src','_images/port_web_ro.jpg');});
$('img.p_web').mouseout(function() { $(this).attr('src','_images/port_web.jpg'); });
$('img.p_id').mouseover(function() { $(this).attr('src','_images/port_identity_ro.jpg');});
$('img.p_id').mouseout(function() { $(this).attr('src','_images/port_identity.jpg'); });
$('img.p_vid').mouseover(function() { $(this).attr('src','_images/port_videos_ro.jpg');});
$('img.p_vid').mouseout(function() { $(this).attr('src','_images/port_videos.jpg'); });
$('img.p_fav').mouseover(function() { $(this).attr('src','_images/port_favorites_ro.jpg');});
$('img.p_fav').mouseout(function() { $(this).attr('src','_images/port_favorites.jpg'); });
$('img.gmap').mouseover(function() { $(this).attr('src','_images/studio_gmap_ro.jpg');});
$('img.gmap').mouseout(function() { $(this).attr('src','_images/studio_gmap.jpg'); });
$('img.ymap').mouseover(function() { $(this).attr('src','_images/studio_ymap_ro.jpg');});
$('img.ymap').mouseout(function() { $(this).attr('src','_images/studio_ymap.jpg'); });
$('img.lfm').mouseover(function() { $(this).attr('src','_images/studio_lfm_ro.jpg');});
$('img.lfm').mouseout(function() { $(this).attr('src','_images/studio_lfm.jpg'); });
$('img.d_blog').mouseover(function() { $(this).attr('src','_images/studio_design_blog_ro.jpg');});
$('img.d_blog').mouseout(function() { $(this).attr('src','_images/studio_design_blog.jpg'); });
$('img.j_fb').mouseover(function() { $(this).attr('src','_images/studio_facebook_ro.jpg');});
$('img.j_fb').mouseout(function() { $(this).attr('src','_images/studio_facebook.jpg'); });
$('img.j_tw').mouseover(function() { $(this).attr('src','_images/studio_twitter_ro.jpg');});
$('img.j_tw').mouseout(function() { $(this).attr('src','_images/studio_twitter.jpg'); });
$('img.image_1').mouseover(function() { $(this).attr('src','_images/studio_img_i_ro.jpg');});
$('img.image_1').mouseout(function() { $(this).attr('src','_images/studio_img_i.jpg'); });
$('img.image_2').mouseover(function() { $(this).attr('src','_images/studio_img_ii_ro.jpg');});
$('img.image_2').mouseout(function() { $(this).attr('src','_images/studio_img_ii.jpg'); });
$('img.image_3').mouseover(function() { $(this).attr('src','_images/studio_img_iii_ro.jpg');});
$('img.image_3').mouseout(function() { $(this).attr('src','_images/studio_img_iii.jpg'); });
$('img.image_4').mouseover(function() { $(this).attr('src','_images/studio_img_iv_ro.jpg');});
$('img.image_4').mouseout(function() { $(this).attr('src','_images/studio_img_iv.jpg'); });
$('img.image_5').mouseover(function() { $(this).attr('src','_images/studio_img_v_ro.jpg');});
$('img.image_5').mouseout(function() { $(this).attr('src','_images/studio_img_v.jpg'); });
$('img.p_more_tags').mouseover(function() { $(this).attr('src','_images/port_tags_ro.jpg');});
$('img.p_more_tags').mouseout(function() { $(this).attr('src','_images/port_tags.jpg'); });

$('img.more_r_btn').mouseover(function() { $(this).attr('src','_images/studio_more_ras_ro.jpg');});
$('img.more_r_btn').mouseout(function() { $(this).attr('src','_images/studio_more_ras.jpg'); });

$('img.more_j_btn').mouseover(function() { $(this).attr('src','_images/studio_more_jar_ro.jpg');});
$('img.more_j_btn').mouseout(function() { $(this).attr('src','_images/studio_more_jar.jpg'); });

$('img.mem_sign_up').mouseover(function() { $(this).attr('src','_images/feed_signupbtn_ro.jpg');});
$('img.mem_sign_up').mouseout(function() { $(this).attr('src','_images/feed_signupbtn.jpg'); });

$('input.button').mouseover(function() { $(this).attr('src','_images/feed_ok_ro.jpg');});
$('input.button').mouseout(function() { $(this).attr('src','_images/feed_ok_ro.jpg'); });

$('img.visit_blog').mouseover(function() { $(this).attr('src','_images/feed_ras_blog_ro.png');});
$('img.visit_blog').mouseout(function() { $(this).attr('src','_images/feed_ras_blog.jpg'); });

//callouts animation
$('img.circles_about')
    .bind('click', function(){
			$('#callouts_wrapper').animate({
      	  		'marginLeft' : '0', 
      		}, 1000);
			$('.sliding_bar').animate({
      	  		'marginLeft' : '0', 
      		}, 1000);
							});
	
$('img.circles_news')
    .bind('click', function(){
			$('#callouts_wrapper').animate({
      	  		'marginLeft' : '-525', 
      		}, 1000);
			$('.sliding_bar').animate({
      	  		'marginLeft' : '138', 
      		}, 1000);
							});
	
$('img.circles_unique')
    .bind('click', function(){
			$('#callouts_wrapper').animate({
      	  		'marginLeft' : '-1050', 
      		}, 1000);
			$('.sliding_bar').animate({
      	  		'marginLeft' : '276', 
      		}, 1000);
							});
	
$('span.peach')
    .bind('click', function(){
			$('#form').css('visibility', 'visible');
							});
$('.submit_button')
    .bind('click', function(){
			$('#form').css('visibility', 'hidden');
							});


//studio animation
$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
   $('#jar_left .jar_reveal').slideUp('fast');
   $('#ras_right .ras_reveal').slideUp('fast');
 // shows the slickbox on clicking the noted link  
  $('.more_ras').click(function() {
    $('#ras_hidden').slideDown('slow');
	$('#ras_right .ras_reveal').slideDown('slow');
    return false;
  });
  
   $('.more_jar').click(function() {
    $('#jar_hidden').slideDown('slow');
	$('#jar_left .jar_reveal').slideDown('slow');
    return false;
  });
 // hides the slickbox on clicking the noted link  
  $('.jar_minimize').click(function() {
    $('#jar_hidden').slideUp('slow');
	$('#jar_left .jar_reveal').slideUp('slow');
    return false;
  });
  
  $('.ras_minimize').click(function() {
    $('#ras_hidden').slideUp('slow');
	$('#ras_right .ras_reveal').slideUp('slow');
    return false;
  });
  
});






	



}); //end of doc ready

//capabilities animation
//$('#serv_content #cap_vi img.header_title').mouseover(function() { $('#serv_content .inside_cap_vi').fadeIn('fast'); });
//$('#serv_content .inside_cap_vi').mouseout(function() { $('#serv_content .inside_cap_vi').fadeOut('fast'); });




//purpose openings animation
$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 780;
  var slides = $('.slides');
  var numberOfSlides = 3;
  var textslideWidth = 670;
  var numberOfTextSlides = 3;
  var browserWidth = $(window).width();
// Hide left arrow control on first load
  manageControls2(currentPosition);
// Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
// Determine new position
      currentPosition = ($(this).attr('id')=='purpose_left')
    ? currentPosition+1 : currentPosition-1;
// Hide / show controls
      manageControls2(currentPosition);
// Move slideInner using margin-left
      $('#slides_wrapper').stop().animate({
        'marginLeft' : slideWidth*(-currentPosition), 
      }, 1000);
    });
	
	
	
// manageControls: Hides and shows controls depending on currentPosition
   function manageControls2(position){
		
    // Hide left arrow if position is first slide
    if(position==0){ $('#purpose_right').hide() } 
    else{ $('#purpose_right').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#purpose_left').hide() }
    else{ $('#purpose_left').show() }
}
    });

//startup sliding animaiton
$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 757;
  var numberOfSlides = 6;
  var textslideWidth = 757;
  var numberOfTextSlides = 6;
  var browserWidth = $(window).width();
// Hide left arrow control on first load
  manageControls3(currentPosition);
// Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
// Determine new position
      currentPosition = ($(this).attr('id')=='st_right_arrow')
    ? currentPosition+1 : currentPosition-1;
// Hide / show controls
      manageControls3(currentPosition);
// Move slideInner using margin-left
      $('#st_slides_wrapper').stop().animate({
        'marginLeft' : slideWidth*(-currentPosition), 
      }, 1000);
    });
	
	
	
// manageControls: Hides and shows controls depending on currentPosition
   function manageControls3(position){
		
    // Hide left arrow if position is first slide
    if(position==0){ $('#st_left_arrow').hide() } 
    else{ $('#st_left_arrow').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#st_right_arrow').hide() }
    else{ $('#st_right_arrow').show() }
}
    });




//FUNCTIONS

//toggleface function
(function($) {
  $.fn.toggleFade = function(settings)
  {
  	settings = jQuery.extend(
  		{
        speedIn: "normal",
        speedOut: settings.speedIn
  		}, settings
  	);
  	return this.each(function()
  	{
  	  var isHidden = jQuery(this).is(":hidden");
      jQuery(this)[ isHidden ? "fadeIn" : "fadeOut" ]( isHidden ? settings.speedIn : settings.speedOut);
    });
  };
})(jQuery);


//pre-load images function
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
