var doc 	= document;
var oDbg	= new Object();
var bIE		= (doc.all) ? true : false;

function showVoyageInfoPopup(oEvent, oObject, iVoyageID, bShow) 
{
	sStatus = 'bShow = '+bShow;
  var iPadding = 20;
  aMousePos = getMouseXY(oEvent, oObject);
  oDiv = doc.getElementById('trip_'+ iVoyageID);

	var iPopupHeight = 200;
	var iPopupWidth  = 300;
  var iScreenHeight = window.screen.height;
  
  if(doc.innerHeight)
  {
  	iScreenHeight = doc.innerHeight;
	}
	else if(doc.documentElement.clientHeight)
	{
		iScreenHeight = doc.documentElement.clientHeight;
	}
	else if(doc.body)
	{
		iScreenHeight = doc.body.clientHeight;
	}

	var iMouseTop = aMousePos["Y"] + iPadding;
	var iMouseLeft = aMousePos["X"] + iPadding;

	if (iMouseTop > 0 && iMouseLeft > 0)
	{
		var iPopupBottomPos = iMouseTop + iPopupHeight;

		if (iPopupBottomPos > iScreenHeight)
			iTop = iScreenHeight - iPopupHeight - 2;
		else
			iTop = iMouseTop;
		iLeft = iMouseLeft;

  	oDiv.style.top = iTop +'px';
  	oDiv.style.left  = iLeft +'px';

  	if (bShow && oDiv.style.visibility != 'visible')
  	{
			oDiv.style.visibility = 'visible';
		}
		else
		{
			oDiv.style.visibility = 'hidden';
		}    
	}
}

/* 
**	2007-03-22 Mark - Method .clientX/Y works under in IE6+, FF1+, Opera9+ and is W3C
**									- Rewrote function partly
**									- Added parameter oEvent, FF needs it :)
*/
function getMouseXY(oEvent, oObject)
{
	var aCursor = new Array;

	aCursor["X"] = oEvent.clientX;
	aCursor["Y"] = oEvent.clientY;

	oDbg = doc.getElementById('dbg_mouseXY');
	if (oDbg)
		oDbg.innerHTML = aCursor["X"] + ' - ' + aCursor["Y"];

	// Catch possible negative values in NS4
	if (aCursor["X"] < 0)
		aCursor["X"] = 0;

	if (aCursor["Y"] < 0)
		aCursor["Y"] = 0;

	return aCursor;
}
