var timers = new Array();

function animMouseOver(id, src, pos, anim)
{
    var img = document.getElementById(id);
    if (img && timers[id]) {
	img.setAttribute("src", src+pos+".png");
	if (pos < anim) {
	    pos++;
	    setTimeout("animMouseOver('"+id+"','"+src+"',"+pos+","+anim+")", 75);
	}
	else {
	    timers[id] = null;
	}
    }
}

function mouseOver(img, src, pos, anim)
{
    if (anim) {
	var id = img.getAttribute("id");
	timers[id] = setTimeout("animMouseOver('"+id+"','"+src+"',"+pos+","+anim+")", 1);
    }
    else {
	img.setAttribute("src", src);
    }
}

function mouseDown(img, src)
{
    var id = img.getAttribute("id");
    if (timers[id]) {
	clearTimeout(timers[id]);
	timers[id] = null;
    }
    img.setAttribute("src", src);
}

function mouseUp(img, src, loc)
{
    var id = img.getAttribute("id");
    if (timers[id]) {
	clearTimeout(timers[id]);
	timers[id] = null;
    }
    img.setAttribute("src", src);
    self.location = loc;
}

function mouseOut(img, src)
{
    var id = img.getAttribute("id");
    if (timers[id]) {
	clearTimeout(timers[id]);
	timers[id] = null;
    }
    img.setAttribute("src", src);
}

function init(id1, id2, inds, path)
{
    setTimeout("slideshowFade(0, '"+id1+"','"+id2+"', 2, "+inds+", '"+path+"');", 1);
}

function slideshowFade(step, id1, id2, ind, inds, path)
{
    var img1 = document.getElementById(id1);
    img1.style.opacity = 0.05 * step;
    if (step == 20) {
	var img2 = document.getElementById(id2);
	img2.src = path+ind+".jpg";
	if (ind ==inds)
	    ind = 1;
	else
	    ind++;
	img1.style.opacity = 0;
	img1.src = path+ind+".jpg";
	step = 0;
    }
    setTimeout("slideshowFade("+(step+1)+",'"+id1+"','"+id2+"',"+ind+","+inds+",'"+path+"');", step == 0? 3500 : 30);
}
