var dci_display_duration = 4; // secondes
var dci_fade_duration = 1; // secondes

var dci_dd = (dci_display_duration * 1000);
var dci_fs = Math.round(100 / ((dci_fade_duration * 1000) / 25));

var rot_img = 0;
var nbImg = dci_ss.length;
var loadedImg = 0;
function countImg(){
	loadedImg++;
	if(loadedImg == nbImg){
		document.getElementById("sshow_image").style.display = "block";
		if(dci_lk[0] != ""){
			document.getElementById("sshow_link").setAttribute("href", dci_lk[0]);
			document.getElementById("sshow_skin").setAttribute("title", dci_tt[0]);
			document.getElementById("sshow_link").style.cursor = "pointer";
		}else{
			document.getElementById("sshow_link").removeAttribute("href");
			document.getElementById("sshow_link").style.cursor = "default";
		}
		setTimeout("doSlide(100)", dci_dd);
	}
}
function setOpacity(obj, opacity){
	opacity = (opacity <= 0)?0:opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";	// IE/Win
	obj.style.KHTMLOpacity = opacity/100; // Safari<1.2, Konqueror
	obj.style.MozOpacity = opacity/100; // Older Mozilla and Firefox
	obj.style.opacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3
}
function doSlide(opacity){
	opacity -= dci_fs;
	if(opacity <= 0){
		for(var i = 0; i < nbImg; i++){
			document.getElementById("img"+i).style.zIndex++;
		}
		document.getElementById("img"+rot_img).style.zIndex = (50-nbImg);
		setOpacity(document.getElementById("img"+rot_img), 100);
		rot_img = (rot_img == (nbImg-1))?0:rot_img+1;
		if(dci_lk[rot_img] != ""){
			document.getElementById("sshow_link").setAttribute("href", dci_lk[rot_img]);
			document.getElementById("sshow_skin").setAttribute("title", dci_tt[rot_img]);
			document.getElementById("sshow_link").style.cursor = "pointer";
		}else{
			document.getElementById("sshow_link").removeAttribute("href");
			document.getElementById("sshow_link").style.cursor = "default";
		}
		setTimeout("doSlide(100)", dci_dd);
	}else{
		setOpacity(document.getElementById("img"+rot_img), opacity)
		setTimeout("doSlide("+opacity+")", 25);
	}
	
} 
function initSlide(){
	if(document.getElementById("sshow_image")){
		document.getElementById("sshow_image").style.display = "none";
		for(var i = 0; i < nbImg; i++){
			pix = document.createElement("img");
			pix.onload = countImg;
			pix.setAttribute("src", dci_ss[i]);
			pix.setAttribute("id", "img"+i);
			pix.setAttribute("width", 495);
			pix.setAttribute("height", 290);
			pix.className = "abs_img";
			setOpacity(pix, 100);
			pix.style.zIndex = 250-i;
			document.getElementById("sshow_image").appendChild(pix);
		}
	}
}

addLoadEvent(initSlide);