var ie4=document.all;
var dom=document.getElementById;
var curpos=0;
var curphoto=0;
var curimageindex=0;
var nextimageindex=1;

function fadepic(){
	if (curpos<100){
		curpos+=8;
		if (tempobj.filters) {
			tempobj.filters.alpha.opacity=curpos;
		} else if (tempobj.style.MozOpacity) {
			tempobj.style.MozOpacity=(curpos*.01)-.01;
		}
	} else {
		clearInterval(dropslide);
		tempobj=ie4? eval("document.all.photo"+nextimageindex) : document.getElementById("photo"+nextimageindex);
		nextimageindex= (nextimageindex+1) % numSlides;
		setTimeout("rotateimage()",pause*1000);
	}
}

function rotateimage(){
	if (ie4||dom){
		resetit(curphoto);
		var crossobj = tempobj = ie4 ? eval("document.all.photo"+curphoto) : document.getElementById("photo"+curphoto);
		var temp = 'setInterval("fadepic()",80)';
		dropslide = eval(temp);
		curphoto = (curphoto + 1) % numSlides;
	} else {
        document.layers["photo"+curphoto].visibility = "hide";
		curphoto = (curphoto + 1 ) % numSlides;
        document.layers["photo"+curphoto].visibility = "show";	
	}
}

function resetit(what){
	curpos=0;
	var crossobj=ie4? eval("document.all.photo"+what) : document.getElementById("photo"+what);
	if (crossobj.filters) {
		crossobj.filters.alpha.opacity=curpos;
	} else if (crossobj.style.MozOpacity) {
		crossobj.style.MozOpacity=curpos/100;
	}
	crossobj.style.zIndex++;
}

function startit(){
	rotateimage();
}

if (ie4||dom) {
	window.onload=startit;
} else {
	setInterval("rotateimage()",pause*1000);
}
