var menu_arr = Array("ThePastSubNav", "ThePresentSubNav", "TheFutureSubNav");
var HideMenus = 0;
var t;

function ToggleSubMenu(indx, type)
{
	if(type == 1) //display
	{
		HideAll();

		(document.getElementById(menu_arr[indx])).style.display = "block";
		
		HideMenus = 0;
	}

	if(type == 0) //hide
	{
		//(document.getElementById(menu_arr[indx])).style.display = "none";
	
		HideMenus = 1;
		
		t = setTimeout("hideMenu()",2000);
		
		return;
	}	
}

function hideMenu()
{
	if(HideMenus == 1)
	{
		for(i = 0; i < menu_arr.length; i++)
		{
			(document.getElementById(menu_arr[i])).style.display = "none";
		}
		
		//If all the submenus are hidden, then try to display the active menu item subnav
		ActivateTheDefaultNav();
	}
}

function HideAll()
{
	for(i = 0; i < menu_arr.length; i++)
	{
		(document.getElementById(menu_arr[i])).style.display = "none";
	}
}

function ActivateTheDefaultNav()
{
	var is_active = 0;
	var menu_pos = -1;
	
	if(active_subnav == "")
	{
		return;
	}

	for(i = 0; i < menu_arr.length; i++)
	{
		if(menu_arr[i] == active_subnav)
		{
			menu_pos = i;
		}
	}

	if(!is_active && active_subnav != "" && menu_pos >= 0)
	{
		(document.getElementById(menu_arr[menu_pos])).style.display = "block";
	}
}

function ToggleHideNav(type)
{
	if(type == 0) //Hide
	{
		HideMenus = 1;
		t = setTimeout("hideMenu()", 2000);
	}

	if(type == 1) //Display
	{
		HideMenus = 0;
	}
}

