var ListePhotos;
var indicePhotoCourante=-1;
var typeDocument="image";
var ImageCopieEcran;
function chargeEnsemblePhoto(documentCourant,nomTag){
	ListePhotos=new Array();
	var lesPhotos=documentCourant.getElementsByName(nomTag);
	for(var i=0;i<lesPhotos.length;i++){
		ListePhotos[i]=new Image();
		ListePhotos[i].src=lesPhotos[i].innerHTML;
		ListePhotos[i].src=ListePhotos[i].src.replace("\n","");
	}
	typeDocument="image";
	initialiseZoneAffichage();
	indicePhotoCourante=0;
	definiAffichageContaineurPhoto("block");
	attenteChargementeDesPhotos();
}


function attenteChargementeDesPhotos(){
var bContinuer,eltpht;
var bCharge;
var i,iNbPhChg=0;

bContinuer=true;
for(var i=0;i<ListePhotos.length;i++){

	eltpht=ListePhotos[i];
	bCharge=eltpht.complete;
	
	if(bCharge){
		iNbPhChg++;
	}
	bContinuer=bContinuer&&bCharge;
}
var pctChg=Math.round(iNbPhChg/ListePhotos.length*100);

var eltprog=document.getElementById("zonephotoprogress");
if(eltprog){
	eltprog.style.display="block";
	eltprog.innerHTML=pctChg+" %";
}
if(bContinuer){
	if(eltprog){
		eltprog.style.display="none";
	}
	affichePhotoCourante();
}
else{
	setTimeout("attenteChargementeDesPhotos()",100);
}

}

function chargeEnsembleAnimation(documentCourant,nomTag){
	ListePhotos=new Array();
	var lesPhotos=documentCourant.getElementsByName(nomTag);
	for(var i=0;i<lesPhotos.length;i++){
		ListePhotos[i]=lesPhotos[i].innerHTML;
		ListePhotos[i]=ListePhotos[i].replace("\n","");
	}
	typeDocument="animation";
	initialiseZoneAffichage();
	indicePhotoCourante=0;
	definiAffichageContaineurPhoto("block");
	//new Effect.Appear('zonephoto', { duration: overlayDuration, from: 0.0, to: 0.8 });
	affichePhotoCourante();
}


function definiAffichageContaineurPhoto(affiche){
var cont=document.getElementById("zonephoto");
if(cont){
	cont.style.display=affiche;
}
}

function afficheImagePrecedente(){
	indicePhotoCourante--;
	if(indicePhotoCourante<0){
		indicePhotoCourante=ListePhotos.length-1;
	}
	affichePhotoCourante();
}

function afficheImageSuivante(){
	indicePhotoCourante++;
	if(indicePhotoCourante>=ListePhotos.length){
		indicePhotoCourante=0;
	}
	affichePhotoCourante();
}

function fermeContaineurPhoto(){
	definiAffichageContaineurPhoto("none");
	var img=document.getElementById("imgzonephoto");
	if(img){
		img.style.width="47px";
		img.style.height="31px";
		img.src="image/attente.gif";
	}
}

function affichePhotoCourante(){

switch(typeDocument){

case "animation":
	ie=(navigator.appName.indexOf ("Microsoft") !=-1);
	if(ie){
		var player=document.getElementById("docanim");
		if(player){
			player.src=ListePhotos[indicePhotoCourante];
			player.MOVIE=ListePhotos[indicePhotoCourante];
			player.Play();
		}
	}
	else{
		var player=document.getElementsByName("docanim");
		if(player.length>0){
			player[0].src=ListePhotos[indicePhotoCourante];
			
		}
	}
break;
case "image":
	var img=document.getElementById("imgzonephoto");
	var lgligtab=document.getElementById("contphoto");
	if((img)&&(lgligtab)){
		var posElt=retournePosTailleElement(lgligtab);
		var hImag=parseInt(posElt.Hauteur);
		var lImag=parseInt(posElt.Largeur);
		
		var lIm=ListePhotos[indicePhotoCourante].width;
		var hIm=ListePhotos[indicePhotoCourante].height;
		if(lIm>lImag){
			hIm=Math.round(lImag/lIm*hIm);
			lIm=lImag;
		}
		if(hIm>hImag){
			lIm=Math.round(hImag/hIm*lIm);
			hIm=hImag;
		}
		
		var pos=Math.round((hImag-hIm)/2);
		img.style.top=pos+"px";
		pos=Math.round((lImag-lIm)/2);
		img.style.left=pos+"px";
		
		//img.src=ListePhotos[indicePhotoCourante].src;
		img.style.width=lIm+"px";
		img.style.height=hIm+"px";
		ImageCopieEcran.definiPhoto(ListePhotos[indicePhotoCourante].src);
	}
	break;
}
var lbl=document.getElementById("labelnumPHOTO");
if(lbl){
	var iNum=indicePhotoCourante+1;
	lbl.innerHTML=iNum+ "/" + ListePhotos.length;
}
}


function initialiseZoneAffichage(){
	var elt=document.getElementById("imgzonephoto");
	if(elt){
		elt.innerHTML="";
		switch(typeDocument){
		case "animation":
			elt.style.top="0px";
			elt.style.left="0px";
			elt.style.width="100%";
			elt.style.height="90%";
			var sTexte="";
			sTexte=sTexte+"<object id=\"docanim\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"100%\" height=\"100%\">";
			sTexte=sTexte+"<param name=\"MOVIE\" value=\"\">";
			sTexte=sTexte+"<param name=\"PLAY\" value=\"true\">";
			sTexte=sTexte+"<param name=\"LOOP\" value=\"true\">";
			sTexte=sTexte+"<param name=\"quality\" value=\"high\">";
			sTexte=sTexte+"<embed src=\"\" width=\"100%\" height=\"100%\" play=\"true\"  loop=\"true\" quality=\"high\" TYPE=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"  name=\"docanim\" swLiveConnect=\"true\">";
			sTexte=sTexte+"</embed>";
			sTexte=sTexte+"<noembed>le navigateur ne permet pas l'affichage</noembed>";
			sTexte=sTexte+"</object>";
			elt.innerHTML=sTexte;
		

			break;
		case "image":

			ImageCopieEcran=new ClassePhotoZoomBox("ImageCopieEcran",document,"imgzonephoto","boitezoomphoto");
			ImageCopieEcran.setRatioMiniZoom(2);
		break;
		
		}
	/*if(elt){
		var ie=(navigator.appName=='Microsoft Internet Explorer');
		var texte="";
		if(ie){
			texte=texte+"<v:image id=\"imgzonephoto\"  class=\"imgzonephoto\"  src=\"image/attente.gif\" width=\"47px\" height=\"31px\"  onclick=\"fermeContaineurPhoto()\" ></v:image>";
		}
		else{
			texte=texte+"<img id=\"imgzonephoto\" class=\"imgzonephoto\" src=\"image/attente.gif\" width=\"47px\" height=\"31px\"   onclick=\"fermeContaineurPhoto()\"  />";
		
		}
		elt.innerHTML=texte;
	}
*/
	}
}



