
startMenu = function() { 
    if (document.getElementById('mainmenu') != null)
    {
        var menu = document.getElementById('mainmenu');
        for (var i = 0; i < menu.rows[0].cells.length; i++)
        {
       	    var submenu = menu.rows[0].cells[i];
       	    var table = submenu.getElementsByTagName('TABLE')[1];
       	    if (table.rows.length > 0)
       	    {
	       	    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.onmouseover = submenu_mouseover;
	            submenu.onmouseout = submenu_mouseout;	       	    
       	    }
        }
    }
}

submenu_mouseover = function() { 
    var tbl = this.getElementsByTagName('TABLE')[1];
    tbl.style.position = 'absolute';
    tbl.style.left = findPosX(this) + 'px';
    tbl.style.top = (findPosY(this) + this.offsetHeight - 2) + 'px';
    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';
}

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;
}
