// menu class
function menu() {
	this.id = new Array();
	this.parentID = new Array();
	this.top = new Array();
	this.left = new Array();
}

function MenuGetI(menuID) {
	for(i=0;i<menu.id.length;i++) {
		if (menu.id[i] == menuID) return i;
	}
}

function SlideDown(menuID) {
	pos+=4;
	if (pos < minTop)
		document.getElementById(menuID).style.top = pos+"px";
	else {
		clearInterval(ti);
	}
}

function SlideUp(menuID) {
	pos-=4;
	if (pos > menu.top[MenuGetI(menuID)])
		document.getElementById(menuID).style.top = pos+"px";
	else {
		document.getElementById(menuID).style.visibility = "hidden";
		clearInterval(ti);
	}
}

// Regular menu
function ShowMenu(menuID,mouseoverClassName,mouseoutClassName) {
	HideAllMenus(mouseoutClassName);
	document.getElementById(menuID).style.visibility = "visible";
	if (mouseoverClassName != '' && mouseoverClassName != undefined) document.getElementById(menu.parentID[MenuGetI(menuID)]).className=mouseoverClassName;
}

// Sliding menu
function SlideMenu(menuID,direction) {
	if (direction == 'up')
		ti = setInterval("SlideUp('"+menuID+"')",1);
	else {
		HideAllMenus();
		if (ti) clearInterval(ti);
		pos = menu.top[MenuGetI(menuID)];
		document.getElementById(menuID).style.visibility = "visible";
		ti = setInterval("SlideDown('"+menuID+"')",1);
	}
	//document.getElementById(menu.parentID[MenuGetI(menuID)]).className="navOver";
}

function HideMenu(menuID,mmenuID,mouseoutClassName) {
	document.getElementById(menuID).style.visibility = "hidden";
	if (mmenuID && mouseoutClassName != '' && mouseoutClassName != undefined) document.getElementById(mmenuID).className=mouseoutClassName;
}

// mouseoutClassName is the class name for the parent menu onmouseout
function HideAllMenus(mouseoutClassName) {
	for(var i=0;i<menu.id.length;i++) {
		document.getElementById(menu.id[i]).style.visibility = "hidden";
		if (mouseoutClassName != '' && mouseoutClassName != undefined) document.getElementById(menu.parentID[i]).className = mouseoutClassName;
	}
}

function LoadMenu(menuID,t,l,parentID) {
	menu.id[i] = menuID;
	menu.parentID[i] = parentID;
	if (t !== "") {
		if (document.getElementById(menuID)) document.getElementById(menuID).style.top = t+"px";
		menu.top[i] = t;
	}
	if (l !== "") {
		if (document.getElementById(menuID)) document.getElementById(menuID).style.left = l+"px";
		menu.left[i] = l;
	}
	i++;
}
/* Usage:
ShowMenu - this is just a simple regular type of menu
<div id="menu1" style="position:absolute;visibility:hidden;">
<table border="0" cellspacing="0" cellpadding="0" class="table_menu">
<tbody>
<tr><td class="td_menu" onmouseover="if (to) clearTimeout(to);className='td_menu_over';" onmouseout="to=setTimeout('HideMenu(\'menu1\')',hideDelayTime);className='td_menu';" onclick="top.location='{YOUR PAGE}';">Item 1</td></tr>
<tr><td class="menu_separator" onmouseover="if (to) clearTimeout(to);"></td></tr>
<tr><td class="td_menu" onmouseover="if (to) clearTimeout(to);className='td_menu_over';" onmouseout="to=setTimeout('HideMenu(\'menu1\')',hideDelayTime);className='td_menu';" onclick="top.location='{YOUR PAGE}';">Item 2</td></tr>
</tbody>
</table>
</div>
<script type="text/javascript">LoadMenu('menu1','','','mmenu1');</script>
SlideMenu
-------------
- minTop must be set. This is the vertical position that you want the menu to stop sliding.
- LoadMenu - when loading the menu, you are requred to set a top position. This is the position the menu will start at.
- You must set the z-index for your menu divs to something less than the z-index of the div that it is sliding out from.
*/
var minTop;
var menu = new menu();
var pos=0;
var i=0;
var ti;
var hideDelayTime = 150;