function effect(oObject)
{
	this.object	= oObject;
}

effect.prototype.run = function()
{
	switch (this.type) {
		default :
			this.fade();
	}
}

effect.prototype.fade = function()
{
	if (!this.object.style.opacity)
		this.object.style.opacity = 1;
	
	this.currentOpacity = this.object.style.opacity*100;
	this.offset = 0;
	
	if (this.currentOpacity < this.target) {
		this.lockProportions();
		this.fadeIn();
		this.changeContent();
		this.gracefulResize();
		this.fadeRestore();
	}
	else
	if (this.currentOpacity > this.target) {
		this.lockProportions();
		this.fadeOut();
		this.changeContent();
		this.gracefulResize();
		this.fadeRestore();
	}
}

effect.prototype.lockProportions = function()
{
	this.object.style.height = this.object.scrollHeight+"px";
	this.object.style.width = this.object.scrollWidth+"px";
}

effect.prototype.fadeOut = function()
{
	var iDifference		= this.currentOpacity-this.target;
	var iFrequency 		= this.mSeconds/Math.abs(iDifference);
	this.prevOpacity	= this.currentOpacity;
	
	for (var i = this.currentOpacity; i >= this.target; i--) 
	{
		setTimeout("SetOpacity('"+this.object.id+"', "+i+")", this.offset*iFrequency);
		this.offset++;
	}
}

effect.prototype.fadeIn = function()
{
	var iDifference		= this.currentOpacity-this.target;
	var iFrequency 		= this.mSeconds/Math.abs(iDifference);
	this.prevOpacity	= this.currentOpacity;
	
	for (var i = this.currentOpacity; i <= this.target; i++)
	{
		setTimeout("SetOpacity('"+this.object.id+"', "+i+")", this.offset*iFrequency);
		this.offset++;
	}
}

effect.prototype.gracefulResize = function()
{
	var innerHTML = this.object.innerHTML;
	
	this.object.innerHTML = this.object.innerHTML+"<div id=\""+this.object.id+"Resize\" style=\"clear:both;overflow:hidden;visibility:hidden;\"></div>";
	var oResize	= document.getElementById(this.object.id+"Resize");
	
	if (oResize) {
		oResize.innerHTML = this.newContent;
		
		var	x					= Math.floor(this.object.style.width.replace(/px|\%/g, ''));
		var y					= Math.floor(this.object.style.height.replace(/px|\%/g, ''))
		var iXdiff				= Math.abs(oResize.scrollWidth) - x;
		var iYdiff				= Math.abs(oResize.scrollHeight) - y;
		
		this.object.innerHTML = innerHTML;
		this.gracefulResizeSet("x", x, iXdiff);
		this.gracefulResizeSet("y", y, iYdiff);
	}
}

effect.prototype.gracefulResizeSet = function(x_y, iBase, iDiff)
{
	var iOffset		= 0;
	var iPerc		= 0;
	var iPrev		= 0;
	var iFrequency 	= this.mSeconds/Math.abs(iDiff);
	
	if (iDiff < 0 || iDiff > 0) {
		for (var i = 0; i <= Math.abs(iDiff); i++)
		{
			iPerc	= Math.floor((i/Math.abs(iDiff))*100)/100;
			
			if (iPerc > iPrev) {
				setTimeout("Resize"+x_y.toUpperCase()+"('"+this.object.id+"', " + (iBase+(iDiff*iPerc)) + ")", iOffset*iFrequency);
				iPrev = iPerc;
			}
			
			iOffset++;
		}
	}
}

effect.prototype.fadeRestore = function()
{
	if (this.restore === true) {
		this.currentOpacity = this.target;
		this.target = this.prevOpacity;
		
		if (this.target > this.currentOpacity)
			this.fadeIn();
		else
		if (this.target < this.currentOpacity)
			this.fadeOut();
	}
}

effect.prototype.changeContent = function()
{
	if (this.newContent)
		setTimeout("SetInnerHTMLfromEffect('"+this.object.id+"')", this.mSeconds);
}