/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/


window.addEventListener?window.addEventListener("load",a3_init,false):window.attachEvent("onload",a3_init);


var f=document, imgs3 = new Array(), zInterval3 = null, current3=0, pause=false;

function a3_init() {
    	if(!f.getElementById || !f.createElement)return;
	
    	
	imgs3 = f.getElementById("bund_billeder_rotation_kasse2").getElementsByTagName("IMG");
	for(i=1;i<imgs3.length;i++) imgs3[i].xOpacity = 1;
	imgs3[0].style.display = "block";
	imgs3[0].xOpacity = .99;
	
	setTimeout(a3_xfade,0);
	
}

function a3_xfade() {
	cOpacity = imgs3[current3].xOpacity;
	nIndex = imgs3[current3+1]?current3+1:0;
	nOpacity = imgs3[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs3[nIndex].style.display = "block";
	imgs3[current3].xOpacity = cOpacity;
	imgs3[nIndex].xOpacity = nOpacity;
	
		setOpacity3(imgs3[current3]); 
	setOpacity3(imgs3[nIndex]);
	
	if(cOpacity<=0) {
		imgs3[current3].style.display = "none";
		current3 = nIndex;
	    setTimeout(a3_xfade,2000);
	} else {
		setTimeout(a3_xfade,50);
	}
	
	function setOpacity3(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}