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

var d = document, current = 0, nIndex = 0, imgs = new Array(), zInterval = null, pause = false;

function init() {
	if(!d.getElementById || !d.createElement){
		return;
	}
	imgs = d.getElementById("presentation").getElementsByTagName("img");
	for(i = 0; i < imgs.length; i++) {
	 imgs[i].xOpacity = 0;	
	}
	current = Math.floor(Math.random() * 10);
	nIndex = current;
	while (current == nIndex) {
		nIndex = Math.floor(Math.random() * 10);	
	}
	imgs[current].style.display = "block";
	imgs[current].xOpacity = .99;
	setTimeout(fade, 5000);
}

function fade() {
	cOpacity = imgs[current].xOpacity;
	nOpacity = imgs[nIndex].xOpacity;	
	cOpacity -= .05; 
	nOpacity += .05;	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);	
	if(cOpacity <= 0) {
		imgs[current].style.display = "none";
		current = nIndex;
		while (current == nIndex) {
			nIndex = Math.floor(Math.random() * 10);	
		}
		setTimeout(fade, 5000);
	} else {
		setTimeout(fade, 50);
	}	
	function setOpacity(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) + ")";
	}	
}
