var menu_hover_old_onload = window.onload ? window.onload : function() {};

var menu_hover_current = null;
var menu_hover_timeout = null;

function menu_hover_change(dest)
{
  if (menu_hover_timeout) {
    clearTimeout(menu_hover_timeout);
    menu_hover_timeout = null;
  }
  if (menu_hover_current == dest) return;
  if (menu_hover_current) {
    menu_hover_current.className = menu_hover_current.className.replace(" hover", "");
  }
  if (dest) {
    dest.className += " hover";
  }
  menu_hover_current = dest;
}

function menu_hover_onload()
{
  if (!document.getElementById) return;
  
  var menu = document.getElementById("t_menu");
  var children = menu.childNodes;
  for (var i = 0; i < children.length; i++) {
    var node = children[i];
    if (node.className && node.className.indexOf("menu_tab") != -1) {
      var old_onmouseover = node.onmouseover ? node.onmouseover : function() {};
      node.onmouseover = function() {
        old_onmouseover();
        menu_hover_change(this);
      }

      var old_onmouseout = node.onmouseout ? node.onmouseout : function() {};
      node.onmouseout = function() {
        old_onmouseout();
        if (menu_hover_timeout) clearTimeout(menu_hover_timeout);
        menu_hover_timeout = setTimeout('menu_hover_change(null);', 1000);
      }
    }
  }
}

window.onload = function() {
  menu_hover_onload();
  menu_hover_old_onload();
}
