// JavaScript Document
// JavaScript Document
// Raccourci et création d'un objet
var d = document,
	o = {};
// Définition des propriétés de l'objet
o.Menu =
{

	// Chargement du menu
	__Load__: function()
	{

		// On lance le test pour s'assurer du bon fonctionnement
		o.Menu.__Init__();
	},

	// Méthode d'initialisation du menu
	__Init__:function()
	{
		// On définit les variables nécessaires.
		var iA,
			oMenu = d.getElementById('menu'),
			oDl = oMenu.getElementsByTagName('dl'),
			oDd;

		// Pour chaque élément dl du tableau oDl,
		for ( iA = oDl.length - 1; iA >= 0; iA-- )
		{
			//pour les déroulants seulement
			oDd = oDl[iA].getElementsByTagName('dd')[0];
			if (oDd != null)
			{
				oDl[iA].onclick = o.Menu.__MouseDisplay__;
			}
		}

	},

	// Méthode d'affichage de l'élément dd lorsqu'on le survole.
	__MouseDisplay__:function()
	{

		// On cache tous les éléments dd en lançant la méthode dédiée à cette tâche.
		o.Menu.__HideLists__();

		// On récupère l'élément dd de l'élément dl qu'on survole dans un objet.
		var oDd = this.getElementsByTagName('dd')[0];
		//affiche le sous menu
		if (oDd != null)
		{
			// On affecte la propriété css "display: block;" à l'objet oDd (affichage)
			oDd.style.display = 'block';
		}
	},

	// Méthode de masquage des éléments dd
	__HideLists__:function()
	{
		// On définit les variables nécessaires.
		var iA,
			oDd = d.getElementById('menu').getElementsByTagName('dd');

		// Pour chaque élément dd du tableau oDd,
		for (iA = oDd.length - 1; iA >= 0; iA-- )
		{
			// On affecte la propriété css "display: none;" à l'objet oDd (masquage)
			oDd[iA].style.display = 'none';
		}
	}
};

function HideMenu()
{
	//Recherche la page courante pour la sélectionner dans le menu
	var pageCourrante = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1) || "index.php";
	//Cache les sous-menu qui n'ont pas de page sélectionnée
	var oDd = d.getElementById('menu').getElementsByTagName('dd'),
		i=oDd.length-1;
		
	var reduit, oA, j;
	for(i;i>=0;i=i-1)
	{
		reduit = true;
		//met en gras les éléments du sous-menu
		oA = oDd[i].getElementsByTagName('a');
		if (oA != null)
		{
			//for ( j = oA.length - 1; j >= 0; j-- )
			for ( j = 0; j < oA.length; j++ )
			{
				if (oA[j].href.indexOf(pageCourrante) > -1)
				{
					reduit = false;
					oA[j].style.fontWeight="bold";
				}
			}
		}
		if (reduit)
		{
			oDd[i].style.display='none';
		}
	}
	//met en gras les éléments du menu
	var oDt = d.getElementById('menu').getElementsByTagName('dt');
	i=oDt.length-1;
	for(i;i>=0;i=i-1)
	{
		//met en gras les éléments du sous-menu
		oA = oDt[i].getElementsByTagName('a');
		if (oA != null)
		{
			if (oA[0].href.indexOf(pageCourrante) > -1)
			{
				if (oA[0].href.indexOf("#") < 0)
				{
					oA[0].style.fontWeight="bold";
				}
			}
		}
	}
};
// Une fois que le document est chargé en mémoire, on charge le script.
window.onload=o.Menu.__Load__;

/*
// JavaScript Document
var sPage = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1) || "index.php";
/*window.onload = function() {
}*//*
function $(pid) {
	return document.getElementById(pid);
}

function HideMenu()
{
	//Recherche la page courante pour la sélectionner dans le menu
	var pageCourrante = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1) || "index.php";
	//Cache les sous-menu qui n'ont pas de page sélectionnée
	var oDd = d.getElementById('menu').getElementsByTagName('dd'),
		i=oDd.length-1;
		
	var reduit, oA, j;
	for(i;i>=0;i=i-1)
	{
		reduit = true;
		oA = oDd[i].getElementsByTagName('a');
		if (oA != null)
		{
			//for ( j = oA.length - 1; j >= 0; j-- )
			for ( j = 0; j < oA.length; j++ )
			{
				if (oA[j].href.indexOf(pageCourrante) > -1)
				{
					//alert(oA[j].href);
					reduit = false;
					oA[j].style.color = "#E42B2A";
				}
			}
		}
		if (reduit)
		{
			oDd[i].style.display='none';
		}
	}*/
/*
	var tblUl = $("menu").getElementsByTagName("ul");
	for (var i = 0;i<tblUl.length;i++)
	{
		tblUl[i].style.display="none";
		tblUl[i].parentNode.firstChild.onclick = HideMenu2;
		/*tblUl[i].parentNode.firstChild.onclick = function () {
			if (this.parentNode.childNodes[2].style.display == "none")
				this.parentNode.childNodes[2].style.display="block";
			else
			    this.parentNode.childNodes[2].style.display = "none";};*/
	/*}
	var tblA = $("menu").getElementsByTagName("a");
	for (var j=0;j<tblA.length;j++) {
		if (tblA[j].href.indexOf(sPage) > -1) {
			if (tblA[j].href.indexOf("#") < 0) {
				tblA[j].style.fontWeight="bold";
				tblA[j].parentNode.parentNode.style.display="block";
			}
		}
	}
};

function HideMenu2() {
	if (this.parentNode.childNodes[2].style.display == "none")
		this.parentNode.childNodes[2].style.display="block";
	else
	    this.parentNode.childNodes[2].style.display = "none";
}*/