
$(document).ready(function(){
	$.easing.easeInOutExpo = function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	};
	var $paneTarget = $('.scrollWin');
	$paneTarget.scrollTo( 0 );
	$.scrollTo( 0 );
	scrollInit = function() {
		var $scrollOffset = $('.allHeroes').offset();
		var $contentOffset = $('.content').offset();
		$actualOffset = $scrollOffset.left - $contentOffset.left;
		if ($actualOffset > -3750) {
			$paneTarget.scrollTo('+=950px',0 , {duration:1000,axis:'x',easing:'easeInOutExpo'} );
		} else {
			$paneTarget.scrollTo(0,0 , {duration:1000,axis:'x',easing:'easeInOutExpo'} );
		}
	}
	$paneTarget.click(function() {
		scrollInit();
		clearInterval(autoScroll);
		autoScroll = setInterval("scrollInit();", 7000);
	});
	$('.heroNav a').click(function(){
		clearInterval(autoScroll);
		autoScroll = setInterval("scrollInit();", 7000);
		$paneTarget.scrollTo($(this).attr('href'), {duration:1000,axis:'x',easing:'easeInOutExpo'});
		return false;
	});
	autoScroll = setInterval("scrollInit();", 7000);
});