var m_curPopupId = "";		// id of any open popup, or ""

// popupId should be a div with class "popupmenu"
// which means visibility = hidden (and borders, etc)
function activatePopup(popupId, linkObj) {
	var popup = getRawObject(popupId);
	
	if (popup.style.visibility == "visible") {
		// Close popup if trying to activate a second time...
		closeCurrentPopup();
		return;
	}

	// Close already-open popup first
	closeCurrentPopup();

	// Place the popup near the "link" that opened it
	var linkPos = getObjectPos(linkObj);
	var linkSize = getObjectSize(linkObj);

	popup.style.top = (linkPos.top + linkSize.height + 2) + "px";
	popup.style.left = (linkPos.left - 10) + "px";
	
	popup.style.visibility = "visible";
	
	m_curPopupId = popupId;
}

function closeCurrentPopup() {
	if (m_curPopupId != "") {
		getRawObject(m_curPopupId).style.visibility = "hidden";
		m_curPopupId = "";
	}
}

function getActivePopup() {
	return m_curPopupId;
}