var ms;
var menu1;
var menu2;
var menu3;
var menu4;
var menu5;

function InitMenu() 
{
	//==========================================================================================
	// if supported, initialize TransMenus
	//==========================================================================================
	// Check isSupported() so that menus aren't accidentally sent to non-supporting browsers.
	// This is better than server-side checking because it will also catch browsers which would
	// normally support the menus but have javascript disabled.
	//
	// If supported, call initialize() and then hook whatever image rollover code you need to do
	// to the .onactivate and .ondeactivate events for each menu.
	//==========================================================================================
	if (TransMenu.isSupported()) 
	{
		TransMenu.initialize();

		// hook all the highlight swapping of the main toolbar to menu activation/deactivation
		// instead of simple rollover to get the effect where the button stays hightlit until
		// the menu is closed.
		menu1.onactivate = function() { document.getElementById("home").className = "hover"; };
		menu1.ondeactivate = function() { document.getElementById("home").className = ""; };

		menu2.onactivate = function() { document.getElementById("main").className = "hover"; };
		menu2.ondeactivate = function() { document.getElementById("main").className = ""; };

		menu3.onactivate = function() { document.getElementById("programming").className = "hover"; };
		menu3.ondeactivate = function() { document.getElementById("programming").className = ""; };

		menu4.onactivate = function() { document.getElementById("racing").className = "hover"; };
		menu4.ondeactivate = function() { document.getElementById("racing").className = ""; };

		menu5.onactivate = function() { document.getElementById("bookmarks").className = "hover"; };
		menu5.ondeactivate = function() { document.getElementById("bookmarks").className = ""; };

		document.getElementById("forums").onmouseover = function() 
		{
			ms.hideCurrent();
			this.className = "hover";
		}
		document.getElementById("forums").onmouseout = function() { this.className = ""; }
	}
}

function DrawMenu()
{
	// set up drop downs anywhere in the body of the page. I think the bottom of the page is better.. 
	// but you can experiment with effect on loadtime.
	if (TransMenu.isSupported()) 
	{
		//==================================================================================================
		// create a set of dropdowns
		//==================================================================================================
		// the first param should always be down, as it is here
		//
		// The second and third param are the top and left offset positions of the menus from their actuators
		// respectively. To make a menu appear a little to the left and bottom of an actuator, you could use
		// something like -5, 5
		//
		// The last parameter can be .topLeft, .bottomLeft, .topRight, or .bottomRight to inidicate the corner
		// of the actuator from which to measure the offset positions above. Here we are saying we want the 
		// menu to appear directly below the bottom left corner of the actuator
		//==================================================================================================
//		var ms = new TransMenuSet(TransMenu.direction.down, 1, 0, TransMenu.reference.bottomLeft);
		ms = new TransMenuSet(TransMenu.direction.down, 1, 0, TransMenu.reference.bottomLeft);
	
		//==================================================================================================
		// create a dropdown menu
		//==================================================================================================
		// the first parameter should be the HTML element which will act actuator for the menu
		//==================================================================================================
//		var menu1 = ms.addMenu(document.getElementById("home"));
		menu1 = ms.addMenu(document.getElementById("home"));
		menu1.addItem("rTCDD", 		"http://www.paddedwall.org/rTCDD2/index.php"); 
		menu1.addItem("Paddedwall", "http://www.paddedwall.org/home/index.php");

		//==================================================================================================
//		var menu2 = ms.addMenu(document.getElementById("main"));
		menu2 = ms.addMenu(document.getElementById("main"));
		menu2.addItem("Redneck", 	"main_redneck.php");
		menu2.addItem("Just Me", 	"main_justme.php");
		menu2.addItem("Family", 	"main_family.php");
		menu2.addItem("Opinions", 	"main_opinions.php");
		menu2.addItem("(Ex-)Biker", "main_ex_biker.php");
		menu2.addItem("Hobbies", 	"");
	
		//==================================================================================================
		//var menu3 = ms.addMenu(document.getElementById("programming"));
		menu3 = ms.addMenu(document.getElementById("programming"));
		menu3.addItem("Pseudo-resume",	"prog_resume.php");
		menu3.addItem("Philosophy",		"prog_philosophy.php");
		menu3.addItem("Frustrations",	"prog_frustrations.php");
		menu3.addItem("Programs", 		"prog_programs.php");
		menu3.addItem("Code Snippets",	"prog_codesnippets.php");
		menu3.addItem("This Website",	"prog_thiswebsite.php");
	
		//==================================================================================================
//		var menu4 = ms.addMenu(document.getElementById("racing"));
		menu4 = ms.addMenu(document.getElementById("racing"));
		menu4.addItem("Where I'm Racing", "http://www.nascor.net");
		menu4.addItem("NR2K3 Paint"         );
		menu4.addItem("rFactor Paint",    "");
		menu4.addItem("Layered Logos"       );
		
		var submenu41 = menu4.addMenu(menu4.items[1]);
		var submenu42 = menu4.addMenu(menu4.items[2]);
		var submenu43 = menu4.addMenu(menu4.items[3]);
		
		submenu41.addItem("My Online Cars",		"racing_nr2k3_paint.php");
		submenu41.addItem("Aero88 Mod",			"nr2k3_paint_aero88.php");
		submenu41.addItem("CTS Mod",			"nr2k3_paint_cts.php");
		submenu41.addItem("Cup/Busch Mods",		"nr2k3_paint_cupbgn.php");
		submenu41.addItem("PTA Mod",			"nr2k3_paint_pta.php");
		submenu41.addItem("TPTCC Mod",			"nr2k3_paint_tptcc.php");
		submenu41.addItem("Miscellaneous",		"nr2k3_paint_misc.php");
		submenu41.addItem("How to Paint a Stockcar",	"nr2k3_paint_howto.php");

		submenu42.addItem("National Stockcar Challenge","rfactor_paint_nscrs.php");
		
		submenu43.addItem("Introduction",  "logos_introduction.php");
		submenu43.addItem("A through G",   "logos_abcdefg.php");
		submenu43.addItem("H through N",   "logos_hijklmn.php");
		submenu43.addItem("O through U",   "logos_opqrstu.php");
		submenu43.addItem("V through Z",   "logos_vwxyz.php");
		submenu43.addItem("0 through 9",   "logos_0thru9.php");
		submenu43.addItem("Miscellaneous", "logos_misc.php");
	
		//==================================================================================================
//		var menu5 = ms.addMenu(document.getElementById("bookmarks"));
		menu5 = ms.addMenu(document.getElementById("bookmarks"));
		menu5.addItem("News/Search",	"bookmarks2.php");
		menu5.addItem("Hardware",		"bookmarks_hardware.php");
		menu5.addItem("Software",		"bookmarks_software.php");
		menu5.addItem("Games",			"bookmarks_games.php");
		menu5.addItem("Programming",	"bookmarks_programming.php");
		menu5.addItem("Hobbies",		"bookmarks_hobbies.php");
		menu5.addItem("Racing",			"bookmarks_racing.php");
		menu5.addItem("Miscellaneous",	"bookmarks_misc.php");
		menu5.addItem("Friend's Pages",	"bookmarks_friends.php");
	
		//==================================================================================================
		// write drop downs into page
		//==================================================================================================
		// this method writes all the HTML for the menus into the page with document.write(). It must be
		// called within the body of the HTML page.
		//==================================================================================================
		TransMenu.renderAll();
	}
}
