function miFader(elementId, colorTransformer, activeAttribute, nSteps)
{
	this.element = null;
	this.elementId = elementId;
	this.ct = colorTransformer,
	this.fadeSteps = nSteps;
	this.fadeCount = 0;
	this.name = 'miFader_' + elementId + '_' + activeAttribute;
	this.fadeInterval = null;
	this.activeAttribute = activeAttribute;
	
	window[this.name] = this;
}

miFader.prototype.fade=function(bIn)
{
	if(!this.element)
		this.element = document.getElementById(this.elementId);
		
	if(this.fadeInterval)
		clearInterval(this.fadeInterval);

	if(bIn)
		this.fadeInterval = setInterval(this.name + '.fadeIn()', 30);
	else
		this.fadeInterval = setInterval(this.name + '.fadeOut()', 40);
}

miFader.prototype.fadeIn=function()
{
	if(!this.element)
		this.element = document.getElementById(this.elementId);

	this.fadeCount++;
	if(this.fadeCount > this.fadeSteps)
	{
		this.fadeCount = this.fadeSteps;
		clearInterval(this.fadeInterval);
		return;
	}
		
	switch(this.activeAttribute)
	{
		case 'color':
			this.element.style.color = this.ct.getColor(this.fadeCount/this.fadeSteps);
			break;
		case 'backgroundColor':
			this.element.style.backgroundColor = this.ct.getColor(this.fadeCount/this.fadeSteps);
			break;
		case 'borderColor':
			this.element.style.borderColor = this.ct.getColor(this.fadeCount/this.fadeSteps);
			break;
	}
}

miFader.prototype.fadeOut=function()
{
	this.fadeCount--;
	if(this.fadeCount < 0)
	{
		this.fadeCount = 0
		clearInterval(this.fadeInterval);
		return;
	}
	
	switch(this.activeAttribute)
	{
		case 'color':
			this.element.style.color = this.ct.getColor(this.fadeCount/this.fadeSteps);
			break;
		case 'backgroundColor':
			this.element.style.backgroundColor = this.ct.getColor(this.fadeCount/this.fadeSteps);
			break;
		case 'borderColor':
			this.element.style.borderColor = this.ct.getColor(this.fadeCount/this.fadeSteps);
			break;
	}
}
