var arrId = new Array("fondationNavigation","initiativesNavigation","archivesNavigation","publicationNavigation");
var timerMenu;

startList = function(idList) {
    if (document.all&&document.getElementById) {
        navRoot = document.getElementById(idList);
        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName=="LI") {
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
    
    var menu = getElementHandle(idList);
    menu.onmouseover=function() {
       clearTimeout(timerMenu);
    }
    menu.onmouseout=function() {
       clearTimeout(timerMenu);
       var code = 'hideAllSubNavigation()';
       var temps = 3000;
       timerMenu = setTimeout(code, temps);      
    }
}
initAll = function(){
    startList('fondationNavigation');
    startList('initiativesNavigation');
    startList('archivesNavigation');
    startList('publicationNavigation');
}
function getElementHandle(idObject) {
	//document object model dection
	if (document.all) {
		var divElement = document.all(idObject);
	} else if (document.layers) {
		var divElement = document.layers[idObject];
	} else if (document.getElementById) { 
		var divElement = document.getElementById(idObject);
	}
	return divElement;
}
function displaySubNavigation(idSubNavigation,flashX) {
    var i = 0 ;
    for (i=0 ; i<arrId.length; ++i) {
        var subFound = getElementHandle(arrId[i]);
        if (arrId[i] == idSubNavigation) {
            subFound.style.display = "block";
            subFound.style.left = (flashX+20) + "px";
        } else {
            subFound.style.display = "none";            
        }
    }
}
function hideAllSubNavigation() {
    for (i = 0 ;  i <  arrId.length ; ++i) {
        hideElement(arrId[i]);
    }
}
function hideElement(idElement) {
    var subFound = getElementHandle(idElement);
    subFound.style.display = "none";
}
window.onload = initAll;
document.onclick = hideAllSubNavigation;