function HexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function HexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function HexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}

col = 0;

function fade(TextToFade, FinalColour) {

    document.getElementById(TextToFade).style.color = "rgb(" + col + "," + col + "," + col + ")";
    col += 5;
    if(col < 255) {
        setTimeout('fade("'+ TextToFade +'", "' + FinalColour + '")', 10);
    }
    else {
        R = HexToR(FinalColour);
        G = HexToG(FinalColour);
        B = HexToB(FinalColour);    
        document.getElementById(TextToFade).style.color = "rgb(" + R + "," + G + "," + B + ")";
        col = 0;
    }    
}
