

﻿function showPopupMenu(layerId, parentMenu, offsetX, offsetY)
{
	var parentMenuObj = document.getElementById(parentMenu);
	var popupObj = document.getElementById(layerId);
    var offsetX =10;
    var offsetY =22;
	popupObj.style.left = getAbsX(parentMenuObj) + offsetX;
	popupObj.style.top = getAbsY(parentMenuObj) + offsetY;
	popupObj.style.visibility = "visible";
	popupObj.style.display = "inline";
}

function hidePopupMenu(layerId)
{
	var popupObj = document.getElementById(layerId);

	popupObj.style.visibility = "hidden";
}

function getAbsX(obj) //gets absolute X coordinate of an object
{
	var leftOffset = 0;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			leftOffset += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) //for Netscape v.4
	{
		leftOffset = obj.x;
	}
	return leftOffset;
}
          
function getAbsY(obj) //gets absolute Y coordinate of an object
{
	var topOffset = 0;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			topOffset += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) //for Netscape v.4
	{
		topOffset = obj.y;
	}
	return topOffset;
}
