var speed = 50;
var curId = 1;
var incrCount = 10;

function onLoad() {
	setMenuImage(currentSelection, 'hilite');

	if (maxImageCount>0)
		initImage();
}

function fadeInImage(id) {
    imageDivId = id + "Div";
    imageDiv = document.getElementById(imageDivId);
    imageDiv.style.backgroundImage = "url(none)";
    
    imageId = id;
    image = document.getElementById(imageId);
    setOpacity(image, 0);
    image.style.visibility = "visible";
    fadeIn(imageId, image.src, 0);
}
        
function initImage() {
    imageDivId = 'ImgDiv' + curId;
    imageDiv = document.getElementById(imageDivId);
    //imageDiv.style.backgroundImage = "url(none)";
    
    imageId = 'Img' + curId;
    image = document.getElementById(imageId);
    setOpacity(image, 0);
    image.style.visibility = "visible";
    fadeIn(imageId,image.src,0);
    curId++;
    window.setTimeout(nextImage, speed);
}
function nextImage()
{
    if (curId<=maxImageCount)
        initImage();
}

function fadeIn(objId, imgSrc, opacity) {
    
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (obj.src != imgSrc)
		    return;
        if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += incrCount;
			window.setTimeout("fadeIn('"+objId+"', '" + imgSrc + "',"+opacity+")", speed);
		}
	}
}

function setOpacity(obj, opacity) {

	if (obj!=null)
	{
		opacity = (opacity == 100)?99.999:opacity;
		// IE/Win
		obj.style.filter = "alpha(opacity:"+opacity+")";
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity/100;
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
	}
}

window.onload = function() {onLoad()}
