
// CREDITS:
// new hierarchical menu by Urs Dudli and Peter Gehrig 
// Copyright (c) 1999 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.ch.
// info@24fun.ch
// 1/13/2000

// - - - - -
// Modified by Michael Anello (michael@OneToMany.com) - June 6, 2003
// Fixed problem with extra <br> at end of sublinks
// Fixed problem of mainlink with no sublinks expanding
// Added menuBlockToOpenForThisPage variable (set outside this file)
// Added sublinkImageToShow variable (set outside this file)
// Added lineHeight variable
// Added imageStuff variable to show current page with image clue
// Modified how fonts are set - no more <font> tage - changed to style attribute
// Added support for NN4+, IE4+, Mozilla
// - - - - -

// IMPORTANT: 
// If you add this script to a script-library or script-archive 
// you have to add a link to http://www.24fun.ch on the webpage 
// where this script Script will be running.

//  **********************************************************************************

// INSTRUCTIONS: 
// Configure the menu and font parameters for each menublock below.
// each menublock[x] contains all necessary informations to build one menu-item with 
// as many sublinks as you like. You can add as many menublocks as you need.
//
// ATTENTION: When you configure the menublocks take care that you
// set the ";" and the "+" as seen below.

// ADDITIONAL INSTRUCTIONS: Added by Michael Anello, June 7, 2003
// 1. Each menublock consists of the main link and any associated sublinks
// 2. If a menublock doesn't have any sublinks, then be sure the URL of the mainlink is not "#"
// 3. If a menublock has sublinks, then be sure the URL of the mainlink is "#"
// 4. Be sure that each menublock ends with a "0"
// 5. To change the image that is displayed next to the active page link, modify the imageStuff variable
// 6. The lineHeight variable controls the spacing between each menu item
// 7. Font information is set within the menu block (see below)
// 8. The following items are required for each file where this menu is used
//    a. The variable menuBlockToOpenForThisPage must be set to the appropriate value. For example,
//       if you are setting the variable for a page that is located in menublock[1], then this 
//       variable should be set to 1 for this page.
//    b. The variable sublinkImageToShow must be set to the appropriate sublink value. This 
//       dictates where the image will appear indicating which page the user is on. For example,
//       if you are setting the variable for a page that is the 2nd sublink of menublock[1], then
//       this variable should be set to 2 for this page.
//    c. This file must be included on every page where the menu appears.
//    d. The baseball.css stylesheet is used to control the dynamic hover underline for each menu item.
//    e. The function call: onload="openandclose(menuBlockToOpenForThisPage)" must be included in 
//       the <body> tag for each page where the menu appears. 
//    f. Two <div> tags (named "menu" and "menunav4" must be placed where you want the menu to
//       appear. Remember that the "menunav4" <div> tag requires absolute positioning, so be sure
//       to set it to where you want it to appear.
//    g. It is highly recommended that you use a static menu within a <noscript> tag to support
//       browswers that aren't using JavaScript.

//  **********************************************************************************

var menublock=new Array(); // no need to change this

var lineHeight = 25; //value in px

var imageStuff = "&nbsp;<img src='/images/navball.gif' width='12' height='12' border='0' alt='&LT;-'>";

menublock[0]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "Home|/index.htm|_self;"+ 				// text|URL|target of mainlink 
			 "0";									// always end array with a zero
			 
menublock[1]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "For Leagues|#|_self;"+				// text|URL|target of mainlink
			 "Find an Umpire|/leagues/findump.htm|_self;"+	// text|URL|target of mainlink
			 "Get More Info|/leagues/info.htm|_self;"+		// text|URL|target of first sublink
			 "0";									// always end array with a zero
			 
menublock[2]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "For Managers|#|_self;"+				// text|URL|target of mainlink
			 "Find an Umpire|/managers/findump.htm|_self;"+	// text|URL|target of mainlink
			 "Get More Info|/leagues/info.htm|_self;"+		// text|URL|target of first sublink
			 "0";									// always end array with a zero
			 
menublock[3]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "For Members|#|_self;"+				// text|URL|target of mainlink
			 "Login|/members/private/login.asp|_self;"+	// text|URL|target of mainlink
			 "Assignors|/members/private/roster.asp|_self;"+			// text|URL|target of first sublink
			 "Field Locations|/members/locations.htm|_self;"+	// text|URL|target of mainlink
			 "Member Events|/members/events.htm|_self;"+		// text|URL|target of first sublink
			 "Photo Album|/members/photos/Album/index.html|_self;"+		// text|URL|target of first sublink
			 "0";									// always end array with a zero
			 
menublock[4]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "Become an Umpire|#|_self;"+			// text|URL|target of mainlink
			 "Join MVUA|/join/join.htm|_self;"+			// text|URL|target of mainlink
			 "Our Goals|/join/goals.htm|_self;"+			// text|URL|target of first sublink
			 "School Schedule|/join/schedule.htm|_self;"+	// text|URL|target of first sublink
			 "0";									// always end array with a zero
			 
menublock[5]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "Contact Us|/contact/index.htm|_self;"+ 	// text|URL|target of mainlink 
			 "0";									// always end array with a zero
			 
menublock[6]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "About Us|/about/index.htm|_self;"+ 	// text|URL|target of mainlink 
			 "0";									// always end array with a zero
			 
menublock[7]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "Site Map|/sitemap/index.htm|_self;"+ 	// text|URL|target of mainlink 
			 "0";									// always end array with a zero
			 
menublock[8]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "Links|/links/index.htm|_self;"+ 	// text|URL|target of mainlink 
			 "0";									// always end array with a zero
			 
menublock[9]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "Search|/sitemap/search.htm|_self;"+ 	// text|URL|target of mainlink 
			 "0";									// always end array with a zero

menublock[10]="Verdana,Arial,sans-serif;"+ 			// font mainlink
			 "8pt;"+								// fontsize mainlink 
			 "FFFFFF;"+								// fontcolor mainlink
			 "1;"+									// fontweight mainlink, 1 means bold, 0 means normal
			 "Verdana,Arial,sans-serif;"+ 			// font sublinks
			 "8pt;"+								// fontsize sublinks 
			 "FFFFFF;"+								// fontcolor sublinks
			 "0;"+									// fontweight sublinks, 1 means bold, 0 means normal
			 "What's New|/sitemap/new.htm|_self;"+ 	// text|URL|target of mainlink 
			 "0";									// always end array with a zero

// No need to change anything below	 
//  **********************************************************************************
	 
var menusplit;
var urlsplit;
var font_weight_main;
var font_weight_sub;
			 
var showsubmenus=new Array()
for (i=0;i<=menublock.length-1;i++) {
	showsubmenus[i]=-1;
}

function openandclose(visi) {
	showsubmenus[visi]=(-1)*showsubmenus[visi];

	var menucontent="";

	// 0: font mainlink
	// 1: fontsize mainlink
	// 2: fontcolor mainlink
	// 3: fontweight mainlink
	// 4: font sublinks
	// 5: fontsize sublinks
	// 6: fontcolor sublinks
	// 7: fontweight sublinks
	// 8: mainlink text | URL
	// 9: sublink 1 text | URL | target
	// 10: sublink 2 text | URL | target
	// 11: sublink 3 text | URL | target
	// 12, 13, 14, etc...
	
	for (i=0;i<=menublock.length-1;i++) {
		menusplit=menublock[i].split(";");
		urlsplit=menusplit[8].split("|");
		if (menusplit[3]==1) {font_weight_main="<b>"}
		if (menusplit[3]==0) {font_weight_main=""}
		if (menusplit[7]==1) {font_weight_sub="<b>"}
		if (menusplit[7]==0) {font_weight_sub=""}
		
		if (menusplit[9]==0) {
			menucontent+=font_weight_main+"<a style='line-height:"+lineHeight+"px;font-family:"+menusplit[0]+";color:"+menusplit[2]+";font-size:"+menusplit[1]+"' href="+urlsplit[1]+">"+urlsplit[0]+"</b></a>";
			if (menuBlockToOpenForThisPage == i && sublinkImageToShow == 0) { menucontent += imageStuff }
			menucontent += "<br>";
		} else {
			menucontent+=font_weight_main+"<a style='line-height:"+lineHeight+"px;font-family:"+menusplit[0]+";color:"+menusplit[2]+";font-size:"+menusplit[1]+"' href='javascript:openandclose("+i+")'>"+urlsplit[0]+"</a></b><br>";
		}
		
		if (showsubmenus[i]==1) {
			for (ii=9;ii<=menusplit.length-1;ii++) {
				urlsplit=menusplit[ii].split("|");
    			if (urlsplit[0] != 0) { 
					menucontent+=font_weight_sub+"&nbsp;&nbsp;&nbsp;<a style='line-height:"+lineHeight+"px;font-family:"+menusplit[4]+";color:"+menusplit[6]+";font-size:"+menusplit[5]+"' href="+urlsplit[1]+" target="+urlsplit[2]+">"+urlsplit[0]+"</a></b>";
					if (sublinkImageToShow == (ii-8) && menuBlockToOpenForThisPage == i) {menucontent += imageStuff}
					menucontent+="<br>";
				}
			}
		}
	}
	if (document.all) {
		//alert("document.all");   // IE 4+
		menu.innerHTML=menucontent;
	} else if (document.getElementById) {    // Mozilla
		//alert("document.getElementById");
		document.getElementById('menu').innerHTML=menucontent;
	} else if (document.layers) {  //Nav 4
		//alert("document.layers");
		document.layers['menunav4'].document.open();
		document.layers['menunav4'].document.write(menucontent);
		document.layers['menunav4'].document.close();
		// See http://www.xs4all.nl/~ppk/js/layerwrite.html for more info on Nav 4 implementation
	}
}
