// JavaScript Document

jQuery(document).ready(function() {

	var presINT;
	var inPresEffect;
	
	jQuery('#presentation_tabs li').click(function() { setTab(this.id, 'this', true); });
	jQuery('#presentationNext').click(function() { setTab(jQuery('li.presCurrent'), 'next', true); });
	jQuery('#presentationPrev').click(function() { setTab(jQuery('li.presCurrent'), 'prev', true); });
	jQuery('#presentationPLAY').click(function() { presentationStart(); });
	jQuery('#presentationPAUSE').click(function() { presentationStop(); });
	
	
	function setTab(thisOne, isDoing, wasClicked)
	{
		if (inPresEffect == true) return false;
		inPresEffect = true;
		if (wasClicked == true) presentationStop();
		
		if(isDoing == 'next'){thisOne = thisOne.next().attr("id");}
		else if (isDoing =='prev'){thisOne = thisOne.prev().attr("id");}
		
		if (thisOne == null) {
			if(isDoing == 'prev'){thisOne = jQuery('li','#presentation_tabs').last().attr("id");}
			else {thisOne = jQuery('li','#presentation_tabs').first().attr("id");};
		}
		
		thisOne = '#'+thisOne;
		jQuery('div.PreSlideCurrent').fadeOut(110, function() {
															jQuery('div.PreSlide','div#presentation_images').removeClass('PreSlideCurrent');
															jQuery(thisOne+'_IMG').fadeIn(110);
															jQuery(thisOne+'_IMG').addClass('PreSlideCurrent');
															inPresEffect = false;
														 });
		jQuery('li',jQuery('#presentation_tabs')).removeClass('presCurrent');
		jQuery(thisOne).addClass('presCurrent');
		return true;
	}

	function presentationStart() {
			presINT = setInterval( function() { setTab(jQuery('li.presCurrent'), 'next'); }, 4000 );
			jQuery('#presentationPLAY').css("display","none");
			jQuery('#presentationPAUSE').css("display","inline");
	}
	
	function presentationStop() {
			clearInterval (presINT);
			jQuery('#presentationPLAY').css("display","inline");
			jQuery('#presentationPAUSE').css("display","none");
	}
	
	if ( jQuery('#presentationHolder') )  presentationStart();



		
	setInterval('nextFooterBox()',4000);



});
	var footerBoxCount = 3;
	var isAnimating = true;
	var footerCurrent = 1;
	var footerWidth = 960;
	function nextFooterBox(){

		if ( footerCurrent == footerBoxCount ) footerCurrent = 1;
		else footerCurrent = footerCurrent + 1;
		
		isAnimating = true;
		var newPosition = (footerCurrent-1) * footerWidth;
		jQuery('#footer_sponsors_container').animate({
			left: '-'+newPosition+'px'
			  }, 500, function() {
			isAnimating = false;
		  });
	}

