var oMenu = new Menu();
var oSubMenu = new SubMenu();

//Main Menu ===================================================================================================
function Menu()
{	this.menuItems = new Array();
	this.addMenuItem = addMenuItem; 
}

function addMenuItem(sID, sText, sHref)
{	//create a new menu item
	var oItem = new MenuItem(sID, sText, sHref);
	//add the item to the menuItems array
	this.menuItems[this.menuItems.length] = oItem;
}

function MenuItem(sID, sText, sHref)
{	this.id = sID;
	this.text = sText;
	this.href = sHref;
}

function initializeMenu()
{	oMenu.addMenuItem("services", "Services", "services.html");
	oMenu.addMenuItem("staff", "Meet Our Staff", "staff.html");
	oMenu.addMenuItem("about", "About RGC", "about.html");
	oMenu.addMenuItem("classes", "Classes", "classes.html");
	oMenu.addMenuItem("directions", "Directions", "directions.html");
}

//Sub Menus======================================================================================================
function SubMenu()
{	this.subMenuItems = new Array();
	this.addSubMenuItem = addSubMenuItem; 
}

function addSubMenuItem(sID, sText, sHref)
{	//create a new menu item
	var oItem = new SubMenuItem(sID, sText, sHref);
	//add the item to the menuItems array
	this.subMenuItems[this.subMenuItems.length] = oItem;
}

function SubMenuItem(sID, sText, sHref)
{	this.id = sID;
	this.text = sText;
	this.href = sHref;
}

function initializeSubMenu(sParent)
{	//if(sParent == "category1")
	//{	oSubMenu.addSubMenuItem(sParent + "_1", "Sub Item 1", sParent + "_detail1.html");
	//	oSubMenu.addSubMenuItem(sParent + "_2", "Sub Item 2", sParent + "_detail2.html");
	//	oSubMenu.addSubMenuItem(sParent + "_3", "Sub Item 3", sParent + "_detail3.html");
	//}
}

function createMenu(sMain, bMainSelected, sSub)
{	var iWidth = 150;
	var sHeading = "";

	initializeMenu();
	initializeSubMenu(sMain);
	
	document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#ffffff\">");
	document.write("<tr>");
	document.write("<td class=\"secondary\"><img src=\"images/spacer.gif\" alt=\"\" width=\"21\" height=\"1\" border=\"0\"></td>");
	document.write("<td colspan=\"2\" class=\"secondary\"><img src=\"images/spacer.gif\" alt=\"\" width=\"" + iWidth + "\" height=\"15\" border=\"0\"></td>");
	document.write("<tr>");
	document.write("<td class=\"secondary\"><img src=\"images/spacer.gif\" alt=\"\" width=\"21\" height=\"1\" border=\"0\"></td>");
	document.write("<td height=\"15\" colspan=\"2\" class=\"secondary\"><span class=\"subheading\">" + sHeading + "</span></td>");
	document.write("</tr>");
	document.write("<tr><td colspan=\"3\" class=\"secondary\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"15\" border=\"0\"></td></tr>");
	document.write("<tr><td colspan=\"3\" class=\"line\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"1\" border=\"0\"></td></tr>");
	
	for (var i = 0; i < oMenu.menuItems.length; i++)
	{	var sID = oMenu.menuItems[i].id;
		var sText = oMenu.menuItems[i].text;
		var sHref = oMenu.menuItems[i].href;
		
		document.write("<tr>");
	
		if (sMain == sID)
		{	if (bMainSelected)
			{	var sImage = "menu_on.gif";
				var sDisplay = "<span class=\"boldtext\">" + sText + "</span>";
			}
			else
			{	var sImage = "spacer.gif"
				var sDisplay = "<a href=\"" + sHref + "\" class=\"menu\">" + sText + "</a>";
			}
			
			document.write("<td valign=\"top\"><img src=\"images/" + sImage + "\" alt=\"\" width=\"21\" height=\"25\" border=\"0\"></td>");
			document.write("<td width=\"" + iWidth + "\" height=\"25\" valign=\"top\">");
			
			//sub items
			document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
			document.write("<tr><td colspan=\"2\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"5\" border=\"0\"></td></tr>");
			document.write("<tr><td colspan=\"2\">" + sDisplay + "</td></tr>");
				
				for (x = 0; x < oSubMenu.subMenuItems.length; x++)
				{	var sSubID = oSubMenu.subMenuItems[x].id
					var sSubText = oSubMenu.subMenuItems[x].text
					var sSubHref = oSubMenu.subMenuItems[x].href
					
					if (sMain + "_" + sSub == sSubID)
					{	var sSubImage = "menu_on.gif";
						var sSubDisplay = "<span class=\"text\">" + sSubText + "</span>";
					}
					else
					{	var sSubImage = "spacer.gif";
						var sSubDisplay = "<a href=\"" + sSubHref + "\" class=\"submenu\">" + sSubText + "</a>";
					}
						
					document.write("<tr>");
					document.write("<td><img src=\"images/" + sSubImage + "\" alt=\"\" width=\"8\" height=\"20\" border=\"0\"></td>");
					document.write("<td width=\"100%\">" + sSubDisplay + "</td>");
					document.write("</tr>");
				}
				
			document.write("<tr><td colspan=\"2\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"5\" border=\"0\"></td></tr>");
			document.write("</table>");
			
			document.write("</td>");
		}
		else
		{	document.write("<td><img src=\"images/spacer.gif\" alt=\"\" width=\"21\" height=\"25\" border=\"0\"></td>");
			document.write("<td width=\"" + iWidth + "\" height=\"25\"><a href=\"" + sHref + "\" class=\"menu\">" + sText + "</a></td>");
		}
		
		document.write("<td class=\"line\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"25\" border=\"0\"></td>");
		document.write("</tr>");
		document.write("<tr><td colspan=\"3\" class=\"line\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"1\" border=\"0\"></td></tr>");
	}
	
	document.write("<tr><td colspan=\"3\" class=\"secondary\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"15\" border=\"0\"></td></tr>");
	document.write("<tr><td colspan=\"3\" class=\"secondary\"><img src=\"images/spacer.gif\" alt=\"\" width=\"1\" height=\"15\" border=\"0\"></td></tr>");
	document.write("</table>");
}


