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';
}

function appearBlock( elementID ) {
	var el = document.getElementById(elementID);
	if( el != null ) {
		show( elementID );
		el.style.display = 'block';
	}
}

function appearInline( elementID ) {
	var el = document.getElementById(elementID);
	if( el != null ) {
		show( elementID );
		el.style.display = 'inline';
	}
}

function disappear( elementID ) {
	var el = document.getElementById(elementID);
	if( el != null ) {
		hide( elementID );
		el.style.display = 'none';
	}
}

/** 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 element
	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
			
			// 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 /*- 10*/ + 'px';		// move menu content div to align right edge with header
			
			// if menu content div is narrower than header resize accordingly
			if (menuDiv.offsetWidth < parent.offsetWidth)
				menuDiv.style.width = parent.offsetWidth + 'px';
			
			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';

			// add transparent iframe to position underneath menu div and over windowed elements such as select lists
			// this fixes a bug in IE6 where 'windowed' elements don't follow z-index rules as expected
			var ie6fix = document.getElementById('IE6FixIframe' + index);
			if(ie6fix == null) {
				menuDiv.insertAdjacentHTML('afterEnd', '<iframe id="IE6FixIframe' + index + '" class="IE6FixIframe" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
				ie6fix = document.getElementById('IE6FixIframe' + index);
			}
			ie6fix.style.top = menuDiv.style.top;
			ie6fix.style.left = menuDiv.style.left;
			ie6fix.style.width = menuDiv.offsetWidth;
			ie6fix.style.height = menuDiv.offsetHeight;
			ie6fix.style.visibility = 'visible';
		} else {
			// 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 /*- 10*/ + 'px';
			
			// if menu content div is narrower than header resize accordingly
			if (menuDiv.offsetWidth < parent.offsetWidth)
				menuDiv.style.width = parent.offsetWidth - 5 + '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
	// hide the transparent iframe used to fix IE6 bug
	var ie6fix = document.getElementById('IE6FixIframe' + index);
	if(ie6fix != null) ie6fix.style.visibility = 'hidden';
}
/** Menu DIVs end **/

/** Tooltips **/
function showTip( tipID, e )
{
	var isIE = document.all?true:false;
	var ttip = document.getElementById(tipID);
	ttip.style.visibility = 'visible';
	if (isIE) {
		ttip.style.top = document.body.scrollTop + window.event.clientY + 20 + 'px';
		ttip.style.right = document.body.offsetWidth - window.event.clientX + 'px';
		if (ttip.offsetTop + ttip.offsetHeight > document.body.scrollTop + document.body.offsetHeight - 20) {
			ttip.style.top = document.body.scrollTop + document.body.offsetHeight - ttip.offsetHeight - 20 + 'px';
			if(ttip.offsetTop < document.body.scrollTop) {
				ttip.style.top = document.body.scrollTop + 5 + 'px';
			}
		}
		if(ttip.offsetLeft < document.body.scrollLeft) {
			ttip.style.right = document.body.offsetWidth - ttip.offsetWidth - 15 + 'px';
		}
	} else {
		ttip.style.top = e.pageY + 20 + 'px';
		ttip.style.right = window.innerWidth - e.pageX + 'px';
		if (ttip.offsetTop + ttip.offsetHeight > window.pageYOffset + window.innerHeight - 20) {
			ttip.style.top = window.pageYOffset + window.innerHeight - ttip.offsetHeight - 20 + 'px';
			if(ttip.offsetTop < window.pageYOffset) {
				ttip.style.top = window.pageYOffset + 5 + 'px';
			}
		}
		if(ttip.offsetLeft < window.pageXOffset) {
			ttip.style.right = window.innerWidth - ttip.offsetWidth - window.pageXOffset - 15 + 'px';
		}
	}
}
function hideTip( tipID ) { hide(tipID); }
/** Tooltips end **/
