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("home", "Home", "default.aspx");
	oMenu.addMenuItem("bicycles", "The Spirit of Cycling Art Prints", "bicycles.aspx");
	//oMenu.addMenuItem("betheone", "Be The One...<sup>TM</sup> Clothing", "betheone.aspx");
	//oMenu.addMenuItem("custom", "Custom Sports Art", "bicycles_custom.aspx");
	//oMenu.addMenuItem("web", "Web Design &amp; Development", "websites.aspx");
	//oMenu.addMenuItem("illustration", "Design &amp; Illustration" , "illustration.aspx");
	oMenu.addMenuItem("about", "Meet Craig Ripley", "about.aspx");
	oMenu.addMenuItem("links", "Links", "links.aspx");
}

//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 == "bicycles")
	{	oSubMenu.addSubMenuItem(sParent + "_available", "Available Prints", sParent + "_available.aspx");
		//oSubMenu.addSubMenuItem(sParent + "_future", "Future Releases", sParent + "_future.aspx");
		//oSubMenu.addSubMenuItem(sParent + "_preorder", "Pre-Order Prints", sParent + "_preorder.aspx");
		//oSubMenu.addSubMenuItem(sParent + "_custom", "Custom Bicycle &amp; Cycling Art", sParent + "_custom.aspx");
	}
	
	//if(sParent == "illustration")
	//{	oSubMenu.addSubMenuItem(sParent + "_paintings", "Illustrations &amp; Paintings", sParent + "_paintings.aspx");
	//	oSubMenu.addSubMenuItem(sParent + "_digital", "Digital Art", sParent + "_digital.aspx");
	//	oSubMenu.addSubMenuItem(sParent + "_logos", "Logos &amp Branding", sParent + "_logos.aspx");
	//}
}

function createMenu(sMain, bMainSelected, sSub)
{	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=\"180\" height=\"1\" border=\"0\"></td>");
	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=\"180\" 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 = "submenu_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 width=\"10\" nowrap><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=\"180\" 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=\"5\" 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>");
}


