// from: http://www.quirksmode.org/js/findpos.html
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 getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

// dip2: trigger functions for popup menu show and hide
function open_popup( obj, root_item ) {
	// die globalen vars hBarHeight und hBarOffset müssen bei der Menügenerierung
	// erzeugt werden.
	// Voraussetzung: die flag-var "menu_loaded" muss gesetzt worden sein

	if ( menu_loaded ) {
		ynew = findPosY(obj) - root_item * hBarHeight + hBarHeight + hBarOffset ; 
		moveRoot(0,ynew);
		pMenu.over('root', root_item );
	}
}

function close_popup( root_item ) {
	pMenu.out('root', root_item )
}

function moveRoot(xnew,ynew)
{
 if ( pMenu.menu.root[0].lyr ) {
	 with (pMenu.menu.root[0].lyr) {
	 	// x( xnew );
	 	y( ynew );
	 }
 }
}// end function moveRoot
