﻿
//***********************************************************
//----------------------MENU ----------------------
//***********************************************************
//Position
function OffsetL(Obj) {
	if (Obj.offsetParent) {return (Obj.offsetLeft + OffsetL(Obj.offsetParent));}
	else {return (Obj.offsetLeft);}
}
//Montre S-Menu
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {
		document.getElementById('smenu'+i).style.display='none';
		}
	}
    if (d) {
        var posX=OffsetL(document.getElementById('menu_contenu'))-105;  
        d.style.left=posX+"px";
        d.style.zIndex =100;
        d.style.display='block';
       
    }
}
/**************************************************************************
 *                                                                        *
 *  JAVASCRIPT MENU HIGHLIGHTER v.1.0 (051123)                            *
 * --------------------------------------------                           *
 * ©2005 Media Division (www.MediaDivision.com)                           *
 *                                                                        *
 * Written by Marius Smarandoiu & Armand Niculescu                        *
 *                                                                        *
 * You are free to use, modify and distribute this file, but please keep  *
 * this header and credits                                                *
 *                                                                        *
 * Usage:                                                                 *
 * - the script will apply the .current class to the <a> and its parent   *
 *   <li> that is contained in the element with id="primarynav" and points*
 *   to the current URL                                                   *
 * - works in IE6, Firefox and Opera                                      *
 **************************************************************************/
function extractPageName(hrefString)
{
	var arr2 = hrefString.split('.');
	arr2 = arr2[arr2.length-2].split('/');
	return arr2[arr2.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{
	for(var i=0; i < arr.length; i++){
	if(arr[i].href){
	        var url=arr[i].href;
	        if(url.indexOf("#",0)== -1){	        
	            url=extractPageName(url);
	            url=url.toLowerCase();
		            if(url == crtPage)
		            {
    		          
		               if(arr[i].parentNode.tagName == "LI"){
		                    arr[i].parentNode.parentNode.parentNode.parentNode.parentNode.className = "menuON";
		                }
		                else if(arr[i].parentNode.tagName == "TD"){
		                    arr[i].parentNode.className = "menuON";
		                }    		    
		            break;
		            }
		        }
		    }
		}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;		

	if (document.getElementById("menu_contenu")!=null) {
		setActiveMenu(document.getElementById("menu_contenu").getElementsByTagName("a"), extractPageName(hrefString));
		}
}
// INIT ALL
function initAll(){
montre();
setPage();

}

//START ALL
window.onload=initAll;
