/*****
Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*****/

window.addEventListener?window.addEventListener("load",so_init5,false):window.attachEvent("onload",so_init5);

var d5=document, imgs5 = new Array(), zInterval = null, current5 = 0, pause=false;

function so_init5() {
	if(!d5.getElementById || !d5.createElement)return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	css5 = d5.createElement("link");
	css5.setAttribute("href","xfade5.css");
	css5.setAttribute("rel","stylesheet");
	css5.setAttribute("type","text/css");
	d5.getElementsByTagName("head")[0].appendChild(css5);

	imgs5 = d5.getElementById("baner5x").getElementsByTagName("img");
	for(i5=1;i5<imgs5.length;i5++) {
	
	imgs5[i5].xOpacity5 = 0;
	imgs5[i5].style.visibility = "hidden";
	}
	imgs5[0].style.visibility = "visible";
	imgs5[0].style.display = "block";
	imgs5[0].style.position = "absolute";
	imgs5[0].xOpacity5 = 1.0;
	
	setTimeout(so_xfade5,2000); // czas do pierwszej zmiany
}

function so_xfade5() {
	cOpacity5 = imgs5[current5].xOpacity5;
	nIndex5 = imgs5[current5+1]?current5+1:0;

	nOpacity5 = imgs5[nIndex5].xOpacity5;
	
	cOpacity5-=.05; 
	nOpacity5+=.05;
	
	imgs5[nIndex5].style.display = "block";
	imgs5[nIndex5].style.position = "absolute";
	imgs5[nIndex5].style.visibility = "visible";
	imgs5[nIndex5].style.left = "0px";
	imgs5[current5].xOpacity5 = cOpacity5;
	imgs5[nIndex5].xOpacity5 = nOpacity5;
	
	setOpacity5(imgs5[current5]);
	setOpacity5(imgs5[nIndex5]);

	
	if(cOpacity5<=0) {
		imgs5[current5].style.display = "none";
		imgs5[current5].style.position = "relative";
		current5 = nIndex5;
		setTimeout(so_xfade5,3000); // czas pomiedzy kolejnymi obrazkami
	} else {
		setTimeout(so_xfade5,25);
	}
	
	function setOpacity5(obj) {
		if(obj.xOpacity5>1.0) {
			obj.xOpacity5 = 1.0;
			return;
		}
		obj.style.opacity = obj.xOpacity5;
		obj.style.MozOpacity = obj.xOpacity5;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity5*100) + ")";
	}
}