startMenu = function() { 
    if (document.getElementById('mainmenu') != null)
    {
        var menu = document.getElementById('mainmenu');
        for (var i = 0; i < menu.cells.length; i++)
        {
       	    var submenu = menu.cells[i];
	        var tables = submenu.getElementsByTagName('TABLE');
	        if (tables.length >= 2)
	        {
       	        submenu.onmouseover = submenu_mouseover;
                submenu.onmouseout = submenu_mouseout;
       	        var table = tables[1];
       	        for (var j = 0; j < table.rows.length; j++)
       	        {
       	    	    table.rows[j].cells[0].className = 'menuitem';
       	    	    table.rows[j].cells[0].onmouseover = cell_mouseover;
       	    	    table.rows[j].cells[0].onmouseout = cell_mouseout;       		
       	        }
       	    }
        }
    }
}

submenu_mouseover = function() { 
    var tables = this.getElementsByTagName('TABLE');
    var tbl = tables[1];
    tbl.style.position = 'absolute';
    tbl.style.pixelLeft = findPosX(this);
    tbl.style.pixelTop = findPosY(this) + this.offsetHeight - 2;
    tbl.style.display = 'block';
    tbl.style.zIndex = 100;
}

submenu_mouseout= function() 
{ 
    this.getElementsByTagName('TABLE')[1].style.display = 'none'; 
}

cell_mouseover = function()
{
	this.className = 'menuitemHilite';
}

cell_mouseout = function()
{
	this.className = 'menuitem';
    this.parentElement.parentElement.parentElement.parentElement.childNodes[0].className = 'submenu';
}

if (window.attachEvent)
    window.attachEvent("onload", startMenu)
else
    window.onload=startMenu;

		function findPosX(obj)
		{
			var curleft = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			}
			else if (obj.x)
				curleft += obj.x;
			return curleft;
		}

		function findPosY(obj)
		{
			var curtop = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			}
			else if (obj.y)
				curtop += obj.y;
			return curtop;
		}
