var diaporamaContainer = document.getElementById("slideshow");
var allImgs = diaporamaContainer.getElementsByTagName('img'); 
var currentId=allImgs.length-1;

for (i=0; i<allImgs.length; i++) {
allImgs[i].id='img'+(i);
}

defilmage();

function defilmage(){
var opa=0;

lastId=this.currentId;

if ( currentId<(allImgs.length-1) ) {	currentId++; }
else { currentId=0; }

setNewOpacity(opa);
}

function setNewOpacity(Opaa){

currentImg = document.getElementById('img'+currentId);
lastImg = document.getElementById('img'+lastId);
 
currentImg.style.filter = 'alpha(opacity=' + Opaa + ');' ;
lastImg.style.filter = 'alpha(opacity=' + (100 - Opaa ) + ');';
currentImg.style.opacity = Opaa/100;
lastImg.style.opacity = 1-Opaa/100;
currentImg.style.display = 'block';
lastImg.style.display = 'block';

Opaa+=shadeStep;

if (Opaa<=100) {setTimeout(function() { setNewOpacity(Opaa) },shadeSpeed);}
else {
lastImg.style.display = 'none'; 
setTimeout(defilmage,speed);}
}
