
window.onload = function()
{
    var links = document.getElementsByTagName('a');
    for(var i = 0; i < links.length; i++)
    {
        if(links[i].className == 'trans')
        {
            links[i].id = 'trans' + i; // 1
            links[i].curRGB = new Array(startRGB[0]‚ startRGB[1]‚ startRGB[2]); // 2
            links[i].onmouseover = doTrans; // 3
            links[i].t_over = false;
            links[i].onmouseout = clTrans;
            links[i].t_out = false;
        }
    }
}

function doTrans()
{
    if(this.t_out) // 1
    {
        clearInterval(this.t_out);
        this.t_out = false;
    }
    if(this.t_over) return null; // 2
    this.t_over = setInterval('rgbTrans(\'' + this.id + '\'‚\'' + targetRGB[0] + '\'‚\'' + targetRGB[1] + '\'‚\'' + targetRGB[2] + '\')'‚ 25); // 3
}

function clTrans()
{
    if(this.t_over)
    {
        clearInterval(this.t_over);
        this.t_over = false;
    }
    if(this.t_out) return null;
    this.t_out = setInterval('rgbTrans(\'' + this.id + '\'‚\'' + startRGB[0] + '\'‚\'' + startRGB[1] + '\'‚\'' + startRGB[2] + '\')'‚ 25);
}

function rgbTrans(id‚ r‚ g‚ b)
{
    var link = document.getElementById(id); // 1
    var i = 25; // 2
    var curRGB = new Array(link.curRGB[0]‚link.curRGB[1]‚link.curRGB[2]); // 3
    var destRGB = new Array(parseInt(r)‚parseInt(g)‚parseInt(b)); // 4
    if(curRGB[0] == destRGB[0] && curRGB[1] == destRGB[1] && curRGB[2] == destRGB[2]) // 5
    {
        if(link.t_over)
        {
            clearInterval(link.t_over);
            link.t_over = false;
        }
        if(link.t_out)
        {
            clearInterval(link.t_out);
            link.t_out = false;
        }
        return null;
    }
    for(var j = 0; j < 3; j++) // 6
    {
        if(curRGB[j] > destRGB[j])
        {
            curRGB[j] = curRGB[j]–i > destRGB[j] ? curRGB[j]–i : destRGB[j];
        }
        else if(curRGB[j] < destRGB[j])
        {
            curRGB[j] = curRGB[j]+i < destRGB[j] ? curRGB[j]+i : destRGB[j];
        }
    }
    link.curRGB = curRGB; // 7
    link.style.color = 'rgb('+curRGB[0]+'‚'+curRGB[1]+'‚'+curRGB[2]+')'; // 8
}