var ie = /MSIE/.test(navigator.userAgent);
var moz = !ie && navigator.product == "Gecko";
var csch = "/";

if (moz) {
    HTMLElement.prototype.__defineGetter__("children", function() {
        var arr = new Array(), i = 0, l = this.childNodes.length;
        for ( i = 0; i < l; i++ ) {
            if ( this.childNodes[ i ].nodeType == 1 ) {
                arr.push( this.childNodes[ i ] );
            }
        }
        return arr;
    });

}      

    function Reduc(elmtTitre) {
        var elmt = elmtTitre.parentNode.parentNode;
        if (elmt.children[0].className == "expand") {
            elmt.children[1].className = "contentcollapse";
            elmt.children[0].className = "collapse";
            SetCookie(elmt.id,"collapse");
        }
        else {
            elmt.children[1].className = "content";
            elmt.children[0].className = "expand";
            SetCookie(elmt.id,"expand");
        }

    }
    function ReducForce(elmtTitre) {
      var elmt = elmtTitre.parentNode.parentNode;
      elmt.children[1].className = "contentcollapse";
      elmt.children[0].className = "collapse";
    }

        /// mode : - 0 si onglet et le button
        ///        - autre si c'est l'id du parent des onglets  
        function OngletChange(onglet, number,mode){
            var elmt;
            if (mode == 0) elmt = onglet.parentNode.parentNode.parentNode;
            else elmt = document.getElementById(onglet); 
            LI = elmt.firstChild.getElementsByTagName("a");
            for(i=0; i < LI.length; i++){
                if (i == number) LI[i].className = "Actif";
                else LI[i].className = "";
            }
           var i=0;
           node = elmt.children[ 1 ];
           while (node != null){ 
           if (node.nodeType == 1){
            var nodeTitre = node.children[ 0 ];
            var b = false;
            while (!(nodeTitre == null || b))
            {
                if(nodeTitre.nodeType == 1) {nodeTitre.style.display = "none";nodeTitre.style.visibility = "hidden";b=true;}
                nodeTitre = nodeTitre.nextSibling;
            }
            if (i == number) {node.style.display = "block"; node.style.visibility = "visible" }
            else {node.style.display = "none";node.style.visibility = "hidden"}
            i++;}
           node = node.nextSibling; }
        }
        
  
        
        function getCookieVal(offset) {
            var endstr=document.cookie.indexOf (";", offset);
            if (endstr==-1)
                    endstr=document.cookie.length;
            return unescape(document.cookie.substring(offset, endstr));
        }
        function GetCookie(name) {
            var arg= name + "=";
            var alen= arg.length;
            var clen=document.cookie.length;
            var i=0;
            while (i<clen) {
                var j=i+alen;
                if (document.cookie.substring(i, j)==arg)
                                    return getCookieVal (j);
                            i=document.cookie.indexOf(" ",i)+1;
                                    if (i==0) break;}
            return null;
        }
        
        function SetCookie (name, value) {
            // un cookie a besoin d'un nom, d'une valeur, d'un nom de domaine, d'une date d'expiration
            var argv=SetCookie.arguments;
            var argc=SetCookie.arguments.length;
            var expires=(argc > 2) ? argv[2] : null;
            var path=(argc > 3) ? argv[3] : null;
            var domain=(argc > 4) ? argv[4] : null;
            var secure=(argc > 5) ? argv[5] : false;
            document.cookie=name+"="+escape(value)+
                ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
                ((path==null) ? "" : ("; path="+path))+
                ((domain==null) ? "" : ("; domain="+domain))+
                ((secure==true) ? "; secure" : "");
        }


function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  for(i=0; i < LI.length; i++){
    LI[i].onmouseover = function(){
      hover(this);
      if (dropdownrech)
        document.getElementById(dropdownrech).style.visibility = "hidden";
      if (dropdownrech2)
        document.getElementById(dropdownrech2).style.visibility = "hidden";
    }
    LI[i].onmouseout = function(){
      hover(this);
      if (dropdownrech)
        document.getElementById(dropdownrech).style.visibility = "visible";
      if (dropdownrech2)
        document.getElementById(dropdownrech2).style.visibility = "visible";
    }
  }
}

// Appellé pour chaque element Expandable
function Collapse(id){
  var elmt=document.getElementById(id);
  if (GetCookie(id) == "collapse") {
    elmt.children[1].className = "contentcollapse";
    elmt.children[0].className = "collapse";
  }

  if (GetCookie(id) == "expand") {
    elmt.children[1].className = "content";
    elmt.children[0].className = "expand";
  }

}
