var Hover = function(navBar)
{
	var me = this;
	me.items = navBar.select("ul")[0].childElements();
  me.items.each(function(item) { me.initItem(item); });
}

Hover.prototype.initItem = function(item)
{
	var me = this;
	item.onmouseover = function() 
	{
    me.closeAllExcept(item);
    clearTimeout(me.closeTimeout);
    me.openTimeout = setTimeout(function() 
    {
    item.addClassName('over');
    item.setStyle({
      zIndex: 100
      });
    }, Hover.OPEN_TIMEOUT);
	};
	
  item.onmouseout = function() 
  { 
   clearTimeout(me.openTimeout);
   me.closeTimeout = setTimeout(function()
   {
     item.removeClassName('over');
   }, Hover.CLOSE_TIMEOUT);
  };
}

Hover.prototype.closeAllExcept = function(exceptItem)
{
 this.items.each(function(item) 
 { 
   if (item != exceptItem)
    item.removeClassName('over');
 });
}

Hover.OPEN_TIMEOUT  = 50;
Hover.CLOSE_TIMEOUT = 500;


document.observe("dom:loaded", function() {
  // initially hide all containers for tab content
new Hover($("menu"));
})
