// add the initialization function to be run when the site opens
if(window.addEventListener)
{
    window.addEventListener("load",init,true);
}
else
{
    window.attachEvent("onload",init);
}

function init()
{
  var navElements = document.getElementById("main-nav").getElementsByTagName("li");
  
  for(i=0; i < navElements.length; i++)
  {
    if(navElements[i].id)
    {
      navElements[i].onmouseover = showSubNav;
      navElements[i].onmouseout = hideSubNav;
    }
  }
}

function showSubNav(event)
{
    var shownMenu = this.id+"-list";
    shownMenu = document.getElementById(shownMenu);
    
    if(shownMenu.style.display != "block")
    {
     shownMenu.style.display = "block";
    }
}

function hideSubNav(event)
{
    var shownMenu = this.id+"-list";
    shownMenu = document.getElementById(shownMenu);
    if(shownMenu)
    {
     shownMenu.style.display = "none";
    }
}
