//------------------------------------------------------------------------------
//---------------------------------- prechargement d'images --------------------
//------------------------------------------------------------------------------
function load() {
	if (document.images) {
		this.length=load.arguments.length;
		for (var i=0;i<this.length;i++) {
			this[i+1]=new Image();
			this[i+1].src=load.arguments[i];
		}
	}
}
//---------------------------------------------------------------------------
//---------------------------------- gestion des calques --------------------
//----------------------------------------------------------------------------
var timeout=new Array();
var delai = 500; // pour cache automatique des calque (
function getElement(id) {
if (document.getElementById) return document.getElementById(id);
else if (document.all) return document.all[id];
else if (document.layers) return document.layers[id];
return false;
}
function colorMe(id,color) { getElement(id).style.color=color;}
function showMe(id) { getElement(id).style.display="block";}
function hideMe(id) {  getElement(id).style.display="none"; }
function changeMe(id) {getElement(id).style.display=(getElement(id).style.display=="block")?"none":"block"; }
function moveDiv(id,x,y)
{       
	if (y) getElement(id).style.top=y;
	if (x) getElement(id).style.left=x;
}
function afficherDiv(id)
{
	if (timeout[id]) clearTimeout(timeout[id]);
	getElement(id).style.visibility= 'visible';       
}
function cacherDiv(id)
{       
	getElement(id).style.visibility='hidden';
}
function cacherDelai(id) 
{
	 var cmd="cacherDiv('" + id + "')";
	 timeout[id] = setTimeout(cmd,delai);
}
//---------------------------------------------------------------------------
//---------------------------------- barre de progression -------------------
//---------------------------------------------------------------------------
function addZero(chiffre){ // Function qui ajoute un zero devant les chiffres
	if (chiffre < 10) { chiffre = "0"+chiffre; }
	if (chiffre < 100) { chiffre = "0"+chiffre; }
	return chiffre; 
}
//---------------------------------------------------------------------------
//---------------------------------- popup et lien java ---------------------
//---------------------------------------------------------------------------
// rootLaBoutique .... variable js global
function popup(page,h,w) {
	var param='scrollbars,resizable,width=' + w + ',height=' + h + ',toolbar=false';
	newWindow=window.open(page,"",param);
	newWindow.focus();
}
function centrerWindow(page,target,h,w) {
  	var Left=screen.width/2-w/2;
  	var Top=screen.height/2-h/2;
	var prop= 'width=' + w + ', height=' + h + ',scrollbars,status=yes,resizable,left=' + Left + ',top=' + Top;
	var fenetre=window.open(page,target,prop);
	return fenetre.focus();
	}
function windowcenter(page,taille) {//pour lien quelconque
	return centrerWindow(page,'_blank',taille-200,taille);
	}
function popupcenter(key,taille) { // boutique/pagePopup
	var page= rootLeWeb + 'pagePopup.php?nom=' + key;
	return centrerWindow(page,'_blank',taille-200,taille);
    	}
//---------------------------------------------------------------------------
//---------------------------------- form page pro ---------------------
//---------------------------------------------------------------------------
function testPwd(formulaire)
{
var nom =getElement('nomProfessionnel').value ;
var pwd =getElement('pwdProfessionnel').value ;
if(pwd =="rataton")
	{
	   var page=rootLesPros+'page.php?nom=professionnel&ident=' + nom;
	   window.open(page);
	}
else
	{alert('vous ne pouvez pas acceder aux pages professionnels avec ce pwd.');};
}
//---------------------------------------------------------------------------
//---------------------------------- popup ----------------------------------
//---------------------------------------------------------------------------
function popupNotice(page) {
	noticeWindow=window.open(page,'fenetreNotice','width=500,height=800,toolbar=false,scrollbars,resizable');
	noticeWindow.focus();
	}
function popupHR(image) {
	popup(image,'600','600');
	}
//---------------------------------------------------------------------------
//---------------------------------- telechargement produit -----------------
//---------------------------------------------------------------------------
function teleChargementProduit(page) {
	telechargementWindow=window.open(page,'fenetreTelechargement','width=400,height=200,toolbar=false,scrollbars,resizable');
	telechargementWindow.focus();
}
//-----------------------------------------------------
//  outils pour tous les cookies
//-------------------------------------------------------
function isCookie(nomCookie) { if (getCookie(nomCookie)) return true;  else return false; }
function getCookie(nomCookie)
{
  	var valeur="";
	if (document.cookie.length > 0)
	{
  		var texte=nomCookie + "=";
  		var table=document.cookie.split(/;/);
  		for (i=0;i<table.length;i++)
		{
    		if (table[i].indexOf(texte)!= -1) valeur = table[i].substring(Number(texte.length + table[i].indexOf( texte)), table[i].length);
  		}
	}
	return unescape(valeur);
}
function setCookie(nomCookie,txt) {
	var argv=setCookie.arguments;
	var argc=setCookie.arguments.length;
	var expiration=(argc > 2) ? argv[2] : null;
	var str =nomCookie + "=" + txt;
	str +=(expiration==null) ? "" : ("; expires="+expiration.toGMTString());
	str += "; " + "path=/";
	document.cookie = str;
	}
function getTabDansCookie(nom) {
	//les éléments sont des séparé par des &
	var txt=getCookie(nom);
	var tab=txt.split('&');
	return tab;
	}
function setTabDansCookie(nom,tab) {
	//les éléments sont séparé par des &
	var argv=setTabDansCookie.arguments;
	var argc=setTabDansCookie.arguments.length;
	var expiration=(argc > 2) ? argv[2] : null;
	
	var txt=tab.join('&');
	if (expiration==null) 	setCookie(nom,txt);
	else 			setCookie(nom,txt,expiration);
}
//---------------------------------------------------------------------------
//---------------------------------- dimentions de la fenetre ---------------
//---------------------------------------------------------------------------
function dimPage() {
  	/*
    this.larg=screen.width;
  	this.haut=screen.height;
	*/
  	if(window.innerWidth) { //firefox
    	this.larg = window.innerWidth;
    	//this.haut = window.innerHeight;
    	this.haut = document.height;
 		}
		/*
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  		this.larg = document.documentElement.clientWidth;
  		this.haut = document.documentElement.clientHeight;
   		//this.haut = document.documentElement.height;
 		}
		*/
 	else if(document.body.clientWidth) { //IE
   		this.larg = document.body.clientWidth;
   		this.haut = document.body.clientHeight;
   		//this.haut = document.body.height;
 		}
 	else if(document.body.offsetWidth) {
   		this.larg = document.body.offsetWidth - 20;
   		//this.haut = document.body.offsetHeight - 4;
 		//this.haut = 1200;
	}
	if (!this.haut) this.haut=1200;  //opera
 	return this;
}
function positionnerAuMilieu(id,width,height) {
	var fenetre=dimPage();
  	var Left=fenetre.larg/2-width/2;
  	//var Top=fenetre.haut/2-height/2;
	getElement(id).style.left=Left;
	//getElement(id).style.top=150;
}
function positionnerAuMilieuDroite(id,width,height) {
	var fenetre=dimPage();
  	var Left=fenetre.larg/2+width/2;
  	//var Top=fenetre.haut/2-height/2;
	getElement(id).style.left=Left-80;
	//getElement(id).style.top=150;
}
function afficheCache() {
	var fenetre=dimPage();
  	var Width=fenetre.larg;
  	var Height=fenetre.haut;
	//alert('height='+Height+' width='+Width);
	getElement('cache').style.height=Height;
	getElement('cache').style.width=Width;
	getElement('cache').style.top=0;
	getElement('cache').style.left=0;
	getElement('cache').style.display="block";
}	