// This is the amount of time (in milliseconds) that will lapse between each step in the fade
var FadeInterval = 150;

// This is list of steps that will be used for the color to fade out
var FadeSteps = new Array("ee", "dd", "cc", "bb", "aa", "99", "88", "77", "66", "55", "44");

// This is where the fade will start, if you want it to be faster and start with a lighter color, make this number smaller
// It corresponds directly to the FadeSteps below
var StartFadeAt = FadeSteps.length - 1;

function fadeOut(targetId)
{
    DoFade(StartFadeAt, targetId);
}

// This is the recursive function call that actually performs the fade
function DoFade(colorId, targetId)
{
    if(colorId >= 0)
    {
        document.getElementById(targetId).style.backgroundColor = "#ffff" + FadeSteps[colorId];

        // If it's the last color, set it to transparent
        if(colorId == 0)
            document.getElementById(targetId).style.backgroundColor = "transparent";

        // Wait a little bit and fade another shade
        setTimeout(function(){DoFade(colorId - 1, targetId);}, FadeInterval);
        // "DoFade("+(colorId-1)+",'"+targetId+"')"
    }
}

