
var ie5=(document.getElementById && document.all);
var ns6=(document.getElementById && !document.all);

var tbl;
var images;
var timer;
var opcty;

function loaded()
{
    tbl = document.getElementById("gallery_links");
    images = tbl.getElementsByTagName("img");
    nn = images.length / 2;
    timer = new Array(nn);
    opcty = new Array(nn);
    for (ii = 0; ii < nn; ii++)
    {
        opcty[ii] = 0;
    }
}

function hide(idx)
{
    if (timer[idx])
    {
        clearTimeout(timer[idx]);
        timer[idx] = undefined;
    }
    fadeOut(idx);
}

function show(idx)
{
    if (timer[idx])
    {
        clearTimeout(timer[idx]);
        timer[idx] = undefined;
    }
    fadeIn(idx);
}


//  Fade in an image
function fadeIn(idx)
{
    if (ie5  ||  ns6)
    {
        img = images.item(idx * 2 + 1);
        img.style.visibility = "visible";
        if (ie5)
        {
            img.style.filter = "alpha(opacity=" + opcty[idx] + ")";
        }
        else
        {
            img.style.MozOpacity = opcty[idx] / 100.0;
        }
        if (opcty[idx] < 100)
        {
            opcty[idx] += 10;
            timer[idx] = setTimeout("fadeIn(" + idx + ")", 50);
        }
    }
}


//  Fade out an image
function fadeOut(idx)
{
    if (ie5  ||  ns6)
    {
        img = images.item(idx * 2 + 1);
        if (ie5)
        {
            img.style.filter = "alpha(opacity=" + opcty[idx] + ")";
        }
        else
        {
            img.style.MozOpacity = opcty[idx] / 100.0;
        }
        if (opcty[idx] > 0)
        {
            opcty[idx] -= 10;
            timer[idx] = setTimeout("fadeOut(" + idx + ")", 50);
        }
        else
        {
            img.style.visibility = "hidden";
        }
    }
}


