var t = false;
var current;
function SetupMenu()
{
   if (!document.getElementsByTagName) return;
   items = document.getElementsByTagName("li");
   
   for(i = 0; i < items.length; ++i)
   {
      if(items[i].className != "menu")
      {
        continue;
      }//if
     
      //set up event handlers
      thelink = findChild(items[i], "A");
      thelink.onmouseover = ShowMenu;
      thelink.onmouseout = StartTimer;
      
      //is there a submenu?
      
      if(ul = findChild(items[i], "UL"))
      {
        ul.style.display = "none";
        
        for(j = 0; j < ul.childNodes.length; ++j)
        {
           ul.childNodes[j].onmouseover=ResetTimer;
           ul.childNodes[j].onmouseout=StartTimer;
        }
      }//if
    }//out for
}
function findChild(obj, tag)
{
  cn = obj.childNodes;
  if(!cn)
  {
     return false;  //added JPB 5-21-09
  }

  for(k = 0; k < cn.length; ++k)
  {
     if (cn[k].nodeName == tag)
     {
       return cn[k];
     }
  }//for
  return false;
}
function ShowMenu(e)
{
   if(!e)
   {
      var e = window.event;
   }
   
   if(e.target)
   {
     thislink = e.target;
   }
   else
   {
     thislink = e.srcElement;
   }
   
   ResetTimer();
   
   //hide previous menu, if any
   if (current)
   {
      HideMenu(current);
   }
   
   thislink = thislink.parentNode;
   current = thislink;
   
      // find the submenu, if any
   ul = findChild(thislink,"UL");
   if (!ul) return;
   ul.style.display="block";
}
function HideMenu(thelink)
{
   //find the submenu if any
   ul = findChild(thelink, "UL");
   if (!ul)
   {
      return;
   }
   ul.style.display = "none";
}
function ResetTimer()
{
   if (t)
   {
      window.clearTimeout(t);
   }
}
function StartTimer()
{
   t = window.setTimeout("HideMenu(current)", 200);
}
//set up the menu when the page loads
window.onload = SetupMenu;