function show( elementID ) {
	var el = document.getElementById(elementID);
	if( el != null ) el.style.visibility = 'visible';
}

function hide( elementID ) {
	var el = document.getElementById(elementID);
	if( el != null ) el.style.visibility = 'hidden';
}

/** Menu DIVs **/
var menuDivTimeout = new Array();		// array to hold timeout references
function showMenu( index )
{
	clearTimeout(menuDivTimeout[parseInt(index)]);		// clear timeout for current menu
	var isIE = document.all?true:false;								// determine browser
	// retrieve menu header elements
	var parent = document.getElementById('menuTop' + index);
	// highlight selected menu header
	setClass(parent, 'menuTopHL');

	// retrieve menu content div and change settings if it exists
	var menuDiv = document.getElementById('menuDropDown' + index);
	if (menuDiv != null) {
		menuDiv.style.visibility = 'visible';		// show menu content div
		
		// find window scroll values
		var scroll = findWindowScrollXY();
		var scrollX = scroll[0];
		var scrollY = scroll[1];
		
		if (isIE) {
			// offsetTop doesn't work properly in IE so loop through parents to get real top value
			var yPos = parent.offsetTop;
			var temp = parent.offsetParent;
			while (temp != null) {
  				yPos += temp.offsetTop;
	  			temp = temp.offsetParent;
  			}
			menuDiv.style.top = yPos + parent.offsetHeight + 1 + 'px';		// move menu content div to below menu header
			
			// if menu content div is narrower than header resize accordingly
			if (menuDiv.offsetWidth < parent.offsetWidth + 2)
				menuDiv.style.width = parent.offsetWidth + 10 + 'px';
			
			// offsetLeft doesn't work properly in IE so loop through parents to get real left value
			var xPos = parent.offsetLeft;
			var temp = parent.offsetParent;
  			while (temp != null) {
  				xPos += temp.offsetLeft;
	  			temp = temp.offsetParent;
  			}
			menuDiv.style.left = xPos + parent.offsetWidth - menuDiv.offsetWidth + 1 + 'px';		// move menu content div to align right edge with header
			
			var xPos2 = menuDiv.offsetLeft;
			temp = menuDiv.offsetParent;
			while (temp != null) {
				xPos2 += temp.offsetLeft;
				temp = temp.offsetParent;
			}
			
			// if menu content div is going to disappear off the right of the visible page move it left accordingly
			if (xPos2 + menuDiv.offsetWidth - scrollX > document.body.clientWidth)
				menuDiv.style.left = document.body.clientWidth - menuDiv.offsetWidth + scrollX + 'px';
			
			// if menu content div is going to disappear off the left of the visible page move it right accordingly
			if (xPos2 < scrollX)
				menuDiv.style.left = scrollX + 'px';
		} else {
			// if menu content div is narrower than header resize accordingly
			if (menuDiv.offsetWidth < parent.offsetWidth + 2)
				menuDiv.style.width = parent.offsetWidth + 2 + 'px';
			
			// move menu content div to below menu header and aligned with the right edge
			menuDiv.style.top = parent.offsetTop + parent.offsetHeight + 1 + 'px';
			menuDiv.style.left = parent.offsetLeft + parent.offsetWidth - menuDiv.offsetWidth + 1 + 'px';
			
			// if menu content div is going to disappear off the right of the visible page move it left accordingly
			if (menuDiv.offsetLeft + menuDiv.offsetWidth - scrollX > window.innerWidth)
				menuDiv.style.left = window.innerWidth - menuDiv.offsetWidth - 20 + scrollX + 'px';
			
			// if menu content div is going to disappear off the left of the visible page move it right accordingly
			if (menuDiv.offsetLeft < scrollX)
				menuDiv.style.left = scrollX + 'px';
		}
	}
}
function hideMenu( index ) {
	// call menu close function after brief pause so menu doesn't
	// disappear as soon as the mouse pointer leaves the area
	menuDivTimeout[parseInt(index)] = setTimeout("hideMenuElements('" + index + "')", 200);
}
function hideMenuElements( index ) {
	// unhighlight the menu header elements
	setClass(document.getElementById('menuTop' + index), 'menuTop');
	hide('menuDropDown' + index);		// hide the menu content div
}
/** Menu DIVs end **/
