// This is the amount of time (in milliseconds) that will lapse between each step in the fade
var FadeInterval = 80;

// This is list of steps that will be used for the color to fade out
var FadeSteps = new Array();
        FadeSteps[1] = "333333";  // final 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";  // starting colour of fade

// This is the recursive function call that actually performs the fade
function DoFade(colorId, targetId) 
{
  if (colorId >= 1) 
  {
    document.getElementById(targetId).style.backgroundColor = "#" + FadeSteps[colorId];

    // If it's the last color, set it to transparent
    if (colorId==1) 
    {
      document.getElementById(targetId).style.backgroundColor = "transparent";
    }
    colorId--;

    // Wait a little bit and fade another shade
    setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);
  }
}