var scrollingSpeed=3000;var eleAnimSpeed=100;var scrollOffset;var isScrolling=false;var isClick=false;var activeNavStart=193;var activeNavDistance;var introHeight=800;var sectionHeight=2150;var tooltip;var tooltip_y;var tooltip_x;var tooltip_img;var isiPad=false;var currentSection;var snapTime;$(document).ready(function(){isiPad=navigator.userAgent.match(/iPad/i)!=null;var ua=navigator.userAgent;isiPad=/iPad/i.test(ua)||/iPhone OS 3_1_2/i.test(ua)||/iPhone OS 3_2_2/i.test(ua);tooltip=$('#work_tooltip');setupFonts();var navWorkBarWidth=254;var sectionCount=$('#intro_nav .work_nav ul li').length;var workPointWidth=$('#intro_nav .work_nav ul li').width();var workPointSpace=(navWorkBarWidth-(sectionCount*22))/(sectionCount-1);for(i=0;i<(sectionCount-1);i++){$('#intro_nav .work_nav ul li').eq(i).css({'margin-right':workPointSpace});$('#nav .work_nav ul li').eq(i).css({'margin-right':workPointSpace})}activeNavDistance=workPointWidth+workPointSpace+2;setupNav();$('.contact_dropdown').css({'left':($(window).width()/2)-570});$('.clients_dropdown').css({'left':($(window).width()/2)-450});if(!isiPad){scrollHandler()}else{tooltip.addClass('docked')}$(window)._scrollable();$('.site_nav .logo').click(function(){isScrolling=true;isClick=true;$.scrollTo(0,scrollingSpeed,{axis:'y',onAfter:function(){isScrolling=false;trackEvent('section','intro','click');setTimeout('isClick = false',1000)}})});$('#intro .cta').hover(function(){$(this).find('a').stop().animate({marginTop:-52},250)},function(){$(this).find('a').stop().animate({marginTop:0},250)}).click(function(){if(!isiPad){$.scrollTo(introHeight-82,scrollingSpeed,{axis:'y'})}else{$.scrollTo($('.section:first'),scrollingSpeed,{axis:'y'})}});$('.site_nav .work_nav ul li').hover(function(){if(!isScrolling){tooltip.find('.mid').html($(this).find('.img').html());if(tooltip.hasClass('docked')){tooltip.css({'top':$(this).offset().top+25,'left':$(this).offset().left-tooltip.width()/2+12})}else{tooltip.css({'top':$(this).offset().top-tooltip.height(),'left':$(this).offset().left-tooltip.width()/2+12})}tooltip.stop().show()}},function(){tooltip.attr('style','');tooltip.hide()}).bind('click',function(){clickHandler($(this))});if(!isiPad){$('#nav .contact').hover(function(){$(this).find('.contact_dropdown').stop().animate({height:295},500);$(this).addClass('open');trackEvent('nav','contact','hover')},function(){$(this).find('.contact_dropdown').stop().animate({height:0},300);$(this).removeClass('open')});$('#nav .clients').hover(function(){$(this).find('.clients_dropdown').stop().animate({height:425},500);$(this).addClass('open');trackEvent('nav','clients','hover')},function(){$(this).find('.clients_dropdown').stop().animate({height:0},300);$(this).removeClass('open')})}else{$('#nav .contact').click(function(){if($(this).hasClass('open')){$(this).find('.contact_dropdown').stop().animate({height:0},300);$(this).removeClass('open')}else{$(this).find('.contact_dropdown').stop().animate({height:295},500);if($('#nav .clients').hasClass('open')){$('#nav .clients').click()}$(this).addClass('open');trackEvent('nav-ipad','contact','click')}});$('#nav .clients').click(function(){if($(this).hasClass('open')){$(this).find('.clients_dropdown').stop().animate({height:0},300);$(this).removeClass('open')}else{$(this).find('.clients_dropdown').stop().animate({height:425},500);if($('#nav .contact').hasClass('open')){$('#nav .contact').click()}$(this).addClass('open');trackEvent('nav-ipad','clients','click')}})}$('#intro_nav .contact').hover(function(){$(this).find('.contact_dropdown').stop().animate({height:295},500);$(this).addClass('open');trackEvent('nav','contact','hover')},function(){$(this).find('.contact_dropdown').stop().animate({height:0},300);$(this).removeClass('open')});$('#intro_nav .clients').hover(function(){$(this).find('.clients_dropdown').stop().animate({height:425},500);$(this).addClass('open');trackEvent('nav','clients','hover')},function(){$(this).find('.clients_dropdown').stop().animate({height:0},300);$(this).removeClass('open')});$('#clients .backtotop a').click(function(){isScrolling=true;isClick=true;$.scrollTo(0,scrollingSpeed,{axis:'y',onAfter:function(){isScrolling=false;trackEvent('section','intro','click');setTimeout('isClick = false',1000)}})})});function setupFonts(){Cufon.replace('.font_interstate',{fontFamily:'Interstate'});Cufon.replace('.font_vag',{fontFamily:'VagBlack'});Cufon.replace('.font_hnul',{fontFamily:'HelveticaNeueUL'});Cufon.replace('.font_helv',{fontFamily:'HelveticaNeue'})}function setupNav(){var scrollOffset=document.documentElement.scrollTop||document.body.scrollTop;var introNav=$('#intro_nav');var nav=$('#nav');if(!isiPad){if(scrollOffset>=introHeight-$(window).height()){introNav.css({'position':'absolute'})}else{introNav.css({'position':''})}if(scrollOffset>=introHeight-introNav.outerHeight()){introNav.hide();nav.show();tooltip.addClass('docked')}else{nav.hide();introNav.show();tooltip.removeClass('docked')}}if(scrollOffset<=introHeight){if(scrollOffset<718){$('.active_nav').hide();$('.active_nav').css({'left':activeNavStart});if(!isClick){if(currentSection!='intro'){currentSection='intro';trackEvent('section',currentSection,'scroll')}}}else{$('.active_nav').show();if(!isClick){if(currentSection!='mikes'){currentSection='mikes';trackEvent('section',currentSection,'scroll')}}}}else if(scrollOffset>introHeight&&scrollOffset<=introHeight+sectionHeight){if($('.active_nav:visible').length<1){$('.active_nav').show()}if(!isClick){if(currentSection!='mikes'){currentSection='mikes';trackEvent('section',currentSection,'scroll')}}var posPerc=((scrollOffset-introHeight)/sectionHeight)*100;var pos=activeNavStart+(activeNavDistance*(posPerc/100));$('.active_nav').css({'left':pos})}else if(scrollOffset>(introHeight+sectionHeight)&&scrollOffset<=introHeight+(sectionHeight*2)){if($('.active_nav:visible').length<1){$('.active_nav').show()}if(!isClick){if(currentSection!='bacardi'){currentSection='bacardi';trackEvent('section',currentSection,'scroll')}}var posPerc=((scrollOffset-(introHeight+sectionHeight))/sectionHeight)*100;var pos=(activeNavStart+activeNavDistance)+(activeNavDistance*(posPerc/100));$('.active_nav').css({'left':pos})}else if(scrollOffset>(introHeight+(sectionHeight*2))&&scrollOffset<=introHeight+(sectionHeight*3)){if($('.active_nav:visible').length<1){$('.active_nav').show()}if(!isClick){if(currentSection!='rihanna'){currentSection='rihanna';trackEvent('section',currentSection,'scroll')}}var posPerc=((scrollOffset-(introHeight+(sectionHeight*2)))/sectionHeight)*100;var pos=(activeNavStart+((activeNavDistance-2)*2))+(activeNavDistance*(posPerc/100));$('.active_nav').css({'left':pos})}else if(scrollOffset>(introHeight+(sectionHeight*3))&&scrollOffset<=introHeight+(sectionHeight*4)){if($('.active_nav:visible').length<1){$('.active_nav').show()}if(!isClick){if(currentSection!='nickelodeon'){currentSection='nickelodeon';trackEvent('section',currentSection,'scroll')}}var posPerc=((scrollOffset-(introHeight+(sectionHeight*3)))/sectionHeight)*100;var pos=(activeNavStart+((activeNavDistance-2)*3))+(activeNavDistance*(posPerc/100));$('.active_nav').css({'left':pos})}else if(scrollOffset>(introHeight+(sectionHeight*4))){if($('.active_nav').position().left<400){$('.active_nav').css({'left':425})}if(scrollOffset>=$(document).height()-$(window).height()){$('#clients .backtotop').stop().animate({'bottom':180},200)}else{$('#clients .backtotop').stop().animate({'bottom':155},200)}if(scrollOffset>=11468){if($('.active_nav:visible').length!=0){$('.active_nav').hide()}if(!isClick){if(currentSection!='clients'){currentSection='clients';trackEvent('section',currentSection,'scroll')}}}else{if($('.active_nav:visible').length<1){$('.active_nav').show()}if(!isClick){if(currentSection!='pop'){currentSection='pop';trackEvent('section',currentSection,'scroll')}}}}}function clickHandler(ele){isScrolling=true;isClick=true;var section="#"+ele.attr('class').substring(4);var secPos=$(section).offset().top;var scollPos=secPos-$('#intro_nav').outerHeight();if(isiPad){scollPos=secPos}tooltip.filter(':visible').hide();$.scrollTo(scollPos,scrollingSpeed,{axis:'y',onAfter:function(){isScrolling=false;currentSection=ele.attr('class').substring(4);trackEvent('section',currentSection,'click');setTimeout('isClick = false',1000);$('.snapped').removeClass('snapped');$('#'+currentSection).addClass('snapped')}});return false}function scrollHandler(){var scrollOffset=document.documentElement.scrollTop||document.body.scrollTop;var nav=$('#intro_nav');var section;var offset;if(scrollOffset<introHeight){section=$('#intro')}if(scrollOffset>=introHeight-$(window).height()&&scrollOffset<introHeight+sectionHeight){section=$('#mikes');mikes_offset=scrollOffset-introHeight+nav.outerHeight();if(!isiPad){var mikes_g1_logo_posShift=7+mikes_offset*0.008+"%";var mikes_g2_ele1_posShift=-5-mikes_offset*0.009+"%";var mikes_g2_ele3_back_posShift=5-mikes_offset*0.008+"%";var mikes_g2_ele3_mid_1_posShift=6-mikes_offset*0.008+"%";var mikes_g2_ele3_mid_2_posShift=5-mikes_offset*0.008+"%";var mikes_g2_ele3_front_posShift=-1+mikes_offset*0.0009+"%";section.find('.group1 .mikes_logo').css({'top':mikes_g1_logo_posShift});section.find('.group2 .element1').css({'top':mikes_g2_ele1_posShift});section.find('.group2 .element3 .back').css({'top':mikes_g2_ele3_back_posShift});section.find('.group2 .element3 .mid_1').css({'top':mikes_g2_ele3_mid_1_posShift});section.find('.group2 .element3 .mid_2').css({'top':mikes_g2_ele3_mid_2_posShift});section.find('.group2 .element3 .front').css({'top':mikes_g2_ele3_front_posShift})}}if(scrollOffset>=(introHeight+sectionHeight)-$(window).height()&&scrollOffset<=introHeight+(sectionHeight*2)){section=$('#bacardi');bacardi_offset=scrollOffset-(introHeight+sectionHeight+nav.outerHeight());if(!isiPad){var bacardi_g1_ele1_posShift=10-bacardi_offset*0.006+"%";var bacardi_g2_ele1_posShift=10+bacardi_offset*0.009+"%";var bacardi_g2_ele3_posShift=25-bacardi_offset*0.008+"%";section.find('.group1 .element1').css({'top':bacardi_g1_ele1_posShift});section.find('.group2 .element1').css({'top':bacardi_g2_ele1_posShift});section.find('.group2 .element3').css({'top':bacardi_g2_ele3_posShift})}}if(scrollOffset>(introHeight+(sectionHeight*2))-$(window).height()&&scrollOffset<=introHeight+(sectionHeight*3)){section=$('#rihanna');rihanna_offset=scrollOffset-(introHeight+(sectionHeight*2)+nav.outerHeight());if(!isiPad){var rihanna_g1_logo_posShift=20+rihanna_offset*0.007+"%";var rihanna_g2_ele1_posShift=5-rihanna_offset*0.008+"%";var rihanna_g3_missions_posShift=10-(rihanna_offset/20);var rihanna_g3_completed_posShift=10-(rihanna_offset/15);var rihanna_g3_unlocked_posShift=10-(rihanna_offset/30);section.find('.group1 .rihanna_logo').css({'top':rihanna_g1_logo_posShift});section.find('.group2 .element1').css({'top':rihanna_g2_ele1_posShift});section.find('.group3 .missions .screen').css({'background-position':'center '+rihanna_g3_missions_posShift+'px'});section.find('.group3 .completed .screen').css({'background-position':'center '+rihanna_g3_completed_posShift+'px'});section.find('.group3 .unlocked .screen').css({'background-position':'center '+rihanna_g3_unlocked_posShift+'px'})}}if(scrollOffset>(introHeight+(sectionHeight*3))-$(window).height()&&scrollOffset<=introHeight+(sectionHeight*4)){section=$('#nickelodeon');nick_offset=scrollOffset-(introHeight+(sectionHeight*3)+nav.outerHeight());if(!isiPad){var nick_g1_ele1_posShift=-2+nick_offset*0.008+"%";var nick_g1_logo_posShift=3-nick_offset*0.008+"%";var nick_g2_ele1_back_posShift=-1+nick_offset*0.007+"%";var nick_g2_ele1_front_posShift=-1+nick_offset*0.009+"%";var nick_g2_ele2_back_posShift=-7+nick_offset*0.007+"%";var nick_g2_ele2_mid_posShift=-10+nick_offset*0.008+"%";var nick_g2_ele2_front_posShift=-1-nick_offset*0.009+"%";var nick_g2_ele3_posShift=85-nick_offset*0.008+"%";section.find('.group1 .element1').css({'top':nick_g1_ele1_posShift});section.find('.group1 .kca_logo').css({'top':nick_g1_logo_posShift});section.find('.group2 .element1 .back').css({'top':nick_g2_ele1_back_posShift});section.find('.group2 .element1 .front').css({'top':nick_g2_ele1_front_posShift});section.find('.group2 .element2 .back').css({'top':nick_g2_ele2_back_posShift});section.find('.group2 .element2 .mid').css({'top':nick_g2_ele2_mid_posShift});section.find('.group2 .element2 .front').css({'top':nick_g2_ele2_front_posShift});section.find('.group2 .element3').css({'top':nick_g2_ele3_posShift})}}if(scrollOffset>(introHeight+(sectionHeight*4))-$(window).height()&&scrollOffset<=introHeight+(sectionHeight*5)){section=$('#pop');pop_offset=scrollOffset-(introHeight+(sectionHeight*4)+nav.outerHeight());if(!isiPad){var pop_g1_ele1_posShift=-1-pop_offset*0.0008+"%";var pop_g1_ele2_posShift=45-pop_offset*0.007+"%";var pop_g1_ele3_posShift=65-pop_offset*0.008+"%";var pop_g1_ele4_posShift=80-pop_offset*0.009+"%";var pop_g2_ele1_posShift=12-pop_offset*0.008+"%";var pop_g2_ele2_posShift=60+pop_offset*0.008+"%";var pop_g2_ele3_posShift=4+pop_offset*0.008+"%";var pop_g2_ele4_posShift=80-pop_offset*0.008+"%";section.find('.group1 .left_col .element1').css({'top':pop_g1_ele1_posShift});section.find('.group1 .left_col .element2').css({'top':pop_g1_ele2_posShift});section.find('.group1 .left_col .element3').css({'top':pop_g1_ele3_posShift});section.find('.group1 .left_col .element4').css({'top':pop_g1_ele4_posShift});section.find('.group2 .element1').css({'top':pop_g2_ele1_posShift});section.find('.group2 .element2').css({'top':pop_g2_ele2_posShift});section.find('.group2 .element3').css({'top':pop_g2_ele3_posShift});section.find('.group2 .element4').css({'top':pop_g2_ele4_posShift})}}clearTimeout(snapTime);if(!isClick){snapTime=setTimeout('checkSnap()',600)}}function checkSnap(){var scrollOffset=document.documentElement.scrollTop||document.body.scrollTop;var sectionCount=$('.section').length;for(i=0;i<sectionCount;i++){var section=$('.section').eq(i);if(scrollOffset>section.offset().top-200&&scrollOffset<section.offset().top+100){if(section.hasClass('snapped')){}else{isScrolling=true;$('.snapped').removeClass('snapped');section.addClass('snapped');$.scrollTo(section.offset().top-$('#intro_nav').outerHeight(),400,{axis:'y',onAfter:function(){isScrolling=false}})}}else{if(section.hasClass('snapped')){section.removeClass('snapped')}}}}$(window).scroll(function(){setupNav();scrollHandler()});$(window).resize(function(){$('.contact_dropdown').css({'left':($(window).width()/2)-570});$('.clients_dropdown').css({'left':($(window).width()/2)-450})});$(window).load(function(){});
