var t = null;
var cursub = null;
var curfx = null;
var menudur = 400;
var action = null;

function dispSubMenu(menu)
{
	var mid = 'sub_menu_' + menu;
	var m = document.getElementById(mid);

	if (m != null)
	{
		// check if we've created our fx object yet
		if (curfx == null)
		{
			curfx = new fx.Height('sub_menu_container', {duration: menudur});
		}
		// clear the timeout if it exists
		if (t != null)
		{
			clearTimeout(t);
		}
		// if we've changed menus, hide the old menu
		if (cursub != null && cursub != menu)
		{
			document.getElementById('sub_menu_' + cursub).style.display = 'none';
		}
		// show the new menu
		m.style.display = 'block';
		if (action != 'open')
		{
			// slide open the menu
			var c = document.getElementById('sub_menu_container');
			curfx.clearTimer();
			curfx.custom(c.offsetHeight, c.scrollHeight);
		}
		action = 'open';
		cursub = menu;
	}
}

function subMenuOver(menu)
{
	if (cursub == menu)
	{
		// clear the timeout if they move into a submenu
		clearTimeout(t);
	}
}

function hideSubMenuT(menu)
{
	if (cursub == menu)
	{
		// set the timeout when they leave the menu/submenu
		t = setTimeout('hideSubMenu(' + menu + ')', 1000);
	}
}

function hideSubMenu(menu)
{
	var m = document.getElementById('sub_menu_' + menu);

	if (m != null)
	{
		if (action != 'close')
		{
			curfx.custom(m.scrollHeight, 0);
		}
		action = 'close';
	}
}

