function initSlideShow(init) {
	var images = Array();

	// preload images
	/*
	for (i = 0; i<slideshow_headers.length; i++) {
		images[i] = new Image();
		images[i].src = slideshow_headers[i];
	}
	*/
	window.setTimeout("slideShowNext('"+init+"')", slideshow_interval*1000);
}

function slideShowNext(last) {
	// select next image === IN ORDER
/*
	if(animLock == true)
	{
		window.settimeout("slideShowNext('"+last+"')", slideshow_interval*1000);
		return;
	}
	animLock = true;
*/
	var i = 0;
	for (i=0; i<slideshow_headers.length; i++)
		if (slideshow_headers[i] == last)
			break;

	if (++i == slideshow_headers.length)
		i = 0;

	current = slideshow_headers[i];

	/*
	// select next image, other then previous === RANDOM
	do {
		slideshow_headers.sort(function() {return 0.5 - Math.random();})
		current = slideshow_headers[0];
	} while (current == last);
	*/

	obj = document.getElementById(slideshow_box);
	obj_a = document.getElementById(slideshow_link);

	if (last != '') {
		// fadeout previous
		fadeOut(slideshow_box, 100);
	}

	window.setTimeout(
		function slideshow_banner(){
			// change image
			obj.style.background = "url('"+current+"') no-repeat";
			obj_a.href = slideshow_links[i];

			// fadein new
			fadeIn(slideshow_box, 0);

			// schedule next change
			window.setTimeout("slideShowNext('"+current+"')", slideshow_interval*1000);
		},
		500 // fade out duration
	);
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	opacity = (opacity == 0)?0.001: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;
}

function fadeOut(objId, opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity >= 0) {
			setOpacity(obj, opacity);
			opacity -= 20;
			window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 50);
		}
	}
}

function fadeIn(objId, opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 5;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
		}
	}
}
