/* MAIN MENU *****************************************************************************************/

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

window.loadListeners = new Array();
window.addLoadListener = function(f) {
  window.loadListeners[window.loadListeners.length]=f;
}

function initPage() {
  for(var n=0;n<window.loadListeners.length;n++){
    if (typeof(window.loadListeners[n]) == 'function') {
      window.loadListeners[n]();
    } 
  }
}

if ( typeof(document.getElementById)!='undefined' ) {
  window.onload = initPage;
}

var menubar = {
    timer: 0,
    timerForSecondMenu: 0,
    menuchilds: [],
    allow_close: 0,
    active_item: 0,
    canRedraw: true,
    showmenu: function(element) {
        this.allow_close=1
        this.hidemenu(1)
        this.allow_close=0
        if (this.canRedraw==true) {
			document.getElementById('m1').style.backgroundColor='';
			document.getElementById('m2').style.backgroundColor='';
			document.getElementById('m3').style.backgroundColor='';
			document.getElementById('m4').style.backgroundColor='';
			document.getElementById('m5').style.backgroundColor='';
			document.getElementById('m6').style.backgroundColor='';
			document.getElementById('m7').style.backgroundColor='';
//			document.getElementById('m8').style.backgroundColor='';
//			document.getElementById('m9').style.backgroundColor='';
//			document.getElementById('m10').style.backgroundColor='';
        }
        if(this.timerForSecondMenu) clearTimeout(this.timerForSecondMenu)
        if(element.childNodes[1] && element.childNodes[1].nodeType==1) {
            element.childNodes[1].style.display='block'
            this.active_item=element.childNodes[1]
        }
    },
    resetToDefault: function() {
        var Selected = false;
        this.menuchilds = document.getElementById("menubar").childNodes
        for (var i=0;i<this.menuchilds.length;i++) {
            if(this.menuchilds[i].nodeType==1) {
                if (this.menuchilds[i].className.substr(0,8) == 'selected') {
                    this.menuchilds[i].onmouseover();
                    Selected=true;
                }
            }
        }
        document.getElementById('m1').style.backgroundColor='';
        document.getElementById('m2').style.backgroundColor='';
        document.getElementById('m3').style.backgroundColor='';
        document.getElementById('m4').style.backgroundColor='';
        document.getElementById('m5').style.backgroundColor='';
        document.getElementById('m6').style.backgroundColor='';
		document.getElementById('m7').style.backgroundColor='';
//		document.getElementById('m8').style.backgroundColor='';
//		document.getElementById('m9').style.backgroundColor='';
//		document.getElementById('m10').style.backgroundColor='';
/*        if (!Selected) 
        {
            document.getElementById("defaultmnu").childNodes[1].style.display='block';
            if (this.active_item.id!="neverclose")
            {
                this.active_item.style.display='none';
            }
        }*/
    },

    hidemenu: function(now) {
        if (now && this.allow_close && this.active_item) {
            this.active_item.style.display='none'
        }
        if (!now && !this.allow_close) {
            this.allow_close=1
            if(this.timer) clearTimeout(this.timer)
            this.timer = setTimeout("menubar.hidemenu(1)",001)
            this.timerForSecondMenu = setTimeout("menubar.resetToDefault()",001)
            //this.init();
            //document.getElementById("defaultmnu").childNodes[1].style.display='block'
        }
    },


    init: function() {
        // put mouse event listener on every <li> in the menu
            var Selected = false;
            this.menuchilds = document.getElementById("menubar").childNodes
            for (var i=0;i<this.menuchilds.length;i++) {
                if(this.menuchilds[i].nodeType==1) {
                    this.menuchilds[i].onmouseover=function () { menubar.showmenu(this) }
                    this.menuchilds[i].onmouseout=function () { menubar.hidemenu(0) }
                    this.menuchilds[i].onfocus=function () { menubar.showmenu(this) }
                    this.menuchilds[i].onblur=function () { menubar.hidemenu(0) }
                    if (this.menuchilds[i].className.substr(0,8) == 'selected') {
                        this.menuchilds[i].onmouseover();
                        Selected=true;
                    }
                }
            }
//            if (!Selected) {document.getElementById("defaultmnu").childNodes[1].style.display='block';}
    }
}

// add initmenu to the list of functions to be called at the end of the page loading.

function initmenubar() {
	if (document.getElementsByTagName('body')[0]!=null) {
	    menubar.init();
	}
}
      
addLoadListener(initmenubar);




//Second Menu
/***********************************************
* AnyLink Vertical Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var menuVide=new Array()

//Ajouter une couleur de menu pour chaques menu
var menuBgColor = new Array()
menuBgColor['menu1']='#000000';
menuBgColor['menu2']='#000000';
menuBgColor['menu3']='#000000';
menuBgColor['menu4']='#000000';
menuBgColor['menu5']='#000000';
menuBgColor['menu6']='#000000';
menuBgColor['menu7']='#000000';
//menuBgColor['menu8']='#000000';
//menuBgColor['menu9']='#000000';
//menuBgColor['menu10']='#000000';
//menuBgColor['menu11']='#000000';
//menuBgColor['menu12']='#000000';
//menuBgColor['menu13']='#000000';
//menuBgColor['menu14']='#000000';
//menuBgColor['menu15']='#000000';
//menuBgColor['menu16']='#000000';
//menuBgColor['menu17']='#000000';


//Ces variables sont pour la couleur de fond du premier niveau dans le menu (PAPER, WOOD, PULP ...)
/*var menuColor = new Array()
menuColor['menu1']='#000000';
menuColor['menu2']='#000000';
menuColor['menu3']='#000000';
menuColor['menu4']='#000000';
menuColor['menu5']='#000000';
menuColor['menu6']='#000000';
menuColor['menu7']='#000000';
menuColor['menu8']='#000000';
menuColor['menu9']='#000000';
menuColor['menu10']='#000000';*/


// Ces variables sont pour la couleur du roll over du premier niveau dans le menu (PAPER, WOOD, PULP ...)
var menuHoverColor = new Array()
menuHoverColor['menu1']='#A4CAD7';
menuHoverColor['menu2']='#E2D1B9';
menuHoverColor['menu3']='#F5EEB4';
menuHoverColor['menu4']='#7FA4D0';
menuHoverColor['menu5']='#BFD49A';
menuHoverColor['menu6']='#CFCFCD';
menuHoverColor['menu7']='#F7B5A1';
//menuHoverColor['menu8']='#BDC3C8';
//menuHoverColor['menu9']='#BDC3C8';
//menuHoverColor['menu10']='#BDC3C8';


var ie4=document.all
var ns6=document.getElementById&&!document.all

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
if (ie4) {
    var verticaloffset=4;
}
else {
    var verticaloffset=7;
}
var horizontaloffset=0 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed


if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width: 160px" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
    }
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
//dropmenuobj.style.left=dropmenuobj.style.top=-500
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge"){
        var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
        if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth
    }
    else{
        var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
        var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
        if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
            edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
            if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
            edgeoffset=dropmenuobj.y
        }
    }
    return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what;
}


function dropdownmenu(obj, e, menucontentsname, menuwidth, menuColor,hiddenDefault){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    clearhidemenu()
    dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
    menucontentsobj=document.getElementById(menucontentsname);
    populatemenu(menucontentsobj.innerHTML)
    if (!hiddenDefault) {
        if (ie4||ns6){
            showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
            dropmenuobj.x=getposOffset(obj, "left")
            dropmenuobj.y=getposOffset(obj, "top")
            //dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
            dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
            //dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
            dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+verticaloffset+"px"
            //alert (dropmenuobj.style.bgColor);
            dropmenuobj.style.backgroundColor = menuColor;
            dropmenuobj.style.border = '1px solid rgb(0,0,0)';
        }
    }
    else (hiddenDefault)
    {
        dropmenuobj.style.border = 'none';
    }
    return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
        if (ie4||ns6)
        dropmenuobj.style.visibility="hidden"
    }
}

function delayhidemenu(){
    if (ie4||ns6) {
        delayhide=setTimeout("hidemenu()",disappeardelay)
        menubar.timerForSecondMenu = setTimeout("menubar.resetToDefault()",100)
        
    }
}

function clearhidemenu(){
    if (typeof delayhide!="undefined"){
        clearTimeout(delayhide)
    }
    if (menubar.timer!=0) {
        clearTimeout(menubar.timerForSecondMenu);
        clearTimeout(menubar.timer);
    }
}