/*PLACEMENT MENULEFT*/
function Menu(){
	if (navigator.appName=="Microsoft Internet Explorer"){
		var windowWidth = document.body.clientWidth;
	}else{
		var windowWidth = window.innerWidth;
	}
	var position = ((windowWidth-765)/2)+80;
    if(position<95) position=95;
	var menu_left = document.getElementById('menu_left').style;
	menu_left.left = position+"px";
	menu_left.visibility="visible";
    
   Menutop();
}

/* MENU TOP : GENERATION ET PLACEMENT */

y_sous_menu=81;
function Menutop(){
    getVars();
    var menu_ar = getMenuAr(2);
    var menutop = document.getElementById('menu_top');
    var htmtable = '<table border="0" cellspacing="2" cellpadding="0" class="menutop" align="right"><tr>';
    pos1 = 0;
    for(n=0;n<menu_ar.length;n++){
        niv1 = menu_ar[n];
        pos1 += n*16;
        maclasse = 'menu_top_off';
        if(niv1[0].indexOf("module="+module)!=-1 && niv1[0].indexOf("action="+action)!=-1)maclasse = 'menu_top_on';
        htmtable += "<td id=\"menu"+niv1[2]+"\" valign=\"top\" class=\""+maclasse+"\" height=\"30\" onmouseover=\"this.className='menu_top_on';initNiv1("+pos1+",'"+niv1[2]+"');\" onmouseout=\"this.className='"+maclasse+"';\" onclick=\"document.location='"+ART_wwwroot+"/"+rootpage+niv1[0]+"&amp;lang="+ART_LANG+"';\" title=\""+niv1[1]+"\">"+niv1[1]+"</td>";
        if(n<menu_ar.length-1) htmtable += '<td class="backwhite"></td>';
        pos1 += Math.floor((niv1[1].length*4.95));
    }
    htmtable += '</tr></table>';
    menutop.innerHTML = htmtable;
    
    if (navigator.appName=="Microsoft Internet Explorer"){
        var windowWidth = document.body.clientWidth;
    }else{
        var windowWidth = window.innerWidth;
    }
    var position = ((windowWidth-800)/2)+800-540;
    if(position<95) position=95;
    var menutop = menutop.style;
    menutop.left = position+"px";
    menutop.visibility="visible";
}


var niv1Hover=false;
function killNiv1(kid){
    if(niv1Hover==false){
        var menutop2 = document.getElementById('menu_top2').style;
        document.getElementById('menu_top2').innerHTML = '';
        menutop2.left = "0px";
        menutop2.visibility="visible";
        setNiv2Hover(false);
        killNiv2();
        if(document.getElementById('menu'+kid)){
            document.getElementById('menu'+kid).className='menu_top_off';
        }
    }
}

function setNiv1Hover(val){
    niv1Hover=val;
}

var niv1maxlarge = 0;
function initNiv1(pos,id){
     setNiv2Hover(false); 
     killNiv2();
     var ar = getMenuAr(id);
     if(ar.length>0){
        niv1maxlarge=0;
        getVars();
        lang_decalage=27;
        if(ART_LANG=="en_EN")lang_decalage=81;
        
        setNiv1Hover(true);
        var htmlssmenu = '<table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;">';
        for(o=0;o<ar.length;o++){
            
            ssar = ar[o];
            calcul = Math.floor((ssar[1].length*6.6));
            if(calcul>niv1maxlarge)niv1maxlarge = calcul;
            htmlssmenu += "<tr><td class=\"sous_menu_top_off\" onmouseover=\"this.className='sous_menu_top_on';document.getElementById('menu"+id+"').className='menu_top_on';setNiv1Hover(true);initNiv2("+pos+",'"+ssar[2]+"',"+o+");\" onmouseout=\"this.className='sous_menu_top_off';setNiv1Hover(false);setTimeout('killNiv1("+id+")',1000);\"onclick=\"document.location='"+ART_wwwroot+"/"+rootpage+ssar[0]+"&amp;lang="+ART_LANG+"';\" title=\""+ssar[1]+"\">"+ssar[1]+"</td></tr>"
        }
        htmlssmenu += '</table>';
        
        if (navigator.appName=="Microsoft Internet Explorer"){
            var windowWidth = document.body.clientWidth;
        }else{
            var windowWidth = window.innerWidth;
        }
        var position = ((windowWidth-800)/2)+800-540+pos;
        if(position<95) position=95;
        
        var menutop2 = document.getElementById('menu_top2').style;
        document.getElementById('menu_top2').innerHTML = htmlssmenu;
        menutop2.left = (position+lang_decalage)+"px";
        menutop2.visibility="visible";
     }else{
        setNiv1Hover(false);
        killNiv1();
     }
}


var niv2Hover=false;
function killNiv2(){
    if(niv2Hover==false){
        var menutop3 = document.getElementById('menu_top3').style;
        document.getElementById('menu_top3').innerHTML = '';
        menutop3.left = "0px";
        menutop3.visibility="visible";
        setTimeout('killNiv1()',500);
    }
}

function setNiv2Hover(val){
    niv2Hover=val;
}

function initNiv2(pos,id,ypos){
     var ar = getMenuAr(id);
     if(ar.length>0){
        getVars();
        lang_decalage=27;
        if(ART_LANG=="en_EN")lang_decalage=81;
        
        setNiv2Hover(true);
        var htmlssmenu = '<table cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;">';
        for(o=0;o<ar.length;o++){
            ssar = ar[o];
            htmlssmenu += "<tr><td class=\"sous_sous_menu_top_off\" onmouseover=\"this.className='sous_sous_menu_top_on';setNiv2Hover(true);setNiv1Hover(true);\" onmouseout=\"this.className='sous_sous_menu_top_off';setNiv2Hover(false);setNiv1Hover(false);setTimeout('killNiv2()',500);\"onclick=\"document.location='"+ART_wwwroot+"/"+rootpage+ssar[0]+"&amp;lang="+ART_LANG+"';\" title=\""+ssar[1]+"\">"+ssar[1]+"</td></tr>"
        }
        htmlssmenu += '</table>';
        
        if (navigator.appName=="Microsoft Internet Explorer"){
            var windowWidth = document.body.clientWidth;
        }else{
            var windowWidth = window.innerWidth;
        }
        var position = ((windowWidth-800)/2)+800-540+pos+niv1maxlarge+8;
        if(position<95) position=95;
        
        var menutop3 = document.getElementById('menu_top3').style;
        document.getElementById('menu_top3').innerHTML = htmlssmenu;
        menutop3.left = (position+lang_decalage)+"px";
        menutop3.top = ((20*ypos)+y_sous_menu)+"px";
        menutop3.visibility="visible"; 
     }else{
        setNiv2Hover(false);
        killNiv2();
     }
}




window.onresize = function(){
    Menu();
}