function mediabox(id)
{
	var self=this;
	this.SwitchTimer=0;
	this.AnimationTimer=0;
	this.direction=1;
	var current=0;
	var divs=document.getElementById(id).getElementsByTagName("div");
	var imagearray = new Array();
	var textarray = new Array();
	var numarray = new Array();
	var numcount = 0;
	var textcount = 0;
	var imgcount = 0;
	var step = 0;
	var fadestep = 10;
		if(navigator.appName=="Microsoft Internet Explorer")
			{
				var ver = (navigator.appVersion).substr(0,1);
				if(ver != "9")
					{
						fadestep = 100;
					}
			}
	var interval = 9000;
	var animationinterval = 25;
	var numstrip ="";
	for(var i=0;i<divs.length;i++)
		{
			if(divs[i].className == "featurenumberstrip")
				{
					numstrip=divs[i];
				}
			if(divs[i].className == "featuredirectionleft")
				{
					divs[i].onclick = function()
						{
							self.CDirection(0);
						}
				}
			if(divs[i].className == "featuredirectionright")
				{
					divs[i].onclick = function()
						{
							self.CDirection(1);
						}
				}
			if(divs[i].className == "featurediv")
				{
					imagearray[imgcount] = divs[i];
					imgcount++;
				}
			if(divs[i].className == "featurenumber")
				{
					numarray[numcount] = divs[i];
					divs[i].index = numcount;
					divs[i].onclick = function()
						{
							self.SwitchImg(this.index);
						};
					numcount++;
				}
			if(divs[i].className == "featuretextdiv")
				{
					textarray[textcount] = divs[i];
					textcount++;
				}

		}
	self.SwitchTimer=setTimeout(function(){self.SwitchImg('auto');},(interval*1.5));
	this.CDirection = function(d)
		{
			this.direction = d;
			self.SwitchImg("auto");
		}
	this.SwitchImg = function(x)
		{
			if(self.SwitchTimer)
				{
					clearTimeout(self.SwitchTimer);
					self.SwitchTimer=0;
				}
			if(self.AnimationTimer)
				{
					clearTimeout(self.AnimationTimer);
					self.AnimationTimer=0;
				}
			for(var i=0;i<imagearray.length;i++)
				{
					textarray[i].style.top="-415px";
					imagearray[i].style.opacity=0;
					imagearray[i].style.filter="alpha(opacity=0)";
					imagearray[i].style.display="none";
					numarray[i].style.backgroundPosition="0px 0px";
					
				}
			if(x=="auto")
				{
					if(this.direction)
						{
							if(current == (imgcount-1))
								{
									current = 0;
								}
							else
								{
									current++;
								}
						}
					else
						{
							if(current == 0)
								{
									current = imgcount-1;
								}
							else
								{
									current=current-1;
								}
						}

					
				}
			else
				{
					if (parseInt(x) < current)
						{
							this.direction = 0;
						}
					else
						{
							this.direction = 1;
						}
					current = x;
				}
			imagearray[current].style.display="block";
			if(textarray[current].innerHTML == "AD")
				{
					numstrip.style.display = "none";
				}
			else
				{
					numstrip.style.display = "block";
					numarray[current].style.backgroundPosition="1px -54px";
				}
			if(fadestep == 100)
				{
					textarray[current].style.top="25px";
					imagearray[current].style.opacity=1;
					imagearray[current].style.filter="alpha(opacity=100)";
					self.SwitchTimer=setTimeout(function(){self.SwitchImg('auto');},interval);
				}
			else
				{
					self.AnimationTimer=setTimeout(function(){self.animate();},animationinterval);
				}
		}
	this.animate = function()
		{
			if(step>100)
				{
					self.AnimationTimer=0;
					self.SwitchTimer=setTimeout(function(){self.SwitchImg('auto');},interval);
					step=0;
				}
			else
				{
					textarray[current].style.top=(textarray[current].offsetTop+39)+"px";
					imagearray[current].style.opacity=step;
					imagearray[current].style.filter="alpha(opacity="+(step)+")";
					step += fadestep;
					self.AnimationTimer=setTimeout(function(){self.animate();},animationinterval);
				}
		}

}
