var images;
var currentimg = 1;
var oldie;
var go;

function loader(){
	images = document.getElementById('image-block').getElementsByTagName('img')
	checkBrowser();
	go = setInterval('rotate();',pause);
}

function initialise(){
	images[0].style.zIndex = 1;
	for (n=1;n<(images.length);n++){
		if (oldie){images[n].setAttribute('style','filter:alpha(0);');}
		else{images[n].setAttribute('style','opacity:0;');}
		images[n].style.zIndex = 0;
	}
}

function checkBrowser(){
	initialise();
	oldie = (images[1].filters)? true:false;
	}

function rotate(){
	if (currentimg==1){initialise();}
	if (currentimg<images.length){
		subrotate(currentimg)
	}
	else{
		currentimg=0;
		setOpacity(currentimg,0);
		subrotate(images.length)
	}
}

function subrotate(index){
	images[currentimg].style.zIndex=index;
	fadeIn(0,currentimg);
	currentimg++;
	if(imgloop== '0'){if (currentimg==images.length){clearInterval(go);return false;}}
}

function fadeIn(current,image){
	if (current<=40){
		var b = Math.sin(current*(Math.PI/80));
		setOpacity(image,b,current);
		current++;
		setTimeout('fadeIn('+current+','+image+')',fade);
	}
	
}

function setOpacity(objs,num,current){
	if (oldie){images[objs].style.filter = 'alpha(opacity=' + (num)*100 + ')';}
	else {images[objs].style.opacity = num;}
	if(current > 38){
	if (oldie){images[objs].style.filter = '';}
	}
}

addLoadEvent(loader);
