var currentMenu = null;

if (!document.getElementById)
    document.getElementById = function() { return null; }

var offMenu = -1;

function closeMenu () {
	if (currentMenu)
	{
        	currentMenu.style.visibility = "hidden";
        	currentMenu = null;
	}
}

function initializeMenu(name) {
    var menu = document.getElementById(name);
    for (var o = menu.firstChild; o;  o = o.nextSibling)
    {
	if (o.tagName == 'LI' && o.className == 'menuDrop')
		initializeSubMenu (o);
    }
}

function initializeSubMenu (o) {
    var submenu = o.getElementsByTagName('ul')[0];
    var actuator = o.getElementsByTagName('a')[0];

    if (submenu == null || actuator == null) return;

    actuator.onmouseover = function() {
        if (currentMenu) {
            currentMenu.style.visibility = "hidden";

            currentMenu = null;
	    if (offMenu >= 0)
	    {
		t = offMenu;
		offMenu = -1;
		clearTimeout(t);
	    }
        }

        this.showMenu();
    }
  
    actuator.onmouseout = function() {
	offMenu = setTimeout('closeMenu()', 250); //
    }

    actuator.showMenu = function() {
	var x = this.offsetLeft;
	var y = this.offsetTop;
	for (var o = this; o.offsetParent && this != o.offsetParent;
			o = o.offsetParent)
	{
		x += o.offsetParent.offsetLeft;
		y += o.offsetParent.offsetTop;
	}
        submenu.style.left = x + "px";
        submenu.style.top = y + this.offsetHeight + "px";
        submenu.style.visibility = "visible";
        currentMenu = submenu;
    }

    submenu.onmouseover = function() {
	if (offMenu >= 0)
	{
		t = offMenu;
		offMenu = -1;
		clearTimeout(t);
	}
    }

    submenu.onmouseout = function() {
	offMenu = setTimeout('closeMenu()', 250); //
	return false;
    }
}
