var currentPane = 0;

$(document).ready(function(){
	totalPanes = $('div.pane').length - 1;
	if(window.location.hash){
		var theHash = parseFloat(window.location.hash.substring(1)) - 1;
		showPane(theHash, false);
	}
	
	//pageTracker._trackPageview('/Feature Tour/' + $('ul#tabs').find('li').eq(currentPane).find('a > span').html());
});

function showPane(n, animation){
	if(n == currentPane){
		return;
	}else{
		// Scroll to the correct Pane
		var targetPosition = n * 750;
		if (animation == true){
			$('div#panels').animate({'left': '-'+targetPosition+'px'}, 500);
		}else{
			$('div#panels').css({'left': '-'+targetPosition+'px'});
		}
		
		
		// Change the tabs and GA
		$('ul#tabs').find('li').eq(currentPane).attr('class', 'off');
		var theTab = $('ul#tabs').find('li').eq(n).attr('class', 'on');
		
		//pageTracker._trackPageview('/Feature Tour/' + theTab.find('a > span').html());
		
		// Change the currentPane variable
		currentPane = n;
	}
}

function prevPane(){
	if(currentPane != 0){
		showPane(currentPane - 1, true);
	}else{
		showPane(totalPanes, true);
	}
}

function nextPane(){
	if(currentPane != totalPanes){
		showPane(currentPane + 1, true);
	}else{
		showPane(0, true);
	}
}
