
function afficheDiaporama(qsForVisu,numPhoto,maxLarg,maxHaut){
	if (getVersionIE()<7)return false;
	if (!numPhoto)numPhoto=0;
	if(getVersionIE()<9){
		var w=parseInt(document.documentElement.clientWidth)*0.9;
		var h=parseInt(document.documentElement.clientHeight)*0.9;
	}else{
		var w=parseInt(window.innerWidth)*0.9;
		var h=parseInt(window.innerHeight)*0.9;
	}
	if (!w)w=800;
	if (!h)h=600;		
	afficheDivAvecTransparence("<div id=divPhotoBtFermer style='position:absolute;left:-10px;top:-10px;cursor:pointer;' onclick=effaceDivAvecTransparence('_visuPhoto');><img src=/config_v3/imgs_defaut/btFermer.png style='width:20px'></div><iframe src='/appPhoto/visuPhoto.php?"+qsForVisu+"&idPhoto="+numPhoto+"' scrolling='no' width=100% height=100% frameborder=0></iframe>",w,h,"_visuPhoto");
}

function afficheDiaporama1Image(srcImage){
	//if (getVersionIE()<7)return false;
	
	var w=parseInt(window.innerWidth)*0.9;
	var h=parseInt(window.innerHeight)*0.9;
	if (!w)w=800;
	if (!h)h=600;
		
	afficheDivAvecTransparence("<div id=divPhotoBtFermer style='position:absolute;left:-10px;top:-10px;cursor:pointer;' onclick=effaceDivAvecTransparence();><img src=/config_v3/imgs_defaut/btFermer.png style='width:20px'></div><img style='margin:auto;' src='"+srcImage+"' />",w,h);
}



function initAlbumPhoto(qsForVisu){
	var tabObj=new Array();
	var photoPrinc=document.getElementById("img_fiche_photoPrincipale");
	var fenetre=0;
	var largTotal=0;xFinTotal=0;
	var maxLarg=0;
	var maxHaut=0;
	
	var nomPhotoRef="img_fiche_photoAlbum1";
	var nomPhotoRefFngf="img_fiche_photoAlbumFngf1";
	
	var legendePhoto = document.getElementById("fiche_legendePhotos");

	//jslog(qsForVisu);
	if (!qsForVisu)qsForVisu="";
	
	if (!document.getElementById(nomPhotoRef) && document.getElementById(nomPhotoRefFngf))var fngf=true;
	else fngf=false;
	
	for (var i=1;i<=20;i++){
		if (fngf)var objPhoto=document.getElementById("img_fiche_photoAlbumFngf"+i);
		else var objPhoto=document.getElementById("img_fiche_photoAlbum"+i);
		if (objPhoto){
			tabObj.push($(objPhoto));
			/*if (objPhoto.width>maxLarg)maxLarg=objPhoto.naturalWidth;
			if (objPhoto.height>maxHaut)maxHaut=objPhoto.naturalHeight;	*/
			if (getLargeurReelleImage(objPhoto)>maxLarg)maxLarg=getLargeurReelleImage(objPhoto);
			if (getHauteurReelleImage(objPhoto)>maxHaut)maxHaut=getHauteurReelleImage(objPhoto);
			//jslog("max_w:"+maxLarg+" max_h"+maxHaut);
		}	
	}
	for (var i=0;i<tabObj.length;i++){
		new Effect.Opacity(tabObj[i], { from: 1, to: 0.9 });
		tabObj[i].onmouseover=function(evt){
			if (photoPrinc)photoPrinc.src2=photoPrinc.src;
			if (photoPrinc && this.src)photoPrinc.src=this.src;
			if($("fiche_legendePhotos")){
				$("fiche_legendePhotos").innerHTML2=legendePhoto.innerHTML;
				$("fiche_legendePhotos").innerHTML=this.getAttribute("txt");
			}
			new Effect.Opacity(this, { from: 0.9, to: 1 });
			
		}
		tabObj[i].onmouseout=function(evt){
			new Effect.Opacity(this, { from: 1, to: 0.9 });
			if (photoPrinc && photoPrinc.src2)photoPrinc.src=photoPrinc.src2;
			if ($("fiche_legendePhotos")) $("fiche_legendePhotos").innerHTML=legendePhoto.innerHTML2;
		}
		
		tabObj[i].num=i;
		if (!fngf){
			tabObj[i].onclick=function(evt){
				afficheDiaporama(qsForVisu,this.num,maxLarg,maxHaut);
			}	
		}	
		var larg=parseInt(tabObj[i].offsetWidth);
		if (larg>fenetre)fenetre=larg;
		largTotal+=larg;
		
		if (tabObj[i] && tabObj[i].offsetLeft){
			var xFin=(parseInt(tabObj[i].offsetLeft)+larg);
			if (xFinTotal<xFin)xFinTotal=xFin;
			
		}		
		if (xFinTotal<largTotal)xFinTotal=largTotal;
	}
	
	var divPrinc=$(document.getElementById("div_fiche_album"));
	if (!divPrinc)return;	

	var btPrec=$(document.getElementById("spanFiche_album_prev"));
	var btSuiv=$(document.getElementById("spanFiche_album_next"));
	var ulPrinc=$(document.getElementById("lst_fiche_photos_suppl"));
	
	btSuiv.style.visibility="hidden";
	btPrec.style.visibility="hidden";

	//alert(xFinTotal+">"+parseInt(divPrinc.offsetWidth));
	if (xFinTotal>parseInt(divPrinc.offsetWidth)){
		btSuiv.style.visibility="visible";
	}

	
	ulPrinc.style.position="absolute";
	var pas=fenetre*2;
		
	btSuiv.onmousedown=function(){
		$(document.getElementById("spanFiche_album_prev")).style.visibility="visible";
		var decal=pas*-1;
		var xFinPrinc=parseInt(ulPrinc.offsetLeft)+parseInt(divPrinc.offsetLeft)+xFinTotal;
		var xFinVisu=parseInt(divPrinc.offsetLeft)+parseInt(divPrinc.offsetWidth);
		
		var xFinApresPrinc=xFinPrinc+decal-50;
		
		if (xFinApresPrinc<xFinVisu){
			decal=((xFinPrinc-xFinVisu)*-1);
			this.style.visibility="hidden";
		}
		new Effect.Move(ulPrinc, { x: decal, mode: 'relative' });
	}
	btPrec.onmousedown=function(){
		$(document.getElementById("spanFiche_album_next")).style.visibility="visible";
		var decal=pas+50;
		var xDebPrinc=parseInt(ulPrinc.offsetLeft);
		var xDebApresPrinc=xDebPrinc+decal;
		if (xDebApresPrinc>0){
			decal=xDebPrinc*-1;
			this.style.visibility="hidden";
		}
		new Effect.Move(ulPrinc, { x: decal, mode: 'relative' });
	}
	
}

function affLegendeEtAlbum(idPhoto,txt){
	$('img_fiche_photoPrincipale').src2=$('img_fiche_photoPrincipale').src;
	if ($(idPhoto).src)$('img_fiche_photoPrincipale').src=$(idPhoto).src;
	if($('fiche_legendePhotos')){
		$('fiche_legendePhotos').innerHTML2=$('fiche_legendePhotos').innerHTML;
		$('fiche_legendePhotos').innerHTML=txt;
	}
}

function effaceLegendeEtAlbum(){
	if ($('img_fiche_photoPrincipale').src2)$('img_fiche_photoPrincipale').src=$('img_fiche_photoPrincipale').src2;
	if($('fiche_legendePhotos')) $('fiche_legendePhotos').innerHTML=$('fiche_legendePhotos').innerHTML2;
}
	