var CESTA='/slide/';

Array.prototype.push = function(pPrvek) {
	return (this[this.length] = pPrvek);
}

var images=['01.gif', '02.gif', '03.gif', '04.gif', '05.gif', '06.gif', '07.gif', '08.gif', '09.gif', '10.gif', '11.gif', '12.gif', '13.gif', '14.gif'];
steps=30; //steps to fade from on pic to the next

var fTim=3*1000/steps; //prechod
var sTim=20*1000; //pauza mezi
var aktual= parseInt(images.length * Math.random());
var krok= 0;
var pArr = new Array();
var pFade;
var pNext;

for (var i=0; i<images.length; i++) {
	document.write('<div id="' + ('img' + i) + '" class="fadeImg"><a href="/index.htm"><img src="'+CESTA + images[i]+'" border="0"/></a></div>');
}

function myfade() {
	for(var i=0; i<images.length; i++) {
		pArr.push(document.getElementById('img' + i));
	}
	pArr[aktual].style.zIndex = 2;
	pArr[aktual].style.visibility = "visible";
	window.setTimeout("slide()",sTim);
}

function slide(){
	pFade = pArr[aktual];
	aktual++;
	if (aktual >= images.length)
		aktual=0;
	pNext=pArr[aktual];

	pFade.style.zIndex=2;
	pFade.style.visibility = "visible";
	opacity(pFade, 100);
	pNext.style.zIndex=1;
	pNext.style.visibility = "visible";
	opacity(pNext, 100);
	krok=0;
	slidenow();
}

function slidenow(){
	krok++;
	opacity(pFade, 100 - 100/steps*krok);

	if (100/steps*krok<=100){
		window.setTimeout("slidenow()", fTim);
		return;
	}

	pFade.style.visibility = "hidden";
	pNext.style.zIndex = 2;
	window.setTimeout("slide()", sTim);
}

function opacity(obj, num) {
	if (num>100)
		num=100;
	obj.style.filter = "alpha(opacity: " + num + ")";
	obj.style.KHTMLOpacity = num / 100;
	obj.style.MozOpacity = num / 100;
	obj.style.opacity = num / 100;
}

onload=myfade;
