<!--menu.js  JavaScript to create cascading menus -->

var menus = new Object();
var numMenus = 0;

function addMenus(main, sub, link, toolTip)
{
	if(!menus[main])
	{
		var tempMenu = new Object();
		tempMenu.name = main;
		tempMenu.rank = numMenus++;
		tempMenu.link = link;
		tempMenu.toolTip = toolTip;
		tempMenu.subMenus = new Array();
		tempMenu.links = new Array();
		menus[main] = tempMenu;
	}
	menus[main].subMenus.push(sub);
	menus[main].links.push(link);

}

function showMainMenus()
{
	for (var tempMenu in menus)
	{
		var aMenu = menus[tempMenu];
		document.write('<a href="'+aMenu.link+'"  title="'+ aMenu.toolTip + '" \
						onmouseover = "timer = setTimeout(\'showMenu(' + aMenu.rank +')\', 1000);" \
						onmouseout = "clearTimeout(timer); \
						timer = setTimeout(\'hideMenu('+aMenu.rank +')\', 2000); ">\
						' + aMenu.name + '</a>' + '<br />' + '<p />');
		for(i=0; i<aMenu.subMenus.length; i++)
		{
			if(aMenu.subMenus[i] != "")
				document.write('<a href='+aMenu.link+'#'+ aMenu.subMenus[i] +' \
							id="'+ aMenu.name + parseInt(i) + '" \
							class = "submenu" \
			 				style="display:none;" >' + aMenu.subMenus[i] + '</a>');
		}
	}
}

function showMenu(rank)
{
	for(var tempMenu in menus)
	{
		var aMenu = menus[tempMenu];
		if((aMenu.rank == rank) && (aMenu.subMenus.length > 0))
		{
			for(i=0; i<aMenu.subMenus.length; i++)
			{
				if(aMenu.subMenus[i] != "")
					document.getElementById(aMenu.name + parseInt(i)).style.display="block";
			}
		}
	}
}

function hideMenu(rank)
{
	for (var tempMenu in menus)
	{
		var aMenu = menus[tempMenu];
		if(aMenu.rank == rank)
		{
			for(i=0; i<aMenu.subMenus.length; i++)
			{
				if(aMenu.subMenus[i] != "")
					document.getElementById(aMenu.name + parseInt(i)).style.display = "none";
			}
		}
	}
}

//addMenus("Fabius Laws, Forms etc", "", "LawsForms.php", "Download or View Laws or Forms");

addMenus("Town Offices (forms)", "", "../php-files/town-offices.php", "Location, hours, forms, permits, etc");
addMenus("Local Businesses", "", "../php-files/local-business.php", "Support the Fabius Business Community");
addMenus("Discussion Board", "", "../phpBB3/", "Discussion forums on various topics");
addMenus("Around & About", "", "../php-files/around-about.php", "Miscellaneous");
addMenus("Going Green - Save Energy", "", "../php-files/Go-Green.php", "Conservation");

addMenus("Government Representatives", "Village", "../php-files/gov.php", "Information about our elected officials");
addMenus("Government Representatives", "Town", "../php-files/gov.php", "Information about our elected officials");
addMenus("Government Representatives", "County", "../php-files/gov.php");
addMenus("Government Representatives", "State", "../php-files/gov.php");
addMenus("Government Representatives", "Federal", "../php-files/gov.php");
addMenus("Government Representatives", "&nbsp", " ");

addMenus("Schools", "", "http://www.fabiuspompey.org", "Local school information");

addMenus("Fabius' History", "", "../php-files/fabius_historical.php", "Learn about Fabius' History");

addMenus("Recreation", "Highland Forest", "../php-files/recreation.php", "Recreation Activities in Fabius");
addMenus("Recreation", "Hill and Dale Golf Course", "../php-files/recreation.php", "Recreation Activities in Fabius");
addMenus("Recreation", "Toggenburg Ski Center", "../php-files/recreation.php");
addMenus("Recreation", "&nbsp", " ");


//addMenus("Home Page", "", "http://192.168.1.103", "Return to the Home Page");
//addMenus("Home Page", "", "http://72.230.120.202", "Return to the Home Page");
addMenus("Home Page", "", "http://www.fabius-ny.gov", "Return to the Home Page");


//addMenus("Businesses", "", "business.php", "Local Businesses");
//addMenus("Businesses", "Artists", "business.php");
