<!--
	
function fader(elementId,currentR,currentG,currentB) {
	this.elementId=elementId;
	this.currentRGB=new Array(currentR,currentG,currentB);

	this.setInRGB=_setInRGB;
	this.inRGB=new Array(0,0,0);
	this.inSteps=1;

	this.setOutRGB=_setOutRGB;
	this.outRGB=new Array(0,0,0);
	this.outSteps=1;

	this.fadeIn=_fadeIn;
	this.fadeOut=_fadeOut;
	this.targetRGB=new Array(0,0,0);
	this.stepRGB=new Array(0.0,0.0,0.0);

	this.timer;
	this.fadeTimeout=0;
	this.nextTimeout=0;
	this._doFade=__doFade;
	this._doNext=__doNull;

	this.objectId="__fader"+elementId;
	eval(this.objectId+"=this");
	return this;
}

function _setInRGB(inR,inG,inB,inSteps) {
	this.inRGB[0]=inR;
	this.inRGB[1]=inG;
	this.inRGB[2]=inB;
	if (!inSteps)         this.inSteps=20;
	else if (inSteps < 1) this.inSteps=1;
	else                  this.inSteps=inSteps;
}

function _setOutRGB(outR,outG,outB,outSteps) {
	this.outRGB[0]=outR;
	this.outRGB[1]=outG;
	this.outRGB[2]=outB;
	if (!outSteps)         this.outSteps=20;
	else if (outSteps < 1) this.outSteps=1;
	else                   this.outSteps=outSteps;
}

function _fadeIn(next,nextTimeout) {
	if (next) {
		if (nextTimeout) {
			this.nextTimeout=nextTimeout;
		} else {
			this.nextTimeout=0;
		}
		this._doNext=next;
	} else {
		this.nextTimeout=0;
		this._doNext=__doNull;
	}

	for(var i=0; i < 3; i++) {
		this.targetRGB[i]=this.inRGB[i];
		this.stepRGB[i]=(this.targetRGB[i] - this.currentRGB[i])/this.inSteps;
	}

	this.fadeTimeout=this.inSteps;
	if (this.timer) clearTimeout(this.timer);
	this.timer=setTimeout(this.objectId+"._doFade()",0);
}

function _fadeOut(next,nextTimeout) {
	if (next) {
		if (nextTimeout) {
			this.nextTimeout=nextTimeout;
		} else {
			this.nextTimeout=0;
		}
		this._doNext=next;
	} else {
		this.nextTimeout=0;
		this._doNext=__doNull;
	}

	for(var i=0; i < 3; i++) {
		this.targetRGB[i]=this.outRGB[i];
		this.stepRGB[i]=(this.targetRGB[i] - this.currentRGB[i])/this.outSteps;
	}

	this.fadeTimeout=this.outSteps;
	if (this.timer) clearTimeout(this.timer);
	this.timer=setTimeout(this.objectId+"._doFade()",0);
}

var __hexDigit=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");

function __hex(n) {
	if      (n <   0) return "00";
	else if (n <  16) return "0"+__hexDigit[n];
	else if (n > 255) return "ff";
	else              return n.toString(16);
}

function __doNull() {
	return true;
}
	
function __doFade() {
	var RGB=new Array(3);
	var object;
 
	for(var i=0; i < 3; i++) {
		if (Math.abs(this.targetRGB[i]-this.currentRGB[i]) < 1)
			this.currentRGB[i]=this.targetRGB[i];
		else if ((this.stepRGB[i] > 0 && this.currentRGB[i] < this.targetRGB[i]) ||
		         (this.stepRGB[i] < 0 && this.currentRGB[i] > this.targetRGB[i]))
			this.currentRGB[i]=this.currentRGB[i] + this.stepRGB[i];
		else    this.currentRGB[i]=this.targetRGB[i];
	
		RGB[i]=Math.round(this.currentRGB[i]);
	}

	if      (document.getElementById) object=document.getElementById(this.elementId);
	else if (document.all)            object=document.all[this.elementId];
	else if (document.layers)         object=document.layers[this.elementId];

 	if (object) { 
		if (object.style) object.style.color="#"+__hex(RGB[0])+__hex(RGB[1])+__hex(RGB[2]);
		else              object.color      ="#"+__hex(RGB[0])+__hex(RGB[1])+__hex(RGB[2]);
 	}

	if (Math.abs(this.targetRGB[0]-this.currentRGB[0]) >= 1 ||
	    Math.abs(this.targetRGB[1]-this.currentRGB[1]) >= 1 ||
	    Math.abs(this.targetRGB[2]-this.currentRGB[2]) >= 1) {
		if (this.timer) clearTimeout(this.timer);
		this.timer=setTimeout(this.objectId+"._doFade()",this.fadeTimeout);
	} else {
		if (this.timer) clearTimeout(this.timer);
		this.timer=setTimeout(this.objectId+"._doNext()",this.nextTimeout);
	}		
}

//-->
