var projectSlideshowCont = true;
var projectLoad = true;
var blogLoad = true;
var currentTimer = null;
$(document).ready(function() {	
$(window).resize(function(){if($(window).height()>800&&$(window).scrollTop()>500){$('#work div.profile').css({'position':'fixed','left':''})}});$(window).scroll(function(){if($(window).scrollTop()>=30){$('nav#nav').css({'position':'fixed','top':0});$('nav#nav h1 img').stop().animate({'width':'60%','height':'60%','marginTop':'0px'},500);$('nav#nav #navbar').stop().animate({'opacity':'1'},250)}else if($(window).scrollTop()<30){$('nav#nav').css({'position':'absolute','top':40});$('nav#nav h1 img').stop().animate({'width':314,'height':106,'marginTop':'-14px'},500);$('nav#nav #navbar').stop().animate({'opacity':'0'},250)}if($(window).scrollTop()==$(document).height()-$(window).height()){$('#credits').addClass('active').css('display','block').animate({'height':'33px','opacity':1})}else{if($('#navbar').height()>50){$('#navbar').css({'height':50});$('#navbar article.content').remove()}if($('#credits').css('height')=='33px'){$('#credits').animate({'height':'15px','opacity':0})}}});$("#work article div article:gt(0), #blog article div p:gt(0), #studio article div p:gt(0)").css("opacity",0);$("#services .sidenav").css("top","25%");$("#work .sidenav").css("top","115px");$("#studio .sidenav").css("top","23%");$("#blog .sidenav").css("top","25%");$("#contact .sidenav").css("top","25%");$("nav").localScroll({duration:800,easing:'easeOutQuad',offset:-100});$(".contact-button").localScroll({duration:800,easing:'easeOutQuad'});$("#tweet").tweet({username:"juiceboxcomau",count:1,loading_text:"loading tweets..."});$(".twitter, .facebook").hover(function(){$('.smbox',this).fadeIn()});$('.twitter, .smbox, .facebook').mouseleave(function(){$('.smbox',this).fadeOut()});$("nav a").hover(function(){$('.txt',$(this)).stop().animate({"marginTop":'-8',"paddingBottom":'19'},200);$('.hover',$(this)).stop().animate({"opacity":'1'},200)},function(){$('.txt',$(this)).stop().animate({"marginTop":'0',"paddingBottom":'0'},200);$('.hover',$(this)).stop().animate({"opacity":'0'},200)});$('nav#nav #navbar').click(function(){if($(this).height()>50){$(this).css({'height':50});$('#navbar article.content').remove()}});$("#servicelist nav a").hover(function(){$(this).stop().animate({"opacity":1},250,'linear')},function(){$(this).stop().animate({"opacity":0.3},250,'linear')});$("#servicelist nav a").click(function(){var pageVar=$(this).attr('id');$("#servicelist nav a").removeClass('active');$("#servicelist article").animate({"opacity":0},500,'linear',function(){$("#servicelist article").load('/includes/content.inc.php',{content:pageVar},function(){$("#servicelist article").animate({"opacity":1},500,'linear');var sectionEl=$(this).parents('section');var expansion=$("#servicelist article").height()+690;sectionEl.animate({"height":expansion},800);sectionEl.find('.skew').animate({"height":expansion},800);sectionEl.css({'overflow':'visible'})})});$(this).addClass('active');return false});$("section, footer").live({mouseenter:function(){$(this).children("nav.sidenav.left").find("div").not("div.loader").stop().animate({"marginLeft":"0px"},300);$(this).children("nav.sidenav.right").find("div").not("div.loader").stop().animate({"marginRight":"0px"},300);clearTimeout(currentTimer)},mouseleave:function(){$(this).children("nav.sidenav.left").find("div").not("div.loader").stop().animate({"marginLeft":"-60px"},300);$(this).children("nav.sidenav.right").find("div").not("div.loader").stop().animate({"marginRight":"-60px"},300);projectSlideshowCont=true;clearTimeout(currentTimer)}});$("#map").hover(function(){$('#juicebox').stop().animate({"opacity":0},600,function(){$('#juicebox').css('z-index',1)})},function(){$('#juicebox').css('z-index',999);$('#juicebox').stop().animate({"opacity":1},600)});$("#work a.next, #blog a.next").click(function(){var nProject=$(this).attr('data-next');var nType=$(this).parents('section').attr('id');var projectDiv=$(this).parents('section').find("div.project");if(projectDiv.hasClass('fullView')){var fullView=true}if(projectLoad){nextProject(fullView,nProject,nType);projectLoad=false}$('div.project').css({'overflow':'visible','position':'relative'});return false});$("#work a.prev, #blog a.prev").click(function(){var nProject=$(this).attr('data-prev');var nType=$(this).parents('section').attr('id');if($('div.project').hasClass('fullView')){var fullView=true}if(projectLoad){prevProject(fullView,nProject,nType);projectLoad=false}$('div.project').css({'overflow':'visible','position':'relative'});return false});$("#reel a").live('click',function(){var nProject=$(this).attr('data-next');if(!$(this).hasClass('active')&&projectLoad==true){nextProject(true,nProject,'work');projectLoad=false}$('div.project').css({'overflow':'visible','position':'relative'});return false});$("#services a.open, nav a[data-section=services], #services a.trigger").live('click',function(){var sectionEl=$('#services');if(!sectionEl.hasClass('fullView')){var expansion=$("#servicelist article").height()+650;sectionEl.animate({"height":expansion},800);$(sectionEl).find('a.blue-button').animate({"opacity":0},800);sectionEl.find('.skew').animate({"height":expansion},800);sectionEl.find('#servicelist').animate({"opacity":1},800);sectionEl.addClass('fullView');if(!sectionEl.hasClass('_active')){$.scrollTo("#services",1200,{offset:-100})}$('#services a.open').addClass('close')}else{sectionEl.animate({"height":sectionEl.attr('data-default')},800);sectionEl.removeClass('fullView');sectionEl.find('#servicelist').animate({"opacity":0},800);sectionEl.find('.skew').animate({"height":sectionEl.attr('data-default')},800);$(sectionEl).find('a.blue-button').animate({"opacity":1},800);$('#services a.open').removeClass('close')}sectionEl.css({'overflow':'visible'});return false});$("#contact a.open, a[data-section=contact], #contact .trigger").live('click',function(){var sectionEl=$('#contact');if(!sectionEl.hasClass('fullView')){var expansion=sectionEl.attr('data-default');sectionEl.animate({"height":expansion},800,function(){sectionEl.css({'overflow':'visible'})});sectionEl.find('#contact-form').animate({"opacity":1},800);$('#map, #contact div.profile').animate({"height":expansion},800);$(sectionEl).find('a.blue-button').animate({"opacity":0},800);if(!sectionEl.hasClass('_active')){$.scrollTo("#contact",1200,{offset:-100})}sectionEl.addClass('fullView');$('#contact a.open').addClass('close')}else{var expansion=450;sectionEl.find('#contact-form').animate({"opacity":0},800,function(){});sectionEl.animate({"height":expansion},800);sectionEl.css({'overflow':'visible'});$('#map').animate({"height":290},800);$('#contact div.profile').animate({"height":250},800);$(sectionEl).find('a.blue-button').animate({"opacity":1},800);sectionEl.removeClass('fullView');$('#contact a.open').removeClass('close')}sectionEl.css({'overflow':'visible'});return false});$("#studio a.open, nav a[data-section=studio],  #studio a.trigger").live('click',function(){var sectionEl=$('#studio');if(!sectionEl.hasClass('fullView')){var expansion=sectionEl.attr('data-expansion');sectionEl.animate({"height":expansion},800);sectionEl.find('.skew').animate({"height":expansion},800);$('#studiotop').cycle({fx:'fade',speed:'2500',timeout:5000});$('#studiobottom').cycle({fx:'fade',speed:'2500',timeout:6000});if(!sectionEl.hasClass('_active')){$.scrollTo("#studio",1200,{offset:-100})}$("#studio p:gt(0)").animate({"opacity":1},600);sectionEl.addClass('fullView');$('#studio a.open').addClass('close')}else{sectionEl.animate({"height":sectionEl.attr('data-default')},800);$("#studio p:gt(0)").animate({"opacity":0},600);sectionEl.removeClass('fullView');$('#studio a.open').removeClass('close');$('#studiotop, #studiobottom').cycle('pause')}sectionEl.css({'overflow':'visible'});return false});$("#work a.open, nav a[data-section=work], #work a.trigger").live('click',function(){var project=$('#work div.project');if(!project.hasClass('fullView')){setViewHeight(project,'work');$('#work a.open').addClass('close');$('div#reel').animate({"height":412},800);var curProject=$('#work div.project').attr('id');startCycle(curProject)}else{;project.removeClass('fullView');$('#work, #work div.project').animate({"height":'460px'},800);$('div#reel').animate({"height":0},800);$('#work article.content,  #work .track, #work article aside, #work .skew').animate({"height":'460px'},800,function(){$('#work .skew aside').animate({"marginTop":0},800)});$("#work article div article:gt(0)").animate({"opacity":0},600);$('#work a.open').removeClass('close')}return false});$("#blog a.open, nav a[data-section=blog], #blog a.trigger").live('click',function(){var project=$('#blog div.project');if(!project.hasClass('fullView')){project.addClass('fullView');$('#blog a.open').addClass('close');setViewHeight(project,'blog')}else{project.removeClass('fullView');var parHeight=350;$("#blog article div.profile p:gt(0)").animate({"opacity":0},600);$('div.project').css('overflow','visible');$('#blog .view-pane, #blog article.content, #blog .skew, #blog-hider').animate({"height":parHeight},800,function(){$('#blog .skew aside').animate({"marginTop":0},800)});$('#blog a.open').removeClass('close')}return false});if($.browser.msie&&$.browser.version.substr(0,1)<=9){$.each($('input[type=text], input[type=email], input[type=tel]'),function(){$(this).val($(this).attr('placeholder'))});$('input[type=text], input[type=email], input[type=tel], textarea').live('focus',function(){if($(this).val()==$(this).attr('placeholder')){$(this).val('')}});$('input[type=text], input[type=email], input[type=tel], textarea').live('blur',function(){if($(this).val()==''){$(this).val($(this).attr('placeholder'))}})}$("#contact-form .submit").live('click',function(){var name=$('input#name').val();var email=$('input#email').val();var phone=$('input#phone').val();var regarding=$('select#regarding').val();var query=$('#query').val();$('div#contact-form').html('<p style="padding-top: 100px;"text-align: center;"><img src="/img/loaderbak.gif" /></p>');$('div#contact-form').load('/includes/contact.inc.php',{name:name,email:email,phone:phone,regarding:regarding,query:query});return false});$("#subscribe .submit").click(function(){var email=$('div#subscribe input[type=text]').val();$('div#subscribe').html('<p style="text-align: center;width:100%;"><img src="/img/loaderbak.gif" /></p>');$('div#subscribe').load('/includes/subscribe.inc.php',{email:email});return false});$("#credits").click(function(){var creditsH=$(window).height()-50;$("#navbar").stop().animate({"height":creditsH},800,function(){$.post("/includes/credits.html",function(data){$("#navbar").append($(innerShiv(data)));creditHeight=($('#navbar article.content').height()+100)*-1;$('#credit-roll').css({'display':'block','margin-top':$('#credit-focus').height()}).animate({'marginTop':creditHeight},50000,'linear')})});return false});
});
var projectSlideShow=function(){var nProject=$('#work a.next').attr('data-next');if(projectSlideshowCont){if($('div.project').hasClass('fullView')){fullView=true}else{fullView=false}nextProject(fullView,nProject,'work');currentTimer=setTimeout("projectSlideShow()",7000)}};var nextProject=function(fullView,nProject,nType){siteLoader(1,nType,1);var curProject=$('#'+nType+' div.project').attr('id');var aniProp;$.ajax({type:"POST",url:"/includes/"+nType+".inc.php",data:'project='+nProject+'&nextProject=true&fullView='+fullView,success:function(data){if(nType=='work'){var articleHeight=$("#work").height()}if(nType=='blog'){var articleHeight=$("#blog-hider").height()}$('input.'+nType+'-navigation').remove();$("#"+nType+" div.track").prepend($(innerShiv(data)));if(nType=='work'){startCycle(nProject)}if((!navigator.userAgent.match(/iPhone/i))&&(!navigator.userAgent.match(/iPod/i))&&(!navigator.userAgent.match(/iPad/i))&&fullView==true){$.scrollTo("#"+nType,1200,{offset:-100})}aniProp=($.browser.msie&&$.browser.version.substr(0,1)<=8)?{"marginRight":'100%'}:{"marginRight":'100%',"opacity":0};$('div#'+curProject).animate(aniProp,800,'easeInExpo',function(){siteLoader(0,nType,1);if(nType=='work'){$('div#'+nProject).css('height',articleHeight)}if(nType=='blog'){$('div#'+nProject+' #blog-hider').css('height',articleHeight)}$('div#'+curProject).remove();aniProp=($.browser.msie&&$.browser.version.substr(0,1)<=8)?{"marginRight":'0'}:{"marginRight":'0',"opacity":1};$('div#'+nProject).animate(aniProp,1000,'easeOutExpo',function(){if(fullView){setViewHeight($('div#'+nProject),nType)}if(nType=='work'){listUpcomingProject($('#next-'+nType).attr('data-list'))}$('div.media-display').css('z-index',999);projectLoad=true});projectNavigation(nType);if(!fullView){switch(nType){case'work':$("div#"+nProject+" article div article:gt(0)").css("opacity",0);break;case'blog':$("#blog article div p:gt(0)").css("opacity",0);break}}$('div.project').css('overflow','visible')})}})};var prevProject=function(fullView,nProject,nType){siteLoader(1,nType,0);var curProject=$('#'+nType+' div.project').attr('id');var aniProp;$.ajax({type:"POST",url:"/includes/"+nType+".inc.php",data:'project='+nProject+'&prevProject=true&fullView='+fullView,success:function(data){var articleHeight=$("#blog-hider").height();$('input.'+nType+'-navigation').remove();$("#"+nType+" div.track").append($(innerShiv(data)));if(nType=='work'){startCycle(nProject)}aniProp=($.browser.msie&&$.browser.version.substr(0,1)<=8)?{"marginRight":'-100%'}:{"marginRight":'-100%',"opacity":0};$('div#'+curProject).animate(aniProp,800,'easeInExpo',function(){$('div#'+curProject).remove();aniProp=($.browser.msie&&$.browser.version.substr(0,1)<=8)?{"marginRight":'0'}:{"marginRight":'0',"opacity":1};$('div#'+nProject).animate(aniProp,1000,'easeOutExpo',function(){siteLoader(0,nType,0);if(nType=='blog'){$('div#'+nProject+' #blog-hider').css('height',articleHeight)}if(fullView){$.scrollTo("#"+nType,1200,{offset:-100});setViewHeight($('div#'+nProject),nType)}if(nType=='work'){listUpcomingProject($('#next-'+nType).attr('data-list'))}projectLoad=true});projectNavigation(nType);if(!fullView){switch(nType){case'work':$("div#"+nProject+" article div article:gt(0)").css("opacity",0);break;case'blog':$("#blog #"+nProject+" article div p:gt(0)").css("opacity",0);break}}$('div.project').css('overflow','visible')})}})};
var projectNavigation=function(nType){$('#'+nType+' a.prev').attr('data-prev',$('#prev-'+nType).val());$('#'+nType+' a.next').attr('data-next',$('#next-'+nType).val())};var listUpcomingProject=function(list){$('div#reel').load('/includes/project-upcoming.inc.php',{nextList:list})};var startCycle=function(nProject){$('nav.pager').html('');$('#portfolio-'+nProject+' div.slider').cycle({fx:'fade',speed:'2000',timeout:5000,pager:'#portfolio-'+nProject+' nav.pager'})};var setViewHeight=function(obj,nType){switch(nType){case'work':obj.addClass('fullView');var slideHeight=$("#work article aside img.projectimg").height();var contentHeight=slideHeight-200;$("#work article div article:gt(0)").animate({"opacity":1},600);$('div.project').css('overflow','visible');$('#work article.content').animate({"height":contentHeight+'px'},800);$('#work, #work .track, #work article aside, #work .skew').animate({"height":slideHeight+'px'},800,function(){if($.browser.safari){$('div.project').css('position','static')}});break;case'blog':obj.addClass('fullView');if($.browser.safari){$('div.project').css('position','static')}var articleHeight=$("#blog article div.profile").height()+50;$('div.project').css('overflow','visible');$("#blog article div.profile p:gt(0)").animate({"opacity":1},600);$('#blog .view-pane, #blog article.content, #blog .skew, #blog .skew:nth-child(1), #blog .skew:nth-child(1) aside, #blog-hider').animate({"height":articleHeight},1200);break}};var siteLoader=function(on,nType,direction){if(on==1){on=0;if(nType=='work'){$('div#reel').html('<img src="/img/loader.gif" class="loader" />')}}else{on=-60};if(direction==0){$('#'+nType+' nav.left div.loader').animate({"marginLeft":on})}else{$('#'+nType+' nav.right div.loader').animate({"marginRight":on})}};function hoverIn(){$(this).children("nav.sidenav.left").stop().animate({"left":"0px"},300);$(this).children("nav.sidenav.right").stop().animate({"right":"0px"},300);clearTimeout(currentTimer);projectSlideshowCont=false};function hoverOut(){$(this).children("nav.sidenav.left").stop().animate({"left":"-60px"},300);$(this).children("nav.sidenav.right").stop().animate({"right":"-60px"},300);projectSlideshowCont=true;clearTimeout(currentTimer)};

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function startAnalytics() {
var pageTracker = _gat._getTracker("UA-8385425-4");
pageTracker._trackPageview();
}

if (window.addEventListener) {
	window.addEventListener('load', startAnalytics, false);
}
else if (window.attachEvent) {
	window.attachEvent('onload', startAnalytics);
}


