function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/* Script pour la pensée de Léon sur l'accueil */

function popupDiv(){
		document.getElementById("monDivGrand").style.visibility = "visible";
		document.getElementById("monDivPetit").style.visibility = "hidden";
	}

function closePopupDiv(){
		document.getElementById("monDivGrand").style.visibility = "hidden";
		document.getElementById("monDivPetit").style.visibility = "visible";
	}


/*

	Auteurs : 

		Dominic Gauthier 	: 6924

		Martin Rancourt 	: 7526

		

	Dernière modification :

		Martin Rancourt 	: 2005-07-07	Optimiser le code

		Martin Rancourt		: 2005-07-19	Ajouter le system d'exeption pour le hightlight

*/

var domaine = "http://"+location.host;

var pathURL = location.pathname;

var arrayPathURL = pathURL.split("/");

function construireMenu(objUl) {

	//loop dans les childs du UL

	for(var i=0;i<objUl.childNodes.length;i++) {

		//valide si le node est un LI

		if (objUl.childNodes[i].tagName == "LI") {

			

			

			//loop dans les childs du LI

			for(j=0;j<objUl.childNodes[i].childNodes.length;j++) {

				//reset la valeur de la varible qui indique si on doit sélectionné ou ouvrir l'item

				needProcess = false;

				//valide si le node est un A

				

				if(objUl.childNodes[i].childNodes[j].tagName == "A") {

						var classIE = objUl.childNodes[i].childNodes[j].getAttribute('className');

					var classMoz = objUl.childNodes[i].childNodes[j].getAttribute('class');

					

					if ((classMoz != null && classMoz != "") || (classIE != null  && classIE != "")) {

						//alert("classMoz="+classMoz+" --- classIE="+classIE);

						//Si le contenu du class se trouve dans l'url de la page

						var strException = new String();

						if(classMoz != null){

							strException = classMoz;

						}else{

							strException = classIE;

						}

						//alert(strException);

						if (document.location.toString().toLowerCase().indexOf(strException.toLowerCase()) != -1 ) {

							//On doit faire l'ouverture ou la selection de l'item

							

							needProcess = true;

						}

					} else {

						//garde le path du lien trouvé

						var path = objUl.childNodes[i].childNodes[j].getAttribute('href');

						//enlève le domaine si il le contien

						if(path.indexOf(domaine) != -1){

							path = path.slice(domaine.length);

						}

						//Créé un array du path

						var arrayPath = path.split("/");

						//Garde le dernier folder du path

						if(arrayPath[(arrayPath.length-1)].indexOf(".") != -1 || arrayPath[(arrayPath.length-1)] == "") {

							var position = (arrayPath.length-2);

						} else {

							var position = (arrayPath.length-1);

						}

						//Si dernier folder de la page = le dernier folder du lien

						if(arrayPathURL[position] == arrayPath[position]) {

							needProcess = true;

						}

					}

					//Si on doit ouvrir ou sélectionner l'item

					if (needProcess) {

						//loop dans les childs du LI

						if(objUl.childNodes[i].getAttribute('class') == "niv1Archive" || objUl.childNodes[i].getAttribute('className') == "niv1Archive"){

							objUl.childNodes[i].setAttribute("className", "niv1");

							objUl.childNodes[i].setAttribute("class", "niv1");

						}

						for(k=0;k<objUl.childNodes[i].childNodes.length;k++) {

							//valide si c'est un élément A

							if (objUl.childNodes[i].childNodes[k].tagName == "A") {

								// Allume le menu -> mets un class "On" au A

								

								objUl.childNodes[i].childNodes[k].setAttribute("className", "On");

								objUl.childNodes[i].childNodes[k].setAttribute("class", "On");

							}

							//valide si il y a un UL

							if(objUl.childNodes[i].childNodes[k].tagName == "UL") {

								//Ouvre le sous menu

								

								objUl.childNodes[i].childNodes[k].style.display = "block";

								//Recall la fonction pour appliquer le processus au child

								construireMenu(objUl.childNodes[i].childNodes[k]);			

								break;					

							}

						}

					}

				}

			}

		}

	}

}

if (window.document.getElementById) construireMenu(window.document.getElementById("menuUl"));
