function promotion()
{
	// Set functions:
	this.load = promotion_load;
	this.timer = promotion_timer;
	this.previous = promotion_previous;
	this.next = promotion_next;
	this.show = promotion_show;
	
	this.click = promotion_click;
	this.changeOpac = promotion_changeOpac;
	this.display = promotion_display;
	
	// Set variables:
	this.objTimer;
	this.arrTimers = new Array();
	this.intSpeed = 30;
	this.intTimeout = 10000;
	this.intPromotion;
	this.intPrevpromotion;
	this.arrPromotions = new Array();
	
	function promotion_load()
	{
		// Find promotions:
		var x = 0;
		while(true)
		{
			var element = document.getElementById("promotion_" + x);
			var elementTitle = document.getElementById("promotionTitle_" + x);
			if(element != null)
			{
				this.arrPromotions[this.arrPromotions.length] = element;
				elementTitle.onmouseover = function()
				{
					arrId = this.id.split("_");
					promotion.show(arrId[1]);
				}
			}
			else
				break;
			
			element.onclick = this.click;
			elementTitle.onclick = this.click;
			
			x++;
		}
		if(this.arrPromotions.length > 0)
		{
			this.intPromotion = 0;
			this.intPrevpromotion = 0;
			this.display(1);
		}
	}
	function promotion_timer()
	{
		this.next();
	}
	function promotion_previous()
	{
		this.intPrevpromotion = this.intPromotion;
		
		this.intPromotion--;
		if(this.intPromotion < 0)
			this.intPromotion = this.arrPromotions.length - 1;
		
		this.display();
	}
	function promotion_next()
	{
		this.intPrevpromotion = this.intPromotion;
		
		this.intPromotion++;
		if(this.intPromotion == this.arrPromotions.length)
			this.intPromotion = 0;
		
		this.display();
	}
	function promotion_show(id)
	{
		this.intPrevpromotion = this.intPromotion;
		this.intPromotion = id;
		
		this.display();
	}
	
	function promotion_click()
	{
		var idName = this.id.split("_");
		window.location = document.getElementById("promotionImage_" + idName[1]).alt;
	}
	
	function promotion_display(first)
	{
		window.clearTimeout(this.objTimer);
		this.objTimer = window.setTimeout("promotion.timer()", this.intTimeout);
		
		if(this.intPrevpromotion == this.intPromotion)
			first = 1;
		
		if(!first)
		{
			document.getElementById("promotion_" + this.intPrevpromotion).style.display = "none";
			document.getElementById("promotionTitle_" + this.intPrevpromotion).className = "";
			
			for(i = 0; i < this.arrTimers.length; i++)
			{
				window.clearTimeout(this.arrTimers[i]);
			}
			
			var timer = 0;
			this.arrTimers = new Array();
			this.changeOpac(0);
			for(i = 0; i <= 100; i=i+5)
			{
				this.arrTimers[this.arrTimers.length] = window.setTimeout("promotion.changeOpac(" + i + ")",(timer * this.intSpeed));
				timer++;
			}
		}
		
		document.getElementById("promotion_" + this.intPromotion).style.display = "block";
		document.getElementById("promotionTitle_" + this.intPromotion).className = "selected";
	}
	
	
	function promotion_changeOpac(opacity)
	{
		var object = document.getElementById("promotion_" + this.intPromotion).style;
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = "alpha(opacity=" + opacity + ")";
	}
}
var promotion = new promotion;