/*
menu class
Usage:
ShowMenu - this is just a simple regular type of menu

<table style="border:0;margin:auto;height:28px;" cellpadding="0" cellspacing="0" onmouseover="if (to0) clearTimeout(to0);" onmouseout="to0=setTimeout('menu.HideAllMenus(\'navOutDropdown\')',hideDelayTime);">
<tbody>
<tr>
	<td id="mmenu1" class="nav" onmouseover="if (to) clearTimeout(to);menu.ShowMenu('menu1','navOverDropdown','navOutDropdown');" onmouseout="to=setTimeout('menu.HideMenu(\'menu1\')',hideDelayTime);">Main Menu 1</td>
</tr>
</tbody>
</table>

<div id="menu1" style="position:absolute;visibility:hidden;">
<table border="0"if (to0) clearTimeout(to0);if (to) clearTimeout(to);" onmouseout="to=setTimeout('menu.HideMenu(\'menu1\',\'mmenu1\',\'navOutDropdown\')',hideDelayTime);" cellspacing="0" cellpadding="0" class="table_menu">
<tbody>
<tr><td class="td_menu" onmouseover="className='td_menu_over';" onmouseout="className='td_menu';" onclick="top.location='{YOUR PAGE}';">Item 1</td></tr>
<tr><td class="menu_separator"></td></tr>
<tr><td class="td_menu" onmouseover="className='td_menu_over';" onmouseout="className='td_menu';" onclick="top.location='{YOUR PAGE}';">Item 2</td></tr>
</tbody>
</table>
</div>
<script type="text/javascript">
var menu = new menu();
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.
*/

function vxtmenu() {
	this.i = 0;
	this.id = new Array();
	this.parentID = new Array();
	this.top = new Array();
	this.left = new Array();

	this.MenuGetI = function (menuID) {
		for(i=0;i<this.id.length;i++) {
			if (this.id[i] == menuID) return i;
		}
	}

	this.ShowMenu = ShowMenu;
	this.ShowSubMenu = ShowSubMenu;
	this.HideMenu = HideMenu;
	this.HideAllMenus = HideAllMenus;
	this.LoadMenu = LoadMenu;

	this.SlideDown = SlideDown;
	this.SlideUp = SlideUp;
	this.SlideMenu = SlideMenu;
}

// Regular menu, mouseoverClassName and mouseoutClassName are the class names for the parent menu
function ShowMenu(menuID,mouseoverClassName,mouseoutClassName) {
	this.HideAllMenus(mouseoutClassName);
	document.getElementById(menuID).style.visibility = "visible";
	if (mouseoverClassName != '' && mouseoverClassName != undefined) document.getElementById(this.parentID[this.MenuGetI(menuID)]).className=mouseoverClassName;
}

function HideMenu(menuID,mmenuID,mouseoutClassName) {
	document.getElementById(menuID).style.visibility = "hidden";
	if (mmenuID && mouseoutClassName != '' && mouseoutClassName != undefined) document.getElementById(mmenuID).className=mouseoutClassName;
}

function ShowSubMenu(menuID) {
	document.getElementById(menuID).style.visibility='visible';
}

// mouseoutClassName is the class name for the parent menu onmouseout
function HideAllMenus(mouseoutClassName) {
	for(var i=0;i<this.id.length;i++) {
		document.getElementById(this.id[i]).style.visibility = "hidden";
		if (mouseoutClassName != '' && mouseoutClassName != undefined) document.getElementById(this.parentID[i]).className = mouseoutClassName;
	}
}

function LoadMenu(menuID,t,l,parentID) {
	this.id[this.i] = menuID;
	this.parentID[this.i] = parentID;

	if (t !== "") {
		if (document.getElementById(menuID)) document.getElementById(menuID).style.top = t+"px";
		this.top[this.i] = t;
	}

	if (l !== "") {
		if (document.getElementById(menuID)) document.getElementById(menuID).style.left = l+"px";
		this.left[this.i] = l;
	}

	this.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 > this.top[this.MenuGetI(menuID)])
		document.getElementById(menuID).style.top = pos+"px";
	else {
		document.getElementById(menuID).style.visibility = "hidden";
		clearInterval(ti);
	}
}

// Sliding menu
function SlideMenu(menuID,direction) {
	if (direction == 'up')
		ti = setInterval("SlideUp('"+menuID+"')",1);
	else {
		HideAllMenus();
		if (ti) clearInterval(ti);
		pos = this.top[this.MenuGetI(menuID)];
		document.getElementById(menuID).style.visibility = "visible";
		ti = setInterval("SlideDown('"+menuID+"')",1);
	}
	//document.getElementById(menu.parentID[MenuGetI(menuID)]).className="navOver";
}

var minTop;
var pos=0;
var ti;
var hideDelayTime = 500;
