/* -------------------------------------------- Hover Over Functions -------------------------------------------- */

function initMenus()
{
  initMenu('menu');
}

function initMenu(containerDiv) {
/* Check we are dealing with IE */
  if (document.all && document.getElementById) {
    /* Deal with the main navigation */
    var nav = document.getElementById(containerDiv);
    if (nav) {
      var navItems = nav.getElementsByTagName('li');
      for (i = 0; i < navItems.length; i++) {
        var navItem = navItems[i];
        
        navItem.onmouseover = function() {
        
          /* If there are other classes applied
           * to the tag, add a space. Otherwise
           * just set "hover" as the only class
           */
           
          if ("" != this.className) {
            this.className += ' '; 
          }
            this.className = 'hover'; 
          }
        
        navItem.onmouseout = function() {
        
          /* Check to see if hover is the only
           * class applied to the tag. If so
           * clear the whole class name.
           * Otherwise search for " hover"
           * and remove it.
           */
           
          if ("hover" == this.className) {
            this.className = ''; 
          } else {
            this.className = this.className.replace(' hover', ''); 
          }
        }
      }
    }
  }
}


var timeout = true;

function initMenuScrollFix() {
/* Check we are dealing with Firefox */
  if (!document.all && document.getElementById) {
    /* Deal with the main navigation */
    var nav = document.getElementById('menu');
    if (nav) {
      nav.onmouseover = function() {
      
        var bodyContent = document.getElementById('body_content');
        bodyContent.style.overflow = 'hidden';
        
        var bodyContentPadding = document.getElementById('body_content_padding');
        if (bodyContentPadding)
        {
          bodyContentPadding.style.paddingRight = '16px';
        }
         
        timeout = false;

      }
      
      nav.onmouseout = function() {
      
         timeout = true;
         /* The setTimeout function is used so that
            the body_content doesn't flicker. If the user
           hasn't selected another menu item after 10 milliseconds
           the body_content will revert back to the normal
           overflow: auto; */
         setTimeout('setBodyContentAuto()', 10);

      }
    }
  }
}

function setBodyContentAuto()
{
  if (timeout)
  {
    var bodyContent = document.getElementById('body_content');
    bodyContent.style.overflow = 'auto';
    
    var bodyContentPadding = document.getElementById('body_content_padding');
    if (bodyContentPadding)
    {
      bodyContentPadding.style.paddingRight = '0';
    }
  }
}
