var menuLeft = 0;
var menuTop = 0;
var domMenu = null;
var domSubMenuContent = null;
var domSubMenuContainer = null;
var domSubMenuContainerStyle = null;
var pause = 500;
var popTimer;
var popTimer2;
var popDisplay = "";
var menuId;
var subMenuContentId;
var subMenuContainerId;
var posType;
var evt;

function popMenuShow(){
	clearTimeout(popTimer2);
	if (popDisplay == "show") {

///// This function generates a popup submenu/tooltip in response to an event on the page
///// The contents of the popup are copied from HTML paragraphs on the page
///// The initial visibility of the popup contents is controlled by CSS
///// The popup display is also controlled by CSS
///// ------------------------------------------------------------------------------------
///// menuId is the id of the object calling the popup menu
///// subMenuContentId is the id of a <div> tag surrounding the paragraphs of popup content
///// subMenuContainerId is the id of a <div> tag that determines all display aspects of the popup
///// posType determines how the popup is positioned
/////   posType = 0 means the popup is being called from an event on an unpositioned element,
/////             such as a link, so the mouse screen location must be used
/////   posType = 1 means the popup is being called from an event on a horizontal menu
/////   posType = 2 means the popup is being called from an event on a vertical menu
///// evt is needed when posType=0 so that the mouse location can be determined
///// ------------------------------------------------------------------------------------
		if (isDHTML) {
	
			///// Immediately hide any previous instance of the popup
			clearTimeout(popTimer);
			if (domSubMenuContainerStyle) {
				domSubMenuContainerStyle.visibility = 'hidden'; 
				domSubMenuContainerStyle.zIndex = '0';
				domSubMenuContainerStyle = null; 
			}

			if (posType == 0) {
				///// Find position of mouse over object that has called the popup menu
				menuLeft = findPageXCoord(evt);
				menuTop = findPageYCoord(evt);
			} 
			if (posType == 1) {
				///// Find position of calling container in horizontal menu, then add height of container
				// DL_ functions are in findDOM.js
				menuLeft = DL_GetElementLeft(findDOM(menuId, 0)) + 5;
				menuTop = DL_GetElementTop(findDOM(menuId, 0)) + findHeight(menuId);

			}
			if (posType == 2) {
				///// Find position of calling container in vertical menu, then add width of container
				// DL_ functions are in findDOM.js
				menuLeft = DL_GetElementLeft(findDOM(menuId, 0)) + findWidth(menuId) - 10;
				menuTop = DL_GetElementTop(findDOM(menuId, 0));
			}
		
			///// Defines the DOMs of the menu objects
			domMenu = findDOM(menuId,0);
			domSubMenuContent = findDOM(subMenuContentId,0);
			domSubMenuContainer = findDOM(subMenuContainerId,0);
			domSubMenuContainerStyle = findDOM(subMenuContainerId,1);
		
			///// Get the submenu HTML content and place it in the submenu container
			domSubMenuContainer.innerHTML = domSubMenuContent.innerHTML;

			////  Check dimensions of the submenu
			var subMenuWidth = findWidth(subMenuContainerId);
			var subMenuHeight = findHeight(subMenuContainerId);
			
			//// Make sure submenu does not go beyond visible page
			if (menuLeft + subMenuWidth > findLivePageWidth()){
				////  Change menuLeft so that menu does not go beyond right of page
				menuLeft = findScrollLeft() + findLivePageWidth() - subMenuWidth;
			}
			if (menuTop + subMenuHeight - findScrollTop() > findLivePageHeight()){
				////  Change menuTop so that menu does not go beyond bottom of page
				menuTop = findScrollTop() + findLivePageHeight() - subMenuHeight;
			}
			///// show the submenu
			domSubMenuContainerStyle.left = menuLeft; 
			domSubMenuContainerStyle.top = menuTop;
			domSubMenuContainerStyle.visibility = 'visible';
			domSubMenuContainerStyle.zIndex = '100';
		}

		else { 
			////// Returns a 'null' value for non-DHTML Browsers 
			return null;
		}
	}
}

function popMenuHide() {
	clearTimeout(popTimer);
	if ((domSubMenuContainerStyle) && (popDisplay == "hide")) {
		domSubMenuContainerStyle.visibility = 'hidden'; 
		domSubMenuContainerStyle.zIndex = '0';
		domSubMenuContainerStyle = null; 
	}
}

function delayShow(va,vb,vc,vd,ve) {
	menuId = va;
	subMenuContentId = vb;
	subMenuContainerId = vc;
	posType = vd;
	evt = ve;
	popTimer2 = setTimeout("popMenuShow()", pause);
}

function delayHide() {
	popTimer = setTimeout("popMenuHide()", pause)
}
