/*******************************************************************************
	AUTHOR:		Timothy Higgins
	CONTACT:	timothymichaelhiggins@gmail.com
*******************************************************************************/
	
	//Define variables.
	var _holdPromotion=false;
	var _promotion=0;
	var _promotions=new Array();
	
	/***************************************************************************
		Track mouse movement over the active promotion.
	***************************************************************************/
	function holdPromotion(holdPromotion){
		_holdPromotion=holdPromotion;
	}
	
	/***************************************************************************
		Load the current promotion.
	***************************************************************************/
	function loadPromotion(){
		if(_promotions.length==0)
			return false;
		
		//Load the current promotion.
		document.getElementById("promotion").src="promotion/photo.php?id="+_promotions[_promotion];
		document.getElementById("promotion").onclick=function(){
			window.location="promotion.php?id="+_promotions[_promotion];
		};
	}
	
	/***************************************************************************
		Advance to the next promotion.
	***************************************************************************/
	function nextPromotion(){
		if(_promotion==_promotions.length-1)
			_promotion=0;
		else
			_promotion++;
		loadPromotion();
	}
	
	/***************************************************************************
		Return to the previous promotion.
	***************************************************************************/
	function previousPromotion(){
		if(_promotion==0)
			_promotion=_promotions.length-1;
		else
			_promotion--;
		loadPromotion();
	}
	
	/***************************************************************************
		Move to the next promotion if the current promotion is not active.
	***************************************************************************/
	function rotatePromotions(){
		if(!_holdPromotion)
			nextPromotion();
	}
