var alpha=0;
var i=0;
var myDiapo, myTimeout;
//var l_img= new Array('images/1.jpg','images/2.jpg','images/3.jpg','images/4.jpg','images/5.jpg','images/6.jpg','images/7.jpg','images/8.jpg')
function effetMyDiapo(){
	var speed=5;
	if(alpha<100){
		alpha+=speed;
		document.getElementById(myDiapo).style.filter="alpha(opacity="+alpha+")";
		document.getElementById(myDiapo).style.opacity = alpha/100;
		compteur=setTimeout(effetMyDiapo,100);
	}
	else{
		alpha=0;
		clearTimeout(compteur);
	}
}
//******************************************************************//
function nextSlide(){
	
	if(document.getElementById(myDiapo).complete){
		if((i+1)<l_img.length){
			alpha=0;
			i++;
		}
		else{
			alpha=0;
			i=0;
		}
		var img=new Image();
		img.src=l_img[i];
		//var s_max=getMaxSize(img.width, img.height, 830, 600);
		if(img.complete==false){
			img.onload=function tmp_fct1(){
				document.getElementById(myDiapo).src=img.src;
				//document.getElementById(myDiapo).width=s_max[0];
				//document.getElementById(myDiapo).height=s_max[1];
				effetMyDiapo();
			};
		}
		else{
			document.getElementById(myDiapo).src=img.src;
			//document.getElementById(myDiapo).width=s_max[0];
			//document.getElementById(myDiapo).height=s_max[1];
			effetMyDiapo();
		}
	}
}
//*******************************************************************//
function loopMyDiapo(){
	nextSlide();
	cpt=setTimeout(loopMyDiapo,myTimeout);
}
/******************************************************************/
function startMyDiapo(img, temps){
	myDiapo=img;
	myTimeout=temps;
	loopMyDiapo();
}
//*************************************************************************************//
function getMaxSize(w, h, w_max, h_max){
	if(w > w_max){
		w_new = w_max;
		h_new = h * w_max / w;
		w=w_new;
		h=h_new;
	}
	if(h > h_max){
		h_new = h_max;
		w_new = w * h_max / h;
		w=w_new;
		h=h_new;
	}
	return Array(w,h);
}
//***************************************************************************************//
function setBackground(id, color){
	document.getElementById(id).style.background=color;
}
//***************************************************************************************//