﻿
function showPopupMenu(layerId, parentMenu, offsetX, offsetY)
{
	var parentMenuObj = document.getElementById(parentMenu);
	var popupObj = document.getElementById(layerId);
    var offsetX =0;
    var offsetY =12;
	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;
}

function preloadImages()
	{
		var d = document;
		if(d.images)
		{
			if(!d.MM_p)
			{
				d.MM_p = new Array();
				var i,j = d.MM_p.length;
				var a = preloadImages.arguments;
				for(i = 0; i < a.length; i++){
					if (a[i].indexOf("#") != 0)
					{
						d.MM_p[j] = new Image;
						d.MM_p[j++].src = a[i];
					}
				}
			}
		}
	}

function openDialog(theURL, theName, Width, Height)
{
	var strValue;
	var strAppName = navigator.appName;
	var intLeft = parseInt((screen.width - Width) / 2);
	var intTop = parseInt((screen.height - Height) / 2);
	if(strAppName == 'Microsoft Internet Explorer')
		strValue = window.showModalDialog(theURL, theName, 'scroll:no;status:no;help:no;dialogHeight:' + Height + 'px;dialogWidth:' + Width + 'px;dialogLeft:' + intLeft + ';dialogTop:' + intTop + ';')
	else
		window.open(theURL, theName, 'width=' + Width + ',height=' + Height + ',left=' + intLeft + ',top=' + intTop + ',scrollbars=yes');
	return strValue;
}