var objPopUp = null;
var popMenuOn = 0;

function popUp(evt,objectID) {
	if (popMenuOn == 1) popHide();
	document.onclick = popHide;
	var evt = (evt) ? evt : ((window.event) ? event : null);
	objPopUp = document.getElementById(objectID);
	if (document.layers) {
		xPos = evt.x + window.pageXOffset;
		yPos = evt.y + window.pageYOffset;
	} else if (document.all) {
		xPos = event.clientX + document.body.scrollLeft;
		yPos = event.clientY + document.body.scrollTop;
	} else if (document.getElementById) {
		xPos = evt.clientX + window.pageXOffset;
		yPos = evt.clientY + window.pageYOffset;
	}
	if (xPos + objPopUp.offsetWidth > document.body.clientWidth) xPos = xPos - objPopUp.offsetWidth;
	if (yPos + objPopUp.offsetHeight > document.body.clientHeight) yPos = yPos - objPopUp.offsetHeight;
	objPopUp.style.left = xPos + 'px';
	objPopUp.style.top = yPos + 'px';
	objPopUp.style.visibility = 'visible';
}

function popHide() {
	if (popMenuOn == 0) {
		popMenuOn = 1;
		return
	} else {
		objPopUp.style.visibility = 'hidden';
		objPopUp = null;
		popMenuOn = 0;
		document.onclick = null;
	}
}