menu = new Array();

//******************************************************
//* List the menu items with the following attributes. *
//*  0  menu ID                                        *
//*  1  menu level                                     *
//*  2  has child (y/n)                                *
//*  3  menu text                                      *
//*  4  url                                            *
//*  5  Status text                                    *
//******************************************************
menu[0]  = new Array("index",            "0", "n", "Home",                    "index.html",                               "Homesite of Youshukai Karate Alliance");
menu[1]  = new Array("aboutYoshukai",    "0", "y", "About Yoshukai",          "",                                         "About Youshukai Karate");
menu[2]  = new Array("yoshukaiAlliance", "1", "n", "Yoshukai Alliance",       "YoshukaiAllianceHistory.html",             "About Youshukai Karate Alliance");
menu[3]  = new Array("yoshukaiHistory",  "1", "n", "Yoshukai History",        "YoshukaiKarateHistory.html",               "About Youshukai Karate");
menu[4]  = new Array("dojoEtiquette",    "1", "n", "Dojo Etiquette",          "DojoEtiquette.html",                       "Dojo Etiquette");
menu[5]  = new Array("dojoBeliefs",      "1", "n", "Dojo Beliefs",            "DojoBeliefs.html",                         "Dojo Beliefs");
menu[6]  = new Array("membershipRules",  "1", "n", "Membership Rules",        "MembershipRules.html",                     "Membership Rules");
menu[7]  = new Array("testing",          "1", "n", "Testing",                 "TestingRequirements.html",                 "Testing Requirements");
menu[8]  = new Array("blackBeltTesting", "1", "n", "Black Belt<br>&nbsp;&nbsp;&nbsp;Requirements", "BlackBeltRequirements.html",               "Black Belt Requirements");
menu[9]  = new Array("dojoLocations",    "0", "y", "Dojo Locations",          "",                                         "List of Youshukai Karate Alliance Dojos");
menu[10] = new Array("hombuDojo",        "1", "n", "Hombu-Dojo",              "HombuDojo.html",                           "Hombu-Dojo");
menu[11] = new Array("kenney Dojo",      "1", "n", "Kenney Dojo",             "KenneyDojo.html",                          "Kenney Dojo");
menu[12] = new Array("trujilloAltoDojo", "1", "n", "Trujillo Alto Dojo",      "TrujilloAltoDojo.html",                    "Trujillo Alto Dojo");
menu[13] = new Array("calendarOfEvents", "0", "n", "Calendar of Events",      "events/CalendarCurrent.html",              "Calendar of Events");
menu[14] = new Array("newsletter",       "0", "n", "Newsletter",              "newsletter/newsletterIndex.html",          "The Alliance Newsletter");
menu[15] = new Array("katas",            "0", "n", "Katas",                   "Katas.html",                               "Yoshukai Karate Alliance Katas");
menu[16] = new Array("weapons",          "0", "n", "Weapons",                 "Weapons.html",                             "Yoshukai Karate Alliance Weapons");
menu[17] = new Array("kumite",           "0", "n", "Kumite",                  "Kumite.html",                              "Kumite (sparring)");
menu[18] = new Array("breaking",         "0", "n", "Breaking",                "BoardBreaking.html",                       "Breaking");
menu[19] = new Array("healthBenefits",   "0", "n", "Health Benefits",         "HealthBenefits.html",                      "Health Benefits of Karate-Do");
menu[20] = new Array("terminology",      "0", "y", "Terminology",             "",                                         "View Karate Terminology");
menu[21] = new Array("terminologyAlpha", "1", "n", "Alphabetical",            "terminology/TerminologyAlphabetical.html", "View karate terminology in alpabetical order");
menu[22] = new Array("terminologyCat",   "1", "n", "Categorized",             "terminology/TerminologyCategorized.html",  "View karate terminology by catagory");
menu[23] = new Array("terminologyCom",   "1", "n", "Commonly Used",           "terminology/TerminologyCommon.html",       "View karate terminology commonly used during class");
menu[24] = new Array("blackBeltDir",     "0", "n", "Black Belt Directory",    "BlackBeltDirectory.html",                  "Yoshukai Karate Alliance Black Belt Directory");
menu[25] = new Array("testimonials",     "0", "n", "Testimonials",            "Testimonials.html",                        "Yoshukai Karate Alliance Testimonials");
menu[26] = new Array("links",            "0", "n", "Links",                   "Links.html",                               "Karate Links");
menu[27] = new Array("contactUs",        "0", "n", "Contact Us",              "ContactUs.html",                           "Contact Us");

//******************************************************
//* This function will loop through the menu items     *
//* above and call the create link function for each   *
//* item.  This function also opens and closes the     *
//* unordered list (ul) tags.                          *
//******************************************************
function buildMenu(path, indexPath)
{
	var menuString = "";
	menuString = menuString + "<ul id=\"navMenu\">";
	var currentLevel = 0;
	var levelsToClose = 1;
	
	for (var x = 0; x < menu.length; x++)
	{
		// If the menu level is the same as the current level
		if (menu[x][1] == currentLevel) {
			menuString = menuString + createLink(x, path, indexPath);
		}
		// If the menu level is greater than the current level
		else if (menu[x][1] > currentLevel) {
			// Add new level by opening a UL tag
			menuString =  menuString + "<ul>";
			menuString = menuString + createLink(x, path, indexPath);			
			// Increment the levels to close
			levelsToClose++;
			// Update the current level variable
			currentLevel = menu[x][1];
		}
		// If the menu level is less than the current level
		else if (menu[x][1] < currentLevel) {
			// Close previous level
			menuString = menuString + "</ul></li>";
			menuString = menuString + createLink(x, path, indexPath);
			// Decrement the levels to close
			levelsToClose--;			
			// Update the current level variable
			currentLevel = menu[x][1];
		}

	}
	
	for (var x = 0; x < levelsToClose; x++) {
		if (levelsToClose > 1) {
			menuString = menuString + "</ul></li>";
		}
		else {
			menuString = menuString + "</ul>";
		}
	}
	
	return menuString;
}

//******************************************************
//* This function will create the individual list      *
//* items (li) and will handle opening the secondary   *
//* menu tiers (ul nested in li).                      *
//******************************************************
function createLink(x, path, indexPath) {
	var menuString = "";
	var outputPath = "";
	
	// If this is the index menu item then use the homePath - Note the index or
	// home page typically has a different path than other html files
	if (menu[x][0] == "index") {
		outputPath = indexPath;
	}
	else {
		outputPath = path;
	}
	
	// If the menu item has children
	if (menu[x][2] == "y") {
		// Display the list item and leave the tag open.  The menu
		// item is not created as a link.
		menuString = menuString + "<li>&nbsp;&nbsp;&nbsp;" + menu[x][3];
	}
	// If the menu does not have children
	else {
		// Display the list item and close the tag
		menuString = menuString + "<li>&nbsp;&nbsp;&nbsp;<a href=\"" + outputPath + menu[x][4] + "\" onMouseOver=\"window.status='" +
					 menu[x][5] + "';return true;\" onMouseOut=\"window.status='';return true;\">" + menu[x][3] + "</a></li>";
	}
	
	return menuString;
}

//******************************************************
//* This function overrides the hover and over         *
//* functions for list item (li) tags.                 *
//******************************************************
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("navMenu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
	
	// If the navigator is not IE
	if (navigator.appName.indexOf("Microsoft") == -1) {
		document.getElementById("rightPage").style.backgroundAttachment="scroll";
		document.getElementById("contentBody").style.paddingLeft="10%";
		document.getElementById("contentBody").style.paddingRight="10%";
		document.getElementById("contentBody").style.width="100%";
	}
}

//******************************************************
//* This function inserts the email address into the   *
//* web page to prevent spam on Alliance email.        *
//******************************************************
function getAddr(intType) {
	var at = "@";
	var dom1 = "yoshukai";
	var dom2 = "alliance";
	var dot = ".";
	var com = "com";
	var type = "";
		
	if (intType == 1)
		type = "admin";
	else if (intType == 2)
		type = "instructors";
	else if (intType == 3)
		type = "duganSensei";
	else if (intType == 4)
	{
		type = "yoshukaikarate";
		dom1 = "yahoo";
		dom2 = "";
	}
	else if (intType == 5)
	{
		type = "senseischreiber";
		dom1 = "hotmail";
		dom2 = "";
	}
	else if (intType == 6)
	{
		type = "sblascors";
		dom1 = "yahoo";
		dom2 = "";
	}
	
	var strRet = "<a class=link href=mailto:" + type + at + dom1 + dom2 + dot + com + ">" + type + at + dom1 + dom2 + dot + com + "</a>";
	return strRet
}

function adjustBodyHeight() {
	var height = getWindowHeight();
	var width = getWindowWidth();
	document.getElementById("headerRight").style.width=width + "px";
	document.getElementById("leftMenu").style.height=height + "px";
	document.getElementById("rightPage").style.height=getWindowHeight() + "px";
	document.getElementById("rightPage").style.width=getWindowWidth() + "px";
}

function getWindowHeight() {
	if (typeof(window.innerWidth) == 'number') {
		return window.innerHeight - 85;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		return document.documentElement.clientHeight - 85;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		return document.body.clientHeight - 85;
	}
	
	return 460;
}

function getWindowWidth() {
	if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		return document.documentElement.clientWidth - 150;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		return document.body.clientWidth - 150;
	}
	else if (typeof(window.innerWidth) == 'number') {
		return window.innerWidth - 150;
	}
	
	return 630;
}

