var browserW,browserH,leftPos,rightPos,centerPos,browserWideEnough,currentCard='intro';var slideOutTime=300,slideInFromLeftTime=700,slideInFromRightTime=500;if(typeof ipad!='undefined'){slideOutTime=200;slideInFromLeftTime=200;slideInFromRightTime=200;}
$(function(){init();$(window).resize(function(){init();});});function init(){browserW=$(window).width();browserH=$(window).height();leftPos=(browserW+$('#intro').outerWidth()+10)*-1;rightPos=browserW+10;centerPos=(browserW-$('#intro').outerWidth())/2;browserWideEnough=(browserW>=$('#intro').outerWidth()+20)?true:false;$('section[id='+currentCard+']').each(function(){if(browserWideEnough){$(this).css({position:'absolute',marginLeft:0,left:centerPos});}else{$(this).css({display:'block',position:'relative',margin:0,left:0,top:0});}});$('section:not([id='+currentCard+'])').each(function(){if(browserWideEnough){$(this).css({position:'absolute',marginLeft:0,left:leftPos}).show().find('div.inset-shadow').css({overflowY:'auto'});}else{$(this).css({display:'none',position:'relative',margin:0,left:0,top:0});}});}
function slideCardIn(card){if(card!=false){if(browserWideEnough){var direction,curCardIndex,nextCardIndex;$('section').each(function(i){if($(this).attr('id')==currentCard){curCardIndex=i;}
if($(this).attr('id')==card.substring(1)){nextCardIndex=i;}
direction=curCardIndex-nextCardIndex;});direction=(direction<0)?'right':'left';$('#'+currentCard).animate({left:(direction=='right')?rightPos:leftPos},slideOutTime);$(card).css('left',(direction=='right')?leftPos:rightPos).animate({left:centerPos},(direction=='right')?slideInFromLeftTime:slideInFromRightTime);updateCurrents(card);updateNav(card);}else{$('#'+currentCard).hide();$(card).show();updateCurrents(card);updateNav(card);}}
_gaq.push(['_trackEvent','Navigation','Go To',card.substring(1)]);}
function updateCurrents(card){currentCard=card.substring(1);}
$(function(){$('header nav a, section#intro a').click(function(e){e.preventDefault();var cardToShow=$(this).attr('href');if(cardToShow.substring(1)==currentCard){return false;}else{slideCardIn(cardToShow);}});$(window).keydown(function(e){if(e.keyCode==37){slideCardIn(findNextCard('left'));}else if(e.keyCode==39){slideCardIn(findNextCard('right'));}});});function updateNav(cardToShow){$('header nav li').removeClass('active');$('header nav li a').blur();$('header nav li a[href='+cardToShow+']').parent().addClass('active');}
function findNextCard(w){var allCards=$('section');var stopCard=(w=='left')?'intro':'skills';if(currentCard==stopCard){return false;}else{for(var x=0;x<allCards.length;x++){if($(allCards[x]).attr('id')==currentCard){var nextCard=(w=='left')?$(allCards[x-1]).attr('id'):$(allCards[x+1]).attr('id');return'#'+nextCard;}}}}
