// JavaScript Document
function carrousel(el){
var zoneimg=el;
var mydiv=document.createElement('DIV');
var aacolec=zoneimg.getElementsByTagName('IMG');
var tabimg=new Array();
var myint;
var intfade;
var imgactu;
var curopac=100;
var ascendant=false;
var textcolec;
var temps=5000;

zoneimg.style.position='relative';

this.allume=function(){

	for (var i=0 ; i<aacolec.length;i++){
		tabimg.push(aacolec[i].cloneNode(true))
	}
	while(zoneimg.childNodes.length >0){
			zoneimg.removeChild(zoneimg.childNodes[0]);
			}
	for (i=0 ;i<tabimg.length;i++){
		cur=zoneimg.appendChild(tabimg[i]);
		cur.style.top=0+'px';
		cur.style.left=0+'px';
		cur.style.position="absolute";
	}
	imgactu=tabimg.length;
	aacolec=zoneimg.getElementsByTagName('IMG');
	myint= setInterval(suivant,temps);

}

function suivant(){
	if (ascendant) {
		imgactu++;
		if (imgactu>aacolec.length-1) {
			imgactu=aacolec.length-1;
			for (i=0; i<aacolec.length;i++){
				aacolec[i].style.opacity=1;
				aacolec[i].style.filter="alpha(opacity=100)";
				}
			ascendant=false;
		}
	
			
	}
	else{
		imgactu--;
		if (imgactu<1) {
			imgactu=1;
			for (i=1; i<aacolec.length;i++){
				aacolec[i].style.opacity=0;
				aacolec[i].style.filter="alpha(opacity=0)";
				}
			ascendant=true;
		}
	}
	(ascendant)?curopac=0:curopac=100;
	intfade=setInterval(fadeinout,40);
}
function fadeinout(){
	if (ascendant) {
		curopac+=10;
		if (curopac>100){ 
			curopac=100;
			clearInterval(intfade);
			}
	}
	else{
		curopac-=10;
		if (curopac<0){ 
			curopac=0;
			clearInterval(intfade);
			}
	}
	aacolec[imgactu].style.opacity=curopac/100;
	aacolec[imgactu].style.filter="alpha(opacity="+curopac+" )";
}
}
