var ms;
var menu1;
var menu2;
var menu3;
var menu4;
var menu5;

var submenu26;
var submenu27;

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.
        HookupMenuItem("pwhome",		null);
        HookupMenuItem("main",			menu2);
        HookupMenuItem("hobbies",		menu3);
        HookupMenuItem("programming",	null);
        HookupMenuItem("links",			null);
	}
}

//----------------------------------------------------------------------------------------
// A method that does the nasty work of getting the element specified by the name, and 
// then sets the apporpriate properties based on ewhether or not the specified menu item 
// is null (null indicates no submenu). 
function HookupMenuItem(elementName, menuItem)
{
    var element = document.getElementById(elementName);
    if (element != null && ms != null)
	{
		if (menuItem != null)
		{
			menuitem.onactivate   = function() { element.className = "hover"; }
			menuItem.ondeactivate = function() { element.className = ""; }
		}
		else
		{
			element.onmouseover = function() { ms.hideCurrent(); this.className = ""; }
			element.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
		ms = new TransMenuSet(TransMenu.direction.down, 1, 0, TransMenu.reference.bottomLeft);
	
		// create a dropdown menu:
		// The parameter should be the HTML element which will act as actuator for the menu

		menu2 = ms.addMenu(document.getElementById("main"));
		menu2.addItem("Redneck", 					"main_redneck.aspx");
		menu2.addItem("Just Me", 					"main_justme.aspx");
		menu2.addItem("Family",						"main_family.aspx");
		menu2.addItem("Opinions", 					"main_opinions.aspx");
		menu2.addItem("(Ex-)Biker",					"main_exbiker.aspx");
		menu2.addItem("Cars",						"main_cars.aspx");
		menu2.addItem("What The Hell is That!?",	"main_what_the_hell_is_that.aspx");

		submenu3 = ms.addMenu(document.getElementById("hobbies"));
		submenu3.addItem("Diecast",      "diecast/default.aspx");
		submenu3.addItem("Scale Models", "plastic/default.aspx");
		submenu3.addItem("Firearms",     "guns/default.aspx");

		// 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();
	}
}

