// phillayer v2.1  menu deroulant à 1 niveau
// olive ;o)06/2001
// NB ce menu s'applique spécifiquement à 5 rubriques et 4 éléments (tete corps moteur bottom)

var imgOn;
var imgnamecli="";
var imgnamenoncli="";

// TABLE des layers MENU TETE
//il est possible d'inclure une image pour chaque Entete en l'incluant dans le code
Tableaumenutete =new Array()
Tableaumenutete[0]="Entete1"
Tableaumenutete[1]="Entete2"
Tableaumenutete[2]="Entete3"
Tableaumenutete[3]="Entete4"
Tableaumenutete[4]="Entete5"
Tableaumenutete[5]="Entete6"
Tableaumenutete[6]="Entete7"
Tableaumenutete[7]="Entete8"
tabmen= new Array()
tabmen[0]="lmentop";
tabmen[1]="lmencor";
tabmen[2]="lsearch";
tabmen[3]="lmenbott";

// nombre de tete de menu defini le nombre de block d'item 
//est liée à la variable nbTetemenu
nbTetemenu=Tableaumenutete.length=5         //nb d'en-tete
var couleurmenuTete="white";
var sizemenuTete=20;       // taille de la police contenue ds l'en tete
var espaceh=10;            // espace optionnel
var eswidth=145;
var esheight=17;   // hauteur totale de l'en-tête de menu 
originTop0=originTop=100;
originLeft0=originLeft=100;     // initialisation de l'origine du layer position gauche et droite
hlmentop=19;                    // hauteur du layer de fond --> top
hlmenbottom=25;                // hauteur du layer de fond --> bottom
hlsearch=75;                    // hauteur du layer de fond --> moteur de recherche   40
hlmencor=250;                 // hauteur du layer de fond --> corps   260 
originTop0=originTop=originTop0+hlmentop  //positionnement du top 
compteur=Tableaumenutete.length;
var couleurmenuItem="white";     // couleur par défaut de la police utilisée pour les items
var sizemenuItem=11;             // taille de la police des items
var espaceh2=10;                 // espace optionnel n°2
sizemenuItem=sizemenuItem+espaceh2   // taille totale du menu item
var largpicto="20";                  // espace prévu pour permettre une marge ds laquelle viendra s'insérer une img
eswidth=eswidth-largpicto;           // largeur effective laissée pour le texte
postop=0;                             // initialisation de différentes variables   
posleft=0;
point_item=0;
nbblock=nbTetemenu
numblock=0;
decalheight=0;
pxs="";
finblock=0;
finblock0=0;
numeroblock=0;
numeroblockpreced=-1;
blockitem=0;
numeroblocksuiv=0;   
testredim=0;

//variable de navigation pour mozilla
etatblock=-1

//*************************************************************************
//fonction navigat
function navigat(){
if (navigator.appVersion.charAt(0) == "5") {
  if (navigator.appName == "Netscape") {
      isNav6 = true
      navnom="n6";
  } 
}
else {
navi=navigator.appName;
vers=parseFloat(navigator.appVersion);
if(navi=="Netscape"&&vers>3){navnom="n4";}
	if(navi=="Microsoft Internet Explorer"&&vers>3){navnom="ie4";}      
    }
}//fin de navigat


function recadre(){
// on cherche ici les coordonnées d' imgcal pour effectuer un recadrage dynamique
// le recadrage depend du navigateur il faut donc faire un browser check
   if (navnom=="ie4"){ 
     ximg=parseInt(document.images["imgcal"].offsetLeft);
     yimg=parseInt(document.images["imgcal"].offsetTop);
     xx=ximg-380;    //on introduit un correctif pour caler l'image
     yy=yimg+82;
       if (ximg<380){  xx=0;}     // si la fenêtre utilisateur est < a la 1/2 largeur du tableau on aligne le menu à gauche
   }   

   else {
      if (navnom=="n6"){
        ximg=parseInt(document.images["imgcal"].offsetLeft);
        yimg=parseInt(document.images["imgcal"].offsetTop);
        xx=ximg-380;    //on introduit un correctif pour caler l'image
        yy=yimg+82;
          if (ximg<380){  xx=0;}
      }
      if (navnom=="n4"){
  
        ximg=parseInt(document.images["imgcal"].x);
        yimg=parseInt(document.images["imgcal"].y);
        xx=ximg-379;
        yy=yimg+82;
          if (ximg<380){ xx=0;}
      }
   }

}
// ***************************************************************************
// initlayer construit l'adressage des layers selon les differents navigateurs
function initlayer(){
 recadre();
switch (navnom){
//si Internet Explorer
case"ie4":
pxs="px";
docu="document.all.";
modele=".style"
visib=".visibility"
etatvisible="visible";
etatcache="hidden";
break;
case"n4":
pxs="";
docu="document.layers."
modele=""
visib=".visibility"
etatvisible="show";
etatcache="hide";
break;
// le cas netscape6 est un traitement different des autres
case "n6":
//alert('La version de votre navigateur n\'est pas actuellement supportée. Merci de vous reporter à la page Aide du site.')
break;
    }//fin du switch


	originTop0=yy+15 //test pour passer les coordonnées de l'image
	originLeft0=xx
	init_allblock();     // on appel init all blocks pour effectuer le bon positionnement
  }//fin de la fonction  
//****************************************************************************
//**********************INITIALISE TOUT LES BLOCKS ET BLOCKITEMS****************************
function init_allblock(){
compteur=nbTetemenu;
if(navnom=="n6"){

	//positionnement des layers de base

	lnom="lmentop";
	obj=document.getElementById(lnom);
	obj.style.left=parseInt(xx);
	obj.style.top=parseInt(yy-5);
	obj.style.visibility="visible";


	lnom="lmencor"
	obj1=document.getElementById(lnom);
	obj1.style.left=parseInt(xx);
	obj1.style.top=parseInt(yy-5)+parseInt(obj.style.height);
	obj1.style.visibility="visible";


	lnom="lsearch"
	obj2=document.getElementById(lnom);
	obj2.style.left=parseInt(xx);
	obj2.style.height=parseInt(obj2.style.height)+parseInt(8);
	obj2.style.top=parseInt(obj1.style.top)+parseInt(obj1.style.height);
	obj2.style.visibility="visible";

	lnom="lmenbott"
	obj3=document.getElementById(lnom);
	obj3.style.left=parseInt(xx);
	obj3.style.top=parseInt(obj2.style.top)+parseInt(obj2.style.height);
	obj3.style.visibility="visible";


  
    i=0;
    originTop=originTop0;
    originLeft=originLeft0;

	while(i<nbTetemenu){
		blockinit="block"+i

		block_obj=document.getElementById(blockinit);
		block_obj.style.top=parseInt(originTop);
		block_obj.style.left=parseInt(xx);
		
		originTop=parseInt(originTop)+parseInt(block_obj.style.height);
		
		block_obj.style.visibility="visible";
		
		i++;
	}//fin de while initialise les BLOCKS


	//on réinitialise pour efectuerd e nouveau une boucle sur le nombre de tetes de menu
	i=0;
	while(i<nbTetemenu){
		blockinit="blockitem"+i
		block_obj=document.getElementById(blockinit);   
		// on cache les sousmenu
		block_obj.style.visibility="hidden";
		i++;
	}//fin de while initialise les BLOCKS ITEM (cache des blocks items)

//on redimensionne le corps de menu
	obj1.style.height=parseInt(originTop);


}
else{

	// positionnement des layers de menu en arrière plan
    // mise en place visuelle -->etat visible
	lnom="lmentop";
	ladx=eval(docu+lnom+modele);
    ladx.top=yy-5 // on recupere ici une valeur corrigée par la position d'une img de 'calage'
    ladx.left=xx 
	  if(navnom!="ie4"){ladx.clip.height=hlmentop+pxs;}
      else{ladx.height=hlmentop;}
	  ladx.visibility=etatvisible;
	
	lnom="lmencor";
	ladx=eval(docu+lnom+modele);
    ladx.top=hlmentop+yy-5   // on recupere ici une valeur corrigée par la position d'une img de 'calage'
    ladx.left=xx;  
	  if(navnom!="ie4"){ladx.clip.height=hlmencor+pxs;}
      else{ladx.height=hlmencor;}
	  ladx.visibility=etatvisible;
	 
	lnom="lsearch";
	ladx=eval(docu+lnom+modele);
    ladx.top=hlmencor+yy-5   // on recupere ici une valeur corrigée par la position d'une img de 'calage'
    ladx.left=xx 
	  if(navnom!="ie4"){ladx.clip.height=hlsearch+8+pxs;}  //on introduit un léger correctif
      else{ladx.height=hlsearch;}
	  ladx.visibility=etatvisible;
	  
	lnom="lmenbott";
	ladx=eval(docu+lnom+modele);
    ladx.top=hlmencor+yy+hlsearch-5   // on recupere ici une valeur corrigée par la position d'une img de 'calage'
    ladx.left=xx 
    if(navnom!="ie4"){ladx.clip.height=hlmenbottom+8+pxs;}  //on introduit un léger correctif
     else{ladx.height=hlmenbottom;}
	 ladx.visibility=etatvisible;

  
    i=0;
    originTop=originTop0;
    originLeft=originLeft0;


while(i<nbTetemenu){
blockinit="block"+i
ladx=eval(docu+blockinit+modele);
ladx.top=originTop;
ladx.left=originLeft;
// on fixe l'origine + la heuteur du layer d'entete = hauteur de l'image = clip height
if(navnom!="ie4"){originTop+=parseInt(ladx.clip.height);}  //on introduit un léger correctif
     else{originTop+=parseInt(ladx.height);}
// on cache le layer pouer l'initialisation
ladx.visibility=etatvisible;
i++;
}//fin de while initialise les BLOCKS
//on réinitialise pour efectuerd e nouveau une boucle sur le nombre de tetes de menu
i=0;
while(i<nbTetemenu){
blockinit="blockitem"+i
ladx=eval(docu+blockinit+modele);   
// on cache les sousmenu
ladx.visibility=etatcache;
i++;
}//fin de while initialise les BLOCKS ITEM (cache des blocks items)
}//fin de if
}//fin de init_all

//****************FONCTION initiale DE DEPLIAGE DES LAYER DE BLOCKITEMX *********
function ouvre_ferme(numeroblock){

if(navnom=="n6"){
	obj2.style.height=parseInt(obj2.style.height)-parseInt(8);
}
// envoi dabors à la fermeture et init des layers
init_allblock();  //d'abord il y a initialisation des blocks
if(navnom=="n6"){
 		if (numeroblockpreced!=numeroblock){
				ouvre_n6(numeroblock);
				etatblock=0;
				numeroblockpreced=numeroblock;
		}
		else{
			if (numeroblockpreced==numeroblock && etatblock==0){
					//avant de lancer l'init on enleve le correctif de 8px sur la recherche.
					obj2.style.height=parseInt(obj2.style.height)-parseInt(8);
                    init_allblock();
					etatblock=-1;
					numeroblockpreced=numeroblock;
			}
			else if (numeroblockpreced==numeroblock && etatblock==-1){
				ouvre_n6(numeroblock);
				etatblock=0;
				numeroblockpreced=numeroblock;
			}
		}
	
}else{






if (numeroblockpreced !=numeroblock){
 choixtraite(numeroblock,numeroblockpreced,blockitem,finblock,finblock0,nbTetemenu,hlmencor,testredim,sizemenuItem,espaceh);
numeroblockpreced=numeroblock;
}
else if(numeroblockpreced==numeroblock){numeroblockpreced=-1;finblock=0; finblock0=0;}   
// phil modif 5 septembre les 3 lignes suivantes est a ajouter
//si ie seulement
if(document.all){
if(imgnamenoncli!=""){
//restauration ici
off(imgnamenoncli);
}//fin de restauration
nouvim="img"+parseInt(numeroblock+1);
imgnamecli=nouvim;
imgOn = eval(nouvim+ "on.src");
on(nouvim);
imgnamenoncli=imgnamecli;
imgnamecli="non";
}// fin si ie
}//fin if-else
}//ferme fonction ouvre_ferme
//////////////////////////////////////////////////////////////////////////

//c'est dans choix traite que selon le navigateur on envoi...
function choixtraite(numeroblock,numeroblockpreced,blockitem,finblock,finblock0,nbTetemenu,hlmencor,testredim,sizemenuItem,espaceh){
blockitem="blockitem"+numeroblock;
numeroblocksuiv=parseInt(numeroblock)+1
 if(numeroblocksuiv==nbTetemenu){
   finblock=-1;finblock0=sizemenuTete+espaceh;
   redimMen(numeroblock,numeroblockpreced,blockitem,finblock,finblock0,nbTetemenu,hlmencor,testredim,sizemenuItem,espaceh)
 }//fin de if
//si sortie depassement du dernier layer
numeroblocksuiv=numeroblocksuiv+finblock
//finblock change d'usage et devient la hauteur de layer d'entete

// c'est le block d'entete suivant qui va determine la position top et left d'affichage du block item
blocksuivant="block"+numeroblocksuiv;
ladx=eval(docu+blockitem+modele);
ladsuivant=eval(docu+blocksuivant+modele);
//positionne le block d'items finblock =0 sauf si dernier block
ladx.top=eval(parseInt(ladsuivant.top)+parseInt(finblock0));
ladx.left=eval(parseInt(ladsuivant.left));
//rend visible le block d'items
ladx.visibility=etatvisible;

//ici decale les block de la hauteur du blockitem ouvert
if(navnom=="n4"){decalheight=ladx.clip.height;}
else{decalheight=ladx.height}
redimMen(numeroblock,numeroblockpreced,blockitem,finblock,finblock0,nbTetemenu,hlmencor,testredim,sizemenuItem,espaceh);
//le while deplace les blocks qui sont dessous le blocks d'items qui s'ouvre
if(finblock==0){
while(numeroblocksuiv<nbTetemenu)
{
blocksuivant="block"+numeroblocksuiv;
lad_decal=eval(docu+blocksuivant+modele);
lad_decal.top=eval(parseInt(lad_decal.top))+parseInt(decalheight);
numeroblocksuiv++;// positionne la  variable numeroblockpreced

}//fin while
}// fin de if finblock
}// fin de la fonction

//////////////////// la fonction redimMen ///////////////////
function redimMen(numeroblock,numeroblockpreced,blockitem,finblock,finblock0,nbTetemenu,hlmencor,testredim,sizemenuItem,espaceh){
sizem=sizemenuItem+espaceh;
testredim=parseInt(decalheight)+parseInt(sizem*nbTetemenu);  // =hauteur totale des entetes + taille du layer ouvert (items)

if (hlmencor<testredim){                // si le corps de menu est trop petit on redimensionne l'arrière plan
ladx=eval(docu+"lmencor"+modele);
  if(navnom!="ie4"){ladx.clip.height=testredim+pxs;}
  else{ladx.height=testredim+pxs;}
ladx=eval(docu+"lsearch"+modele);
ladx.top=(yy+testredim-5)+pxs;   // on doit deplacer l'élément de recherche
ladx=eval(docu+"lmenbott"+modele);
ladx.top=(yy+testredim+hlsearch-5)+pxs;   // on doit deplacer le bottom
}//fin if de redimensionnent

else{
testredim=originTop0+hlmentop+hlmencor
ladx=eval(docu+"lmencor"+modele);
if(navnom!="ie4"){ladx.clip.height=hlmencor+pxs;}
else{ladx.height=hlmencor+pxs;}
ladx=eval(docu+"lsearch"+modele);ladx.top=hlmencor+yy-5+pxs
ladx=eval(docu+"lmenbott"+modele);ladx.top=hlmencor+yy+hlsearch-5+pxs
}// fin if else redim dynamique de la hauteur du menu
}//fin de redimMen

//********************************************************* 
function ouvre_n6(numeroblock){
i=0;
ordonnee_origine=parseInt(obj1.style.top);

while(i<nbTetemenu){
		blockinit="block"+i;
		block_obj=document.getElementById(blockinit);
       
		if (i!=numeroblock){
				block_obj.style.top=parseInt(ordonnee_origine);
				block_obj.style.left=parseInt(xx);
				ordonnee_origine=parseInt(ordonnee_origine)+parseInt(block_obj.style.height);
				block_obj.style.visibility="visible";
		}
		if (i==numeroblock){
				block_obj.style.top=parseInt(ordonnee_origine);
				block_obj.style.left=parseInt(xx);
				block_obj.style.visibility="visible";

				ordonnee_origine=parseInt(ordonnee_origine)+parseInt(block_obj.style.height);
				block_obj=document.getElementById("blockitem"+i);
				block_obj.style.top=parseInt(ordonnee_origine);
				block_obj.style.left=parseInt(xx);
				ordonnee_origine=parseInt(ordonnee_origine)+parseInt(block_obj.style.height);
				block_obj.style.visibility="visible";

		}
		
		i++;
	}

	//redimentionnement du layer corps de menu
	if(parseInt(ordonnee_origine)-parseInt(obj1.style.top)>=parseInt(224)){
		obj1.style.height=parseInt(ordonnee_origine)-parseInt(obj1.style.top);
		obj2.style.top=parseInt(ordonnee_origine);
	}
	else{
		obj1.style.height=parseInt(224);
		obj2.style.top=parseInt(obj1.style.top)+parseInt(224);
	}

	
	obj2.style.visibility="visible";
	ordonnee_origine=parseInt(obj2.style.top)+parseInt(obj2.style.height);
	obj3.style.top=ordonnee_origine;
	obj3.style.visibility="visible";
	ordonnee_origine=parseInt(ordonnee_origine)+parseInt(obj3.style.height);
	

}
//*************************************************************
