function cColorFader(StartColor, EndColor)
{
	var aStartColor 			= StartColor.split('#');
	var SplitStartColor 	= aStartColor[1];
	var aSplitStartColor 	= new Array();
	aSplitStartColor[0] 	= SplitStartColor.substr(0,2);
	aSplitStartColor[1] 	= SplitStartColor.substr(2,2);
	aSplitStartColor[2] 	= SplitStartColor.substr(4,2);

	this.StartRed	 				= this.h2d(aSplitStartColor[0]);
	this.StartGreen				= this.h2d(aSplitStartColor[1]);
	this.StartBlue 				= this.h2d(aSplitStartColor[2]);
	
	//alert("start: " + this.StartRed + " :: " + this.StartGreen + " :: " + this.StartBlue);
	
	var aEndColor 				= EndColor.split('#');
	var SplitEndColor 		= aEndColor[1];
	var aSplitEndColor 		= new Array();
	aSplitEndColor[0] 		= SplitEndColor.substr(0,2);
	aSplitEndColor[1] 		= SplitEndColor.substr(2,2);
	aSplitEndColor[2] 		= SplitEndColor.substr(4,2);

	this.EndRed	 					= this.h2d(aSplitEndColor[0]);
	this.EndGreen					= this.h2d(aSplitEndColor[1]);
	this.EndBlue 					= this.h2d(aSplitEndColor[2]);
	
	//alert("end: " + this.EndRed + " :: " + this.EndGreen + " :: " + this.EndBlue);

	this.steps = 20;
  this.speed = 10;
	
	this.aGoColorTimers = new Array();
	this.MouseOutTimer = null;
	this.bFadingIn = false;
}

cColorFader.prototype.d2h = function(d) {return d.toString(16);}
cColorFader.prototype.h2d = function(h) {return parseInt(h,16);} 

cColorFader.prototype.FadeOut = function(obj)
{
	var _this = this;
  this.MouseOutTimer = setTimeout(function() { _this.FadeOutEx(obj) }, 400);
}

cColorFader.prototype.FadeOutEx = function(obj)
{
	this.bFadingIn = false;
	this.ClearTimers();
	this.Fade(obj, this.EndRed, this.EndGreen, this.EndBlue, this.StartRed, this.StartGreen, this.StartBlue);
}

cColorFader.prototype.FadeIn = function(obj)
{
	clearTimeout(this.MouseOutTimer);
	if(this.bFadingIn) {
	} else {
		this.bFadingIn = true;
		this.ClearTimers();
		this.Fade(obj, this.StartRed, this.StartGreen, this.StartBlue, this.EndRed, this.EndGreen, this.EndBlue);
	}
}

cColorFader.prototype.ClearTimers = function()
{
	for(var i = 0; i < this.aGoColorTimers.length; i++)
	{
		clearTimeout(this.aGoColorTimers[i]);	
	}
	this.aGoColorTimers = new Array();
}

cColorFader.prototype.Fade = function(obj, StartRed, StartGreen, StartBlue, EndRed, EndGreen, EndBlue, cbWhenDone)
{
  var steps = this.steps;
  var speed = this.speed;
  var bUp = true;
  if(EndRed < StartRed)
  {
  	bUp = false;
  }
  
   var EndColor = "rgb("+EndRed+", "+EndGreen+", "+EndBlue+")";
  //debug(obj.style.backgroundColor.replace(/ /g, ""));
  if(obj.style.backgroundColor.replace(/ /g, "") == EndColor.replace(/ /g, "")) {
  	this.bFadingIn = false;
  	return;
  }
  
  var redint 		= Math.round(Math.abs(StartRed		-	EndRed)/steps);
  var greenint 	= Math.round(Math.abs(StartGreen	-	EndGreen)/steps);
  var blueint 	= Math.round(Math.abs(StartBlue  -	EndBlue)/steps);
  if(redint == 0) { redint = 1 }
  if(greenint == 0) { greenint = 1 }
  if(blueint == 0) { blueint = 1 }
  //obj.style.backgroundColor = 'rgb(' + StartRed+ ',' + StartGreen + ',' + StartBlue + ')';
  for(var tCounter = 0; tCounter <= steps; tCounter++)
  { 
  	if(bUp) {
  		this.GoColor(obj, (StartRed + (tCounter * redint)), (StartGreen + (tCounter * greenint)), (StartBlue + (tCounter * blueint)), (tCounter * speed));  
  	} else {
  		this.GoColor(obj, (StartRed - (tCounter * redint)), (StartGreen - (tCounter * greenint)), (StartBlue - (tCounter * blueint)), (tCounter * speed));  
  	}
  }
  this.aGoColorTimers.push(setTimeout( function() { ConvertColor(obj, 'rgb(' + EndRed+ ',' + EndGreen + ',' + EndBlue + ')'); }, steps * speed));
}

cColorFader.prototype.GoColor = function(obj, ColorRed, ColorGreen, ColorBlue, TimeOut)
{
	this.aGoColorTimers.push(setTimeout( function() { ConvertColor(obj, 'rgb(' + ColorRed+ ',' + ColorGreen + ',' + ColorBlue + ')'); }, TimeOut));
}

function ConvertColor(target, FontColor) 
{
	target.style.backgroundColor = FontColor;
	var aSub = target.childNodes;
  	if(aSub.length > 0) {
  	 for(var i = 0; i < aSub.length; i++) {
  		 if(aSub[i].nodeType == 1) {
  		   ConvertColor(aSub[i], FontColor);
  		 }
  	  }
  	}
}


function debug(value)

{

  document.getElementById("debug").innerHTML += value + "<br />";

}