/****** BEGIN LICENSE BLOCK *****
 * Copyright (c) 2005 Harmen Christophe and contributors. All rights reserved.
 * 
 * This script is free software; you can redistribute it and/or
 *   modify under the terms of the Creative Commons - Attribution-ShareAlike 2.0
 * <http://creativecommons.org/licenses/by-sa/2.0/>
 * You are free:
 *     * to copy, distribute, display, and perform the work
 *     * to make derivative works
 *     * to make commercial use of the work
 * 
 * Under the following conditions:
 * _Attribution_. You must attribute the work in the manner specified by the
 *   author or licensor.
 * _Share Alike_. If you alter, transform, or build upon this work, you may
 *   distribute the resulting work only under a license identical to this one.
 *     * For any reuse or distribution, you must make clear to others 
 *      the license terms of this work.
 *     * Any of these conditions can be waived if you get permission from 
 *      the copyright holder.
 * 
 * Your fair use and other rights are in no way affected by the above.
 * 
 * This is a human-readable summary of the Legal Code (the full license). 
 * <http://creativecommons.org/licenses/by-sa/2.0/legalcode>
 ***** END LICENSE BLOCK ******/

addEventLst(window,"load",initMenus2);
function initMenus2() {
	var nav2 = navigator.userAgent;
	var ie5mac2 = nav2.indexOf("Opera")==-1 && nav2.indexOf("MSIE 5")>-1 && nav2.indexOf("Mac")>-1;
	if (!document.createElement && !document.createTextNode && !document.getElementById && !document.getElementsByTagName) return;
	if (ie5mac2) return;
	document.getElementById("navthema").style.display = "block";
	//var nPControle2, nAControle2, nTxt2;
	//nPControle2 = document.getElementById("righter").getElementsByTagName("p")[0];
	//nPControle2.id= "menusControle2";
	//nAControle2 = document.createElement("a");
	//nAControle2.href="javascript:menuController2();";
	//nPControle2.appendChild(nAControle2);
	//nTxt2 = document.createTextNode("Désactiver le menu");
	//nAControle2.appendChild(nTxt2);
	//var nChild2 = document.getElementById("menu2");
	//document.getElementById("righter").insertBefore(nPControle2,nChild2);
	loadMenus2();
}
function loadMenus2() {
	var nRessources2, nA2;
	addClassName(document.body,"dynamik2");
	nMenus2 = document.getElementById("navthema");
	if (nMenus2.addEventListener) {
		nMenus2.addEventListener("mouseover",montrerMenu2,true);
		nMenus2.addEventListener("focus",montrerMenu2,true);
		nMenus2.addEventListener("DOMFocusIn",montrerMenu2,true);
		nMenus2.addEventListener("mouseout",cacherMenus2,true);
		nMenus2.addEventListener("blur",cacherMenus2,true);
		nMenus2.addEventListener("DOMFocusOut",cacherMenus2,true);
	} else {
		var cTheme2 = getElementsByClass("theme2",nMenus2);
		for (var i=0; i<cTheme2.length; i++) {
			addEventLst(cTheme2[i],"mouseover",montrerMenu2);
			addEventLst(cTheme2[i],"mouseout",cacherMenus2);
			for (var j=0; nA2 = cTheme2[i].getElementsByTagName("a")[j]; j++) {
				addEventLst(nA2,"focus",montrerMenu2);
				addEventLst(nA2,"blur",cacherMenus2);
			}
		}
	}
	//document.getElementById("menusControle2").getElementsByTagName("a")[0].firstChild.nodeValue="Désactiver le menu";
}
function unloadMenus2() {
	var nRessources2, nA2;
	deleteClassName(document.body,"dynamik2");
	nMenus2 = document.getElementById("navthema");
	if (nMenus2.removeEventListener) {
		nMenus2.removeEventListener("mouseover",montrerMenu2,true);
		nMenus2.removeEventListener("focus",montrerMenu2,true);
		nMenus2.removeEventListener("DOMFocusIn",montrerMenu2,true);
		nMenus2.removeEventListener("mouseout",cacherMenus2,true);
		nMenus2.removeEventListener("blur",cacherMenus2,true);
		nMenus2.removeEventListener("DOMFocusOut",cacherMenus2,true);
	} else {
		var cTheme2 = getElementsByClass("theme2",nMenus2);
		for (var i=0; i<cTheme2.length; i++) {
			removeEventLst(nChild2,"mouseover",montrerMenu2);
			removeEventLst(nChild2,"mouseout",cacherMenus2);
			for (var j=0; nA2 = cTheme2[i].getElementsByTagName("a")[j]; j++) {
				removeEventLst(nA2,"focus",montrerMenu2);
				removeEventLst(nA2,"blur",cacherMenus2);
			}
		}
	}
	//document.getElementById("menusControle2").getElementsByTagName("a")[0].firstChild.nodeValue="Activer le menu";
}
function menuController2() {
	if (hasClassName(document.body,"dynamik2")) unloadMenus2();
	else loadMenus2();
}
function montrerMenu2(evt2) {
	var oNode2;
	if (evt2 && evt2.target) {
		oNode2 = evt2.target;
	} else if (window.event) {
	    oNode2 = window.event.srcElement;
	} else {
		oNode2 = this;
	}
	while (oNode2.id!="navthema") {
		if (hasClassName(oNode2,"theme2")) {
			addClassName(oNode2,"currentTheme2");
			//On veut remonter jusqu'a [id=menus] alors pas de : break;
		}
		oNode2 = oNode2.parentNode;
	}
}
function cacherMenus2(evt2) {
	var oNode2, nRelatedTarget2;
	function _cacherMenus2(oNode2) {
		var nSibling2 = oNode2;
		// On test les frères
		while (nSibling2) {
			if (hasClassName(nSibling2,"theme2")) deleteClassName(nSibling2,"currentTheme2");
			nSibling2=nSibling2.nextSibling;
		}
		// On remonte les parents
		while (oNode2.id!="navthema") {
			if (hasClassName(oNode2,"theme2")) deleteClassName(oNode2,"currentTheme2");
			oNode2=oNode2.parentNode;
		}
	}
	if (evt2 && evt2.target) {
		oNode2 = evt2.target;
		nRelatedTarget2 = evt2.relatedTarget;
	} else if (window.event) {
		oNode2 = window.event.srcElement;
		nRelatedTarget2 = window.event.toElement;
	} else {
		oNode2 = this;
	}
	while (oNode2.id!="navthema") {
		if (hasClassName(oNode2,"theme2")) {
			if (nRelatedTarget2 && (!isChildNodeOf(nRelatedTarget2,oNode2))) {
				_cacherMenus2(oNode2);
			} else if (!nRelatedTarget2) {
				_cacherMenus2(oNode2);
			}
			break;
		}
		oNode2 = oNode2.parentNode;
	}
}

