	function getXPosition(x,obj)
	{
		if(obj)
		{
			x=x+obj.offsetLeft;
			x=getXPosition(x,obj.offsetParent);
			return x;
		}
		else
		{
			return x;
		}
	}

	function getYPosition(x,obj)
	{
		if(obj)
		{
			x=x+obj.offsetTop;
			x=getYPosition(x,obj.offsetParent);
			return x;
		}
		else
		{
			return x;
		}
	}

	function doPopUp(obj,but) 
	{
		bdy = document.getElementById('BODYTag');
		mainWidth=bdy.offsetWidth;
		mainHeight=bdy.offsetHeight;
		// Make the object visible so that it has size.
		document.getElementById(obj).style.display="inline";

		// Get the accumulated offset position for the activating object
		xPos=getXPosition(0,but);
		yPos=getYPosition(0,but);
		
		// If the resulting right edge is greater than the main width then align right instead of left
		//alert("MainWidth:"+mainWidth);
		//alert("xPos:"+xPos);
		//alert("ImageWidth:"+document.getElementById(obj).offsetWidth);
		//alert("ButtonWidth"+but.offsetWidth);
	if(xPos+document.getElementById(obj).offsetWidth>mainWidth)
		{
			document.getElementById(obj).style.left=xPos-document.getElementById(obj).offsetWidth+but.offsetWidth;
		}
		else
		{
			newLeft=xPos+but.offsetWidth;
			document.getElementById(obj).style.left=newLeft;
		}
		
		// If the resulting top edge is less than zero then align bottom instead of top
		if(yPos+but.offsetHeight-document.getElementById(obj).offsetHeight>0)
		{
				document.getElementById(obj).style.top=yPos+but.offsetHeight-document.getElementById(obj).offsetHeight;		
		}
		else
		{
				if(yPos+document.getElementById(obj).offsetHeight>mainHeight)
				{
					document.getElementById(obj).style.top=mainHeight-document.getElementById(obj).offsetHeight;		
				}
				else
				{
					//document.getElementById(obj).style.top=yPos-document.getElementById(obj).offsetHeight;
					document.getElementById(obj).style.top=yPos;
				}
		}
		//document.getElementById(obj).style.display="inline";
		document.getElementById(obj).style.visibility="visible";
	}

	function unDoPopUp(obj) 
	{
		document.getElementById(obj).style.display="none";
		document.getElementById(obj).style.visibility="hidden";
	}

	function bodyOffsetHeight() 
	{
		bdy = document.getElementById('BODYTag');
		alert('Height:'+bdy.offsetHeight);
		tbl = document.getElementById('tableDetail');
		alert('Top:'+getYPosition(0,tbl));
		ftr = document.getElementById('footer');
		alert('Footer height:'+ftr.offsetHeight);
		alert('Table height:'+tbl.style.height);
	}

