/*****
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_init1,false):window.attachEvent("onload",so_init1);

var d1=document, imgs1 = new Array(), zInterval = null, current1 = 0, pause=false;

function so_init1() {
	if(!d1.getElementById || !d1.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
	css1 = d1.createElement("link");
	css1.setAttribute("href","xfade1.css");
	css1.setAttribute("rel","stylesheet");
	css1.setAttribute("type","text/css");
	d1.getElementsByTagName("head")[0].appendChild(css1);

	imgs1 = d1.getElementById("baner1x").getElementsByTagName("img");
	for(i1=1;i1<imgs1.length;i1++) {
	
	imgs1[i1].xOpacity1 = 0;
	imgs1[i1].style.visibility = "hidden";
	}
	imgs1[0].style.visibility = "visible";
	imgs1[0].style.display = "block";
	imgs1[0].style.position = "absolute";
	imgs1[0].xOpacity1 = 1.0;
	
	setTimeout(so_xfade1,3000); // czas do pierwszej zmiany
}

function so_xfade1() {
	cOpacity1 = imgs1[current1].xOpacity1;
	nIndex1 = imgs1[current1+1]?current1+1:0;

	nOpacity1 = imgs1[nIndex1].xOpacity1;
	
	cOpacity1-=.05; 
	nOpacity1+=.05;
	
	imgs1[nIndex1].style.display = "block";
	imgs1[nIndex1].style.position = "absolute";
	imgs1[nIndex1].style.visibility = "visible";
	imgs1[nIndex1].style.left = "0px";
	imgs1[current1].xOpacity1 = cOpacity1;
	imgs1[nIndex1].xOpacity1 = nOpacity1;
	
	setOpacity1(imgs1[current1]);
	setOpacity1(imgs1[nIndex1]);

	
	if(cOpacity1<=0) {
		imgs1[current1].style.display = "none";
		imgs1[current1].style.position = "relative";
		current1 = nIndex1;
		setTimeout(so_xfade1,3000); // czas pomiedzy kolejnymi obrazkami
	} else {
		setTimeout(so_xfade1,25);
	}
	
	function setOpacity1(obj) {
		if(obj.xOpacity1>1.0) {
			obj.xOpacity1 = 1.0;
			return;
		}
		obj.style.opacity = obj.xOpacity1;
		obj.style.MozOpacity = obj.xOpacity1;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity1*100) + ")";
	}
}
