
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;
}


function position_menu(){
	var main_div = document.getElementById('main');
	var main_y = findPosY(main_div);
	var main_x = findPosX(main_div);
	//alert('y: '+main_y+'px - x:'+main_x+'px');
	
	var menu_y = main_y + 33;
	var menu_x = main_x + 0;
	var menu_div = document.getElementById('submenu_pf');
	menu_div.style.top = menu_y;
	menu_div.style.left = menu_x;
	//salert('y: '+menu_y+'px - x: '+menu_x+'px');
	
	//menu_div.style.visibility = "visible";
}


activateMenu = function(nav) {
position_menu();
    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
    }
	var menu_div = document.getElementById('submenu_pf');
	menu_div.style.visibility = "visible";
}
window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
    activateMenu('nav'); 
   //activateMenu('vertnav'); 
}
