﻿// Fichier JScript

    var menuBackground;
    var menuHighLight = 'rgb(228,228,228)';
    //var coTypeSubMenuPosition = 0;
    var menuSelected = null
    
    var showtimeoutID=false;
    var hidetimeoutID=false;
    var hidetimeoutsubID=false;
    function showSubMenuV(me){
      showSubMenu(me, true,0)
    }
    function showSubMenuH(me){
     showSubMenu(me, false,0)
    }
    
    function showSubMenuDelayH(me){
      clearTimeout(hidetimeoutID);
      clearTimeout(showtimeoutID);
      hideAllOthersLis(me);
      showtimeoutID=setTimeout(function(){showSubMenu(me, false,0)},300);
    }

    function showSubMenu(me, isV, coTypeSubMenuPosition) {
      // highlight current item
      //menuBackground = me.style.backgroundColor;
      //me.style.backgroundColor = menuHighLight;

      // get sub menu
      var submenu = me.getElementsByTagName('ul')[0];
      if (submenu) {

        // workaround for windowed select object bug
        // that ignores zindex values
        submenu.style.display='block';
        
        if(coTypeSubMenuPosition == 2){
            submenu.style.position='relative';
            submenu.style.left = 0;
            return 
        }
      }
    }
    
    function changeMenu(me, isV) {
      var submenu = me.getElementsByTagName('ul')[0];
      if(submenu && submenu.style.display=='block')
        hideSubMenu(me,2)
      else  
      {
        if(menuSelected!=null)
            hideSubMenu(menuSelected,2)
        showSubMenu(me, isV,2)        
        menuSelected=me
      }
    }
    
    function hideSubMenu(me) {
        hideSubMenu(me,0);
    }
    
    function hideSubMenuDelay(me) {
        clearTimeout(showtimeoutID);
        clearTimeout(hidetimeoutID);
        hidetimeoutID=setTimeout(function(){hideSubMenu(me,0)}, 100);
    }
    
    
    function hideSubMenu(me,coTypeSubMenuPosition) {
      // restore background
      me.style.backgroundColor = menuBackground;

      // hide submenu
      var submenu = me.getElementsByTagName('ul')[0];
      if (submenu) {
        submenu.style.display='none';
        if(coTypeSubMenuPosition == 2)
            return 
      }
    }
    
    function hideAllOthersLis( currentUl )
    {
        var uls = currentUl.parentNode;
        for ( var i=0; i<uls.childNodes.length; i++ )
        {
            if ( uls.childNodes[i].nodeName=='LI' && uls.childNodes[i]!= currentUl)
            {
                hideSubMenu( uls.childNodes[i],0 );
            }
        }
    }

