// menufix.js - Fixes for drop down menu based on Son of Suckerfish.

// IE: Mimics 'hover' pseudo-class. IE7 supports hover on non-links only in strict mode; IE6 on links only. http://msdn.microsoft.com/en-us/library/ms530766(VS.85).aspx
// Safari: ...

function menuFix()
{
  var sfEls = document.getElementById("nav").getElementsByTagName("li");
  
  for (var i=0; i < sfEls.length; i++) 
  {
    sfEls[i].onmouseover = function() 
    {
      if (navigator.userAgent.indexOf('Safari') >= 0)
      {
        mouseOver(this.id);
      }
      
      // http://msdn.microsoft.com/en-us/library/cc817582.aspx
      if (navigator.appName == 'Microsoft Internet Explorer')
      {
         // For us, className = "".
         this.className = "sfhover";  // #nav li.sfhover is set in css
         //this.className = (this.className.length > 0 ? " ": "") + "sfhover";
      }
    }
    
    sfEls[i].onmouseout = function() 
    {
      if (navigator.userAgent.indexOf('Safari') >= 0) 
      {
        mouseOut(this.id);
      }
      
      if (navigator.appName == 'Microsoft Internet Explorer')
      {
         // Revert className to "" (it's value before onmouseover changed it).
         this.className = "";
         //this.className = this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
      }
    }
  }
}

// Bind menuFix to page load event.
if (window.addEventListener)      // DOM
    window.addEventListener("load", menuFix, false);
else if (window.attachEvent)      // IE exclusive
         window.attachEvent("onload", menuFix);
else if (document.getElementById) // older modern browsers
         window.onload = menuFix;
