function Fade(name, secsShow, secScroll)
{
	this.$name		= name;
	this.$secShow	= secsShow;
	this.$secScroll	= secScroll;

	this.$divs		= new Array();
	this.$mode		= 0;
	this.$divcnt	= 0;
	this.$divsel	= 0;
	this.$timer		= setInterval(this.$name + '.interval()', secsShow * 1000);
	this.$shift		= 100.0 / (((secScroll / 2) * 1000.0) / 32.0);
	this.$curShift	= 100.0;
}

Fade.prototype.add = function(id)
{
	var	div	= document.getElementById(id);

	if(!div)
	{
		alert('Can\'t find element ' + id);
		return;
	}

	this.$divs[this.$divcnt]	= div;
	this.$divcnt++;
}

Fade.prototype.interval = function()
{
	if(this.$mode == 0)									// If the mode was display
	{
		this.$mode		= 1;							// Set the mode to scrolling

		clearInterval(this.$timer);						// Clear the current timer
		this.$timer	= setInterval(this.$name + '.interval()', 32);	// Set a new timer every 32 ms
	}
	else if(this.$mode == 1)							// Else if the mode is scrolling
	{
		if(this.$curShift > 0.0)
		{
			this.$curShift	-= this.$shift;
			if(this.$curShift < 0.0)
				this.$curShift	= 0.0;

			setOpacity(this.$divs[this.$divsel], this.$curShift);
		}
		else
		{
			this.$divs[this.$divsel].style.display	= 'none';

			this.$divsel++;									// Increase the selected Div by one
			if(this.$divsel == this.$divcnt)				// If the new div is equal to the count
				this.$divsel	= 0;						//	then loop back to the begining

			setOpacity(this.$divs[this.$divsel], 0);
			this.$divs[this.$divsel].style.display	= 'block';

			this.$mode	= 2;
		}
	}
	else if(this.$mode == 2)
	{
		if(this.$curShift < 100.0)
		{
			this.$curShift	+= this.$shift;
			if(this.$curShift > 100.0)
				this.$curShift	= 100.0;

			setOpacity(this.$divs[this.$divsel], this.$curShift);
		}
		else
		{
			this.$mode	= 0;
			clearInterval(this.$timer);
			this.$timer	= setInterval(this.$name + '.interval()', this.$secShow * 1000);
		}
	}
}

function setOpacity(obj, opacity)
{
	opacity	= (opacity == 100) ? 99.999 : opacity;
  
	// IE/Win
	obj.style.filter		= "alpha(opacity:"+opacity+")";

	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity	= opacity/100;

	// Older Mozilla and Firefox
	obj.style.MozOpacity	= opacity/100;

	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity		= opacity/100;
}
