var isNS4=document.layers?true:false;
var isIE= document.all ?true:false;
var isIE6=isIE&&document.getElementById?true:false;
var isIE4=isIE&&!isIE6?true:false;
var isNS6=!isIE6&&document.getElementById?true:false;
var isNS=isNS4||isNS6;
var agt=navigator.userAgent.toLowerCase();
var isOnlyIE = (agt.indexOf("msie") != -1) ? true:false;
var isOpera = (agt.indexOf("opera") != -1) ? true:false;


function getForm() { return (isIE) ? document.frmeMap : document.forms["frmeMap"]; }
function isNull(obj) { return ((obj == null) || (typeof(obj) == "undefined")); }
function getBtnLeft(evt) { return (isOnlyIE) ? (evt.button == 1) : (evt.which == 1);}
function getBtnRight(evt) { return (isOnlyIE) ? (evt.button == 2) : (evt.which  == 3); }
function getElement(id)  { return (document.getElementById) ? document.getElementById (id) : document.all(id); }
function getImage(id) { return (document.images) ? document.images[id] : getElement(id); }
function getAbsX (e) { 	return e.clientX; }
function getAbsY (e) { 	return e.clientY; }
function getOffsetX(e, obj) { return getAbsX(e) - findPosX(obj); }
function getOffsetY(e, obj) { return getAbsY(e) - findPosY(obj); }
function setWidth (obj, w) { if (!isNull(obj)) obj.style.width= w + "px"; }
function setHeight (obj, h) { if (!isNull(obj)) obj.style.height= h + "px"; }

function setLeft (obj, l)
{
	if (isNull(obj)) return;
	if (isIE) obj.style.pixelLeft= l; else obj.style.left= l+ 'px';
}

function setTop (obj, t)
{
	if (isNull(obj)) return;
	if (isIE) obj.style.pixelTop= t; else obj.style.top= t + 'px';
}

function getTarget(evt)
{
	var target;
	if (evt.srcElement) 
		target = evt.srcElement; 
	else if( evt.target) 
		target = evt.target; 
	return target;
}	

function setVisible (obj , visible)
{
	if (isNull(obj)) return;
	if (visible)
	{
		obj.style.display = "block";
		obj.style.visibility = "visible";
	} 
	else
		obj.style.visibility = "hidden";
}

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 doStopWaiter()
{
	var theform = getForm();
	if (document.images) 
	{
		setVisible (getElement ("divWaiter"), false);
		setVisible (getImage ("Waiter"), false);
		setVisible (getImage("WaiterVertical"), false);
	}
}

function doWaiter() 
{ 
	var theform = getForm();
	if (document.images) 
	{
		var divwaiter = getElement ("divWaiter");
		var imgwait = getImage("imgWaiter");
		if (imgwait != null) 
		{
			setVisible (imgwait, true);
			setLeft (imgwait, 0);
			setTop (imgwait, 0);
			imgwait.src = imgwait.src; //starts the stopped animation (produced by the click i guess?) 
		}
		
		if (divwaiter != null)
		{
			var oParent = getElement ("tblEMAP");
			if (oParent != null)
			{
				var x = findPosX(oParent) + ((oParent.clientWidth-divwaiter.clientWidth) / 2);
				setLeft(divwaiter, x);
				var y = findPosY(oParent) + ((oParent.clientHeight-divwaiter.clientHeight) / 2);
				setTop (divwaiter, y);
				setVisible (divwaiter, true);
			} 
		}
	} 
} 

function showInfo  (text) { var oInfo = getElement ("spanInfo");  if (!isNull(oInfo)) oInfo.innerHTML = text; }
function showDebug (text) { var oInfo = getElement ("spanDebug"); if (!isNull(oInfo)) oInfo.innerHTML = text; }





