/* menu.js (accompanies menu.html)
Brian Davis
javascript menu with links

compatibility:
Tested on Internet Explorer 6 & Firefox 1.0.4
W3 Certification claims code will work on:
Netscape 7.0, Mozilla 1.0, Safari 1.0, Internet Explorer 5.0, Internet Explorer for Mac 5.2

Version Information
version 1.0 - completed 7/2/05
menu system with single-tier menus
*/ 

// Global Variables
var timeOn = null;

// Number of menus in the page
var maxMenus = 3;

var offColor = '#990000';
var onColor = '#FF0000';
/////////////////////////////////////////////////////////////////
function menuOut() 
{
	timeOn = setTimeout("hideAllMenus()", 1000);
}

function menuIn(menuNo)
{
	clearTimeout(timeOn);
	showMenu(menuNo);	
}

function hideAllMenus()
{
	for(var x = 1; x <= maxMenus; x++)
	{
		hideMenu(x);
	}
}

// Hides one menu based on the menu number passed
function hideMenu(menuNo)
{
	document.getElementById('menu' + menuNo).style.visibility = 'hidden';
}

function showMenu(menuNo)
{
	// Close all other menus
	hideAllMenus();

	//get root menu position

	// Get X Position - absolute
	xPos = document.getElementById('labelCell' + menuNo).offsetLeft;
	tempX = document.getElementById('labelCell' + menuNo).offsetParent;
	while (tempX != null)
	{
		xPos += tempX.offsetLeft;
  		tempX = tempX.offsetParent;
	}

	// Get Y Position - absolute
	yPos = document.getElementById('labelCell' + menuNo).offsetTop;
	tempY = document.getElementById('labelCell' + menuNo).offsetParent;
	while (tempY != null)
	{
		yPos += tempY.offsetTop;
  		tempY = tempY.offsetParent;
	}

	// Modify for borders
	xPos = xPos - 1;

	// Get Height of Parent
	parentHeight = document.getElementById('labelCell' + menuNo).offsetHeight;

	// Place menu
	
	document.getElementById('menu' + menuNo).style.top = (yPos + parentHeight) + 'px';
	document.getElementById('menu' + menuNo).style.left = xPos + 'px';	
	
	document.getElementById('menu' + menuNo).style.visibility = 'visible';
}

	