// interval in ms between fade steps
var FadeInterval = 80;

// steps used for fade out
var FadeSteps = new Array();
	FadeSteps[1] = "333333";  // last colour
	FadeSteps[2] = "444444";  
	FadeSteps[3] = "555544";
	FadeSteps[4] = "666655";
	FadeSteps[5] = "777766";
	FadeSteps[6] = "999966";
	FadeSteps[7] = "AAAA66";
	FadeSteps[8] = "BBBB77";
	FadeSteps[9] = "CCCCAA";
	FadeSteps[10] = "DDDD88";
	FadeSteps[11] = "EEEE00";  
	FadeSteps[12] = "FFFF00";  // first colour

// recursive function to perform fade
function DoFade(colorId, targetId) 
{
  if (colorId >= 1) 
  {
	document.getElementById(targetId).style.backgroundColor = "#" + FadeSteps[colorId];

	// if last colour, set to transparent
	if (colorId==1) 
	{
	  document.getElementById(targetId).style.backgroundColor = "transparent";
	}
	colorId--;

	// wait, then do next fade step
	setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);
  }
}