var timer = null;
var timerOn = false;
var menuIdIncrement = 0;

window.onload = init;

function init()
{
   var menu = document.getElementById('menu');
   
   for (var i = 0; i < menu.childNodes.length; i++)
      if (menu.childNodes[i].nodeName == 'UL')
         for (var j = 0; j < menu.childNodes[i].childNodes.length; j++)
            if (menu.childNodes[i].childNodes[j].nodeType == 1)
            {
               menu.childNodes[i].childNodes[j].onmouseover = showMenu;
               menu.childNodes[i].childNodes[j].onmouseout = hideMenu;
            }
}

function showMenu()
{
   var menu = document.getElementById('menu');

   for (var i = 0; i < menu.childNodes.length; i++)
      if (menu.childNodes[i].nodeName == 'UL')
         for (var j = 0; j < menu.childNodes[i].childNodes.length; j++)
            if (menu.childNodes[i].childNodes[j].nodeType == 1 && this != menu.childNodes[i].childNodes[j] && menu.childNodes[i].childNodes[j].childNodes[2])
               menu.childNodes[i].childNodes[j].childNodes[2].style.display = 'none';

   if (this.childNodes[2])
      this.childNodes[2].style.display = 'block';

   stopTime();
}

function hideMenu()
{
   if (!timerOn && this.childNodes[2])
   {
      this.childNodes[2].id = 'dmid' + menuIdIncrement++;
      timer = setInterval("document.getElementById('" + this.childNodes[2].id + "').style.display = 'none';", 600);
      timerOn = true;
   }
}

function stopTime()
{
   if (timer)
   {
      clearInterval(timer);
      timer = null;
      timerOn = false;
   }
}

