// JavaScript Document
window.onload = initMenu;

function $(el){
	return document.getElementById(el);
}

function ajouteTableaux(t1,t2){
	for(var i=0; i<t2.length; i++){
		t1.push(t2[i]);
	}
	return t1;
}


function initMenu(){
	var listLi=$("main_menu").getElementsByTagName("li");
	var listLiSecondMenu=$("second_menu").getElementsByTagName("li");
	
	for (var i=0; i<listLi.length; i++){
		if (listLi[i].className=="rub cacheUl"){			
			listLi[i].onmouseover=function(){
				rollOver_rubrique(this);
			}
			listLi[i].onmouseout=function(){
				rollOut_rubrique(this);
			}
		}
	}
	for (var i=0; i<listLiSecondMenu.length; i++){
		if (listLiSecondMenu[i].className=="rub cacheUl"){			
			listLiSecondMenu[i].onmouseover=function(){
				rollOver_rubrique(this);
			}
			listLiSecondMenu[i].onmouseout=function(){
				rollOut_rubrique(this);
			}
		}
	}
}

function rollOver_rubrique(o){
	//on montre le sous menu correspondant
	o.className="montreUl";
	//masqueSelect(true);
	 
	var oIFR = document.getElementById(o.id +"I");
	
	/* On met une IFrame invisible derrière le menu pour Résoudre le bug d'IE6 du menu
	qui passe derriere le select*/
	
	if(oIFR != null)
    {
	    var oUl = o.getElementsByTagName("ul")
    	
	    if(oUl.length>0)
	    {
	        oIFR.style.height = oUl[0].clientHeight +"px" ;
	        oIFR.style.width = oUl[0].clientWidth +"px";
	        oUl[0].style.zindex = 900  ;
	    }
    	
        oIFR.style.top = o.style.top;
	    oIFR.style.left = 0;
    	
	    oIFR.style.visibility= 'visible' ;
	    oIFR.style.position = 'absolute';
	    oIFR.style.zindex = 40;
	}
	//on passe l''image en mode sélectionée
	o.getElementsByTagName("a")[0].style.backgroundPosition = "0px -26px";
}

function rollOut_rubrique(o){
	//on cache le sous menu correspondant
	o.className="cacheUl";	
	
    //masqueSelect(false);

    
	//on passe l'image en mode sélectionée
	o.getElementsByTagName("a")[0].style.backgroundPosition = "0px 0px";
	
	var oIFR = document.getElementById(o.id +"I");
	if (oIFR != null)
	{
         oIFR.style.visibility= 'hidden' ;
	}
}


// Fonction annexes  //
function switchlanguage(lg)
{   
    mylocation = window.location.href.replace("/language/fr-FR","");
    mylocation = mylocation.replace("/language/de-DE","");    
    window.location.href = mylocation.replace("/Default.aspx","/language/"+lg+"/Default.aspx");
}

function masqueSelect(cache)
{

var browser=navigator.appName;
var b_version=navigator.appVersion;

    //uniquement pour IE6
    if(browser!="Microsoft Internet Explorer" || b_version <= 4 )
    {
        return;
    }
    
    var ctrls = document.getElementsByTagName("select"); 
    for (var i = 0; i < ctrls.length; i++) 
    {    
        if (ctrls[i].className.indexOf("selectCache")>=0)
        { 
            if(cache)
            {
                ctrls[i].style.display="none"; 
            }
            else
            {
                ctrls[i].style.display=""; 
            }
        }
    }
}