var opaciteMax = 100;
var opaciteMin = 0;
var opacite=opaciteMin;
var sensAfficher=true;

var imgCouranteASC = document.getElementById("diaporamaPhotoASC");
var imgCouranteDESC = document.getElementById("diaporamaPhotoDESC");

var anciennePhotoASC = 1;
var anciennePhotoDESC = 1;

var imgProchaineASC = document.createElement('img');
var imgProchaineDESC = document.createElement('img');


var isIE = (navigator.appName == "Microsoft Internet Explorer");
		
function fadePic(){		
	if (opacite<opaciteMax && sensAfficher){opacite+=2;}
	if (opacite>opaciteMin && !sensAfficher){opacite-=2;}
	if (opacite>=opaciteMax){sensAfficher=false;}
	if (opacite<=opaciteMin){sensAfficher=true;}
	if (isIE) {
		imgCouranteASC.style.filter = "alpha(opacity="+opacite+")";
		imgCouranteDESC.style.filter = "alpha(opacity="+(100-opacite)+")";
		}
	else {
		imgCouranteASC.style.opacity=opacite/100;
		imgCouranteDESC.style.opacity=(100-opacite)/100;
		}
	
	if ((opacite == opaciteMax) || (opacite == opaciteMin)) {	
		defilementVignettes();
		}
}

var maxPhotos = 10;
var prochainePhotoASC = Math.floor(Math.random()*maxPhotos)+1;
var prochainePhotoDESC = Math.floor(Math.random()*maxPhotos)+1;
imgProchaineASC.src = "/thuerry_home/img"+prochainePhotoASC+".jpg";
imgProchaineDESC.src = "/thuerry_home/img"+prochainePhotoDESC+".jpg";

function defilementVignettes() {
	if ((opacite == opaciteMax) ) {
		//Changement de l'img DESC arrivée à 0
		imgCouranteDESC.src = imgProchaineDESC.src;
		anciennePhotoDESC = prochainePhotoDESC;
		do {
			prochainePhotoDESC = Math.floor(Math.random()*maxPhotos)+1;
			}
		//while (prochainePhotoDESC == anciennePhoto);
		while ((prochainePhotoDESC == anciennePhotoDESC) || (prochainePhotoDESC == anciennePhotoASC) || (prochainePhotoDESC == prochainePhotoASC));
		imgProchaineDESC.src = "/thuerry_home/img"+prochainePhotoDESC+".jpg";
		}
	else {
		//Changement de l'img ASC arrivée à 0
		imgCouranteASC.src = imgProchaineASC.src;
		anciennePhotoASC = prochainePhotoASC;
		do {
			prochainePhotoASC = Math.floor(Math.random()*maxPhotos)+1;
			}
		while ((prochainePhotoASC == anciennePhotoASC) || (prochainePhotoASC == anciennePhotoDESC) || (prochainePhotoASC == prochainePhotoDESC));
		imgProchaineASC.src = "/thuerry_home/img"+prochainePhotoASC+".jpg";
		}
	}
	
defilementVignettes(); 
timerFondu = setInterval(function(){fadePic();}, 100);
