/* Loïc Pennamen pour Magnana.com */

///////////
var newWin = null;
function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
		newWin.close();
	}
}

///////////
function popUp(strURL,strType,strHeight,strWidth) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
} 

///////////
function changerImage(idImage, srcImage){
	idImage.src=srcImage;
}

///////////
function suppTimer(timerImages){
	window.clearTimeout(timerImages);
}

///////////
function passerNoir(lien, nombreImages){
	//alert(nombreImages);
	for(i=1;i<=nombreImages;i++){
		if(i!=lien){
			document.getElementById(i).style.backgroundColor="#FFFFFF";
			document.getElementById(i).style.color="#8c8c8c";
		}
		else{
			document.getElementById(i).style.backgroundColor="#000000";
			document.getElementById(i).style.color="#FFFFFF";
		}
	}
}

///////////
// afficher/masquer une div
function toggler(madiv){
	maDivObjet=document.getElementById(madiv);
	//maDivObjet.style.display='block';
	if((maDivObjet.style.display=="none") || (maDivObjet.style.display=="")){
		maDivObjet.style.display="block";
	}
	else{
		maDivObjet.style.display="none";
	}
}

///////////
function legendeIn(){
	// Recuperation du numero
	nomPhoto=document.getElementById('grandeImage').src;
	nomPhoto=nomPhoto.split('/');		// division du chemin en tableau
	nomPhoto=nomPhoto.pop();			// recup de la derniere entree  mon_nom.jpg
	nomPhoto=nomPhoto.split('.');		// division du chemin en tableau
	nomPhoto=nomPhoto.shift();			// recup de la derniere entree  mon_nom
	
	for(k=1;k<=nombreImage;k++){
		if(nomPhoto==k){
			blocLegende=document.getElementById('blocLegende'+k);
			if(blocLegende){
				blocLegende.style.display='block';
				blocLegende.style.height='1px';
				derouler(blocLegende);
			}
		}
	}
}

///////////
function legendeOut(){
	for(k=1;k<=nombreImage;k++){
		blocLegende=document.getElementById('blocLegende'+k);
		if(blocLegende){
			if(blocLegende.style.display=='block'){
				enrouler(blocLegende);
			}
		}
	}
}

function derouler(blocLegende){
	if(blocLegende.offsetHeight<50){
		//alert(blocLegende.offsetHeight+100+'px');
		blocLegende.style.height = blocLegende.offsetHeight+2+'px';
		deroulement=setTimeout("derouler(blocLegende)", 10);
	}
	else{
		window.clearTimeout(deroulement);
	}
}
function enrouler(blocLegende){
	//alert(blocLegende.offsetHeight);
	if(blocLegende.offsetHeight>1){
		blocLegende.style.height = (blocLegende.offsetHeight-2)+'px';
		
		leMemeBloc=blocLegende;
		enroulement=setTimeout("enrouler(leMemeBloc)", 10);
	}
	else{
		leMemeBloc.style.display='none';
		window.clearTimeout(enroulement);
	}
}
// Page d'accueil : switcher les blocks des dernieres realisations
// Premier parametre : div a afficher, second parametre, nombre total de divs
function alterner(maDiv, total){
	for(i=1;i<=total;i++){
		ladiv = 'ref'+i;
		// si la div a afficher n'est pas celle cliquée : on la masque
		if(i!=maDiv){
			document.getElementById(ladiv).style.display='none';
		}
		else{
			document.getElementById(ladiv).style.display='block';
		}
	}		
}























