// JavaScript Document
// OBJ

function getOb(ob) { return (document.all)?eval('document.all.'+ob):(document.getElementById)?eval('document.getElementById("'+ob+'")'):null }
function getHt(ob) { return ob.offsetHeight }
function getLg(ob) { return ob.offsetWidth }
function show(ob) { ob.style.visibility = "visible" }
function hide(ob) { ob.style.visibility = "hidden" }
function display_show(ob) {getOb(ob).style.display = "block" }
function display_hide(ob) {getOb(ob).style.display = "none" }
function enx(ob,px) { if (document.all) {getOb(ob).style.pixelLeft = px;}else {getOb(ob).style.left = px+'px'} }
function eny(ob,px) {if (document.all) {getOb(ob).style.pixelTop = px} else {getOb(ob).style.top = px+'px'; } }
function getx(ob) { return (document.all)?getOb(ob).style.pixelLeft:parseInt(getOb(ob).style.left) }
function gety(ob) { return (document.all)?getOb(ob).style.pixelTop:parseInt(getOb(ob).style.top) }
function getHt(ob){return getOb(ob).offsetHeight}
function getLg(ob){return getOb(ob).offsetWidth}
function laht(ob,px) { ob.style.height = px }
function lalg(ob,px) { ob.style.width = px }
function clp(ob,htm,lgd,htp,lgg) { ob.style.clip = eval("'rect("+htm+"px, "+lgd+"px, "+htp+"px, "+lgg+"px)'");}
function prop(binf,ind,bsup,min,max) { return parseInt((ind*(max-min)/(bsup-binf))+min) }
function inner(idob,contenu){getOb(idob).innerHTML=contenu;}
// IMG
function swimg(im, sc) { eval( 'document.'+im+'.src = "'+sc+'"' ) }
function iht(im,px) { eval('document.'+im+'.style.height = '+px) }
function ilg(im,px) { eval('document.'+im+'.style.width = '+px) }

/*---------- Pop up photo -----------*/
function img_zoom(ph,w,h,titre)
{
	var hauteurFenetre = h;
 	var largeurFenetre = w;
	var barre_des_taches = 18;
	if (h>screen.height)
	{
		top=0;
		hauteurFenetre = screen.height;

		if (navigator.appName == "Microsoft Internet Explorer" )
		{
			hauteurFenetre -= 36;
		}
		if (navigator.appName != "Microsoft Internet Explorer" )
		{
			largeurFenetre += 29;
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer" )
	{
		largeurFenetre += 19;
	}
	var top = (screen.height - hauteurFenetre)/2;
	var left = (screen.width - largeurFenetre)/2;
	if (navigator.appName == "Microsoft Internet Explorer" )
	{
		top -= barre_des_taches;
		left -= 5;
	}
 	fenetre_zoom=window.open('','zoom','height='+hauteurFenetre+'px,width='+largeurFenetre+'px,left='+left+'px,top='+top+'px,toolbar=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes')
	fenetre_zoom.document.open();
	fenetre_zoom.document.writeln('<html><head>');
	fenetre_zoom.document.writeln('<title>zoom - '+titre+'</title>');
	fenetre_zoom.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">');
	fenetre_zoom.document.writeln('<style>*{margin:0;padding:0;}img {border:none;}</style>');
	fenetre_zoom.document.writeln('</head><body>');
	fenetre_zoom.document.writeln('<div><img onclick="window.close()" src="../img/'+ph+'"/></div>');
	fenetre_zoom.document.writeln('</body></html>');
	fenetre_zoom.document.close();
	fenetre_zoom.focus();
	
}
/*---------- /Popup photo -----------*/

/*----- impression ---------------------------*/
function impression(id)
{
	var height = screen.height-(screen.height*20/100);
 	var width = 540;
	var top = (screen.height - height-50)/2;
	var left = (screen.width - width)/2;
 	fenetre_print=window.open('impression.htm?id='+id,'print','height='+height+'px,width='+width+'px,left='+left+'px,top='+top+'px,toolbar=no,directories=0,status=0,menubar=0,scrollbars=1,resize=0,resizable=0')
	fenetre_print.focus();
 	//fenetre_print=window.open('print.htm','print','toolbar=no,directories=0,status=0,menubar=0,scrollbars=1,resize=1,resizable=1')
}
/*----- /impression ---------------------------*/
/*--------------------------- recuperation parametre --------------------------------------*/
function parametre(nom_parametre,url)
{
	var valeur;
	var param_avec_valeur
	if(url.indexOf('?')!=-1)
	{
		var les_parametres = url.substring(url.indexOf('?')+1,url.length);
		var pos_nom_param = les_parametres.indexOf(nom_parametre+'=');
		
		if(pos_nom_param!=-1)
		{
			//un seul parametre
			if(pos_nom_param==1&&les_parametres.indexOf('&')!=-1)
			{
				param_avec_valeur=les_parametres.substring(pos_nom_param,les_parametres.length);
			}
			else
			// plusieurs parametres
			{
				les_parametres = les_parametres.substring(pos_nom_param,les_parametres.length);
				pos_nom_param = les_parametres.indexOf(nom_parametre);
				
				if(les_parametres.indexOf('&')!=-1)
				{
					
					param_avec_valeur = les_parametres.substring(pos_nom_param,les_parametres.indexOf('&'));
				}
				else
				//c'est le dernier parametre
				{
					param_avec_valeur = les_parametres;
				}
			}
			valeur = param_avec_valeur.substring(param_avec_valeur.indexOf('=')+1,param_avec_valeur.length);
		}
		else
		{valeur=''}
	}
	else
	{valeur=''}
	
	return valeur;
}
/*--------------------------- recuperation parametre --------------------------------------*/
/*--------------------------- menu vertical ----------------------------------------------*/
function ouvrir_niveau(niveau)
{
	var conteneur_lien = niveau.parentNode;
	if (conteneur_lien.className=='')
	{
	conteneur_lien.className='current';
	}
	else
	{
		conteneur_lien.className='';
	}
}
/*--------------------------- /menu vertical ----------------------------------------------*/
/*-------- implantation ------------------*/
// permet d'ouvrir la pop_up implantation()
function ouvrir_implantation(url)
{
	var hauteurFenetre = 600;
	var largeurFenetre = 522;
	var top = (screen.height-hauteurFenetre)/2;
	//titre fenetre
	hauteurFenetre -= 36;
	var left = (screen.width-largeurFenetre)/2;
	var nouvelleFenetre=open(url,"popup_implantation","width="+largeurFenetre+"px,height="+hauteurFenetre+"px,top="+top+"px,left="+left+"px,menubar=no,resizable=no,scrollbars=no");
	nouvelleFenetre.focus();
}
/*-------- implantation ------------------*/
/*-------- phototheque ------------------*/
/*panoramic*/
largeur_panoramic = null;
defilement_pano = false;
nb_pixel_defil = 5;

function init_panoramic()
{
	largeur_panoramic =  getLg('contenu_panoramic')
	if (largeur_panoramic < getLg('panoramic'))
	{
		getOb('precedent').style.visibility='hidden';
		getOb('suivant').style.visibility='hidden';
	}
	
}

function defilement(sens)
{
	defilement_pano = true;
	if(sens=='r')
	{
		pano_r()
	}
	if(sens=='l')
	{
		pano_l()
	}
}

function arret_defilement()
{
	defilement_pano = false;
}

function pano_r()
{
	if (defilement_pano)
	{
		if (getx('contenu_panoramic')>=-(largeur_panoramic-getLg('panoramic')))
			enx('contenu_panoramic',getx('contenu_panoramic')- nb_pixel_defil);
	
		if (getx('contenu_panoramic')<-(largeur_panoramic-getLg('panoramic')))
			return;
		setTimeout('pano_r()', 1);
	}
}

function pano_l()
{
	if (defilement_pano)
	{
		if (getx('contenu_panoramic')<0)
			enx('contenu_panoramic',getx('contenu_panoramic')+ nb_pixel_defil);
	
		if (getx('contenu_panoramic')>(largeur_panoramic-getLg('panoramic')))
			return;
		setTimeout('pano_l()', 1);
	}
}
/* /panoramic*/
// permet d'ouvrir la pop up avec l'image en taille réel
function open_img_phototheque(id,l_image,h_image)
{
	var left = (screen.width-h_image)/2;
	var top = (screen.height-h_image)/2;
	var popup = window.open("pg_popup.php?id="+id,"MiniSite","height="+l_image+"px,width="+h_image+"px,left="+left+"px,top="+top+"px,resizable=0,menubar=0,scrollbars=0");
	popup.focus();
}
/*-------- /phototheque ------------------*/
/*----- /formulaire newsletter ---------------------------*/
var ajout_fonction_onload=null;
//Lance differentes fonctions sur le onload
function checkparamonload()
{	
	/* a enlever */
	/*if(getOb("container").offsetWidth>1000)
	{
		alert('Le site éclate en largeur.')
	}*/
	if(ajout_fonction_onload!=null)
	{
		for(var i=0;i<ajout_fonction_onload.length;i++)
		{
			eval(ajout_fonction_onload[i])
		}
		
	}
}
//window.onload=checkparamonload;
