<!--

/*
Name: 		Slider drop down menu
By:	 	Thanh Duong
Description:	Script will parse out all <span> tags in the following format and set as menu.
Menu Format:	<span>
			<table>
				<tr><td>Menu Header</td></tr>
			</table>
			<table>
				<tr><td>Menu Item</td></tr>
				<tr><td>Menu Item</td></tr>
			</table>			
		</span>
*/

var nCount = 1;
var objSpanCollection = null;
var arrMenuHeight = new Array();
var objShowMenu = null;
var nSpeed = 5;
var objHideMenu = null;

function InitializeMenu() 
{
	var objSpan = null;
	objSpanCollection = document.body.getElementsByTagName("span");
	for (var i = 0; i < objSpanCollection.length; i++)
	{
		objSpan = objSpanCollection(i);
		// get second table height in span tag and store in array
		arrMenuHeight[i] = objSpan.childNodes(1).clientHeight;
		// hide menu table on load
		objSpan.childNodes(1).style.display = "none";
		// hide text (rows) inside menu
		objSpan.childNodes(1).childNodes(0).style.display = "none";
		// assign ControlMenu function to first table in span tag OnClick event
		objSpan.childNodes(0).onclick = ControlMenu;
	}
		// show one menu on load
		//objSpanCollection(0).childNodes(1).style.display = "inline";
		//objSpanCollection(0).childNodes(1).childNodes(0).style.display = "inline";
		// set that menu object to be current
		//objShowMenu = objSpanCollection(0).childNodes(1);
}

function ControlMenu() 
{
	// always enable one menu to be opened 
	if (this.parentNode.childNodes(1) != objShowMenu)
	{
		// reset count to 1 on each user click
		nCount = 1;
		if (objShowMenu != null)
		{
			// set objHideMenu object to last menu object, to hide
			objHideMenu = objShowMenu;
			HideMenu();
			// reset count to 1 after calling HideMenu function
			nCount = 1;
		}
		// set which menu user clicked on (second table in span tag)
		objShowMenu = this.parentNode.childNodes(1);
		// decide show or hide menu
		(objShowMenu.style.display == "none") ? ShowMenu() : HideMenu();
	}
}

function ShowMenu()
{
	// get item list inside menu
	var objList = objShowMenu.childNodes(0);
	if (nCount < nSpeed)
	{
		// display menu table
		objShowMenu.style.display = "inline";
		// loop through and decide which menu user clicked on
		for (var i = 0; i < objSpanCollection.length; i++)
		{
			if (objShowMenu.parentNode == objSpanCollection[i])
			{
				// increase height of menu table
				objShowMenu.style.height = objShowMenu.clientHeight + (arrMenuHeight[i] / nSpeed);
			}
		}
		nCount++;
		// call function again
		setTimeout("ShowMenu()", nSpeed)
	}
	if (nCount >= nSpeed)
	{
		// display menu item list once height has been restored
		objList.style.display = "inline";
	}
}

function HideMenu()
{	
	// get item list inside menu
	var objList = objHideMenu.childNodes(0);
	if (nCount < nSpeed)
	{
		// loop through and decide which menu user clicked on
		for (var i = 0; i < objSpanCollection.length; i++)
		{
			if (objHideMenu.parentNode == objSpanCollection[i])
			{
				// decrease menu table height
				objHideMenu.style.height = objHideMenu.clientHeight - (arrMenuHeight[i] / nSpeed);
			}
		}
		// hide menu item list
		objList.style.display = "none";
		nCount++;
		// call function again
		setTimeout("HideMenu()", nSpeed)
	}
	if (nCount >= nSpeed)
	{
		// hide menu table
		objHideMenu.style.display = "none";
	}
}

// -->