// creates the main menu along the top of the page

// depends on AmagaviHTML.js

function showRossMenu(){
	var html = "";
	html += asHTMLOpenTag("ul", asHTMLAttribute("class", "utopmenu"));

	// home
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 52px 0px 52px; border-left: 0px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "index.html"), "HOME" );
	html += asHTMLCloseTag("li");
	

	// the school 
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 31px 0px 31px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "about.html"), "THE SCHOOL" );
	html += asHTMLCloseTag("li");
	
	
	// events 
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 44px 0px 44px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "events.html"), "EVENTS" );
	html += asHTMLCloseTag("li");
	

	// PTA 
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 53px 0px 53px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "pta.html"), "PTA" );
	html += asHTMLCloseTag("li");
	
	
	// Downloads 
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 29px 0px 29px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "downloads.html"), "DOWNLOADS" );
	html += asHTMLCloseTag("li");


	// contact 
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 39px 0px 39px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "contact.html"), "CONTACT" );
	html += asHTMLCloseTag("li");
	
	
/* don't use calendar yet, just reproducing previous stuff

	// calendar 
	html += asHTMLOpenTag("li",	asHTMLAttribute("class", "topmenu") +
								asHTMLAttribute("style", "padding: 0px 39px 0px 39px;"));		
	html += asHTMLContainer("a",	asHTMLAttribute("class", "atopmenu")	+
									asHTMLAttribute("href", "RossSchoolCalendar.html"), "CALENDAR" );
	html += asHTMLCloseTag("li");
*/
	
	html += asHTMLCloseTag("ul");
	
	// alert(html);
	
	document.write(html);
}

function getRossMenuAsJSON(){
	var theMenu = 
		[
			{
				"title": "Home",
				"link":"index.html",
				"cssClass": "first"
			},
			
			{
				"title":"The School",
				"link":"about.html",
				"cssClass":""
			},

			{
				"title":"Events",
				"link":"events/silentAuction2010.html",
				"cssClass":""
			},

			{
				"title":"PTA",
				"link":"pta.html",
				"cssClass":""
			},

			{
				"title":"Downloads",
				"link":"downloads.xml",
				"cssClass":""
			},
			
			{
				"title":"Contact",
				"link":"contact.html",
				"cssClass":""
			},

			{
				"title":"Calendar",
				"link":"RossSchoolCalendar.html",
				"cssClass":""
			},
						
			{
				"title":"News",
				"link":"news.html",
				"cssClass":""
			}
			
			/*
			{
				"title":"Photo Gallery",
				"link":"gallery/album-001.html",
				"cssClass":""
			},
			*/
			

			
		];
	return theMenu;
}



function getLeftNavMenuAsJSON(){
	var theMenu = 
		[
			{
				"title": "Annual Auction 2010",
				"link":"events/silentAuction2010.html",
				"cssClass": ""
			},
			
			{
				"title":"Open House - Feb 2010",
				"link":"events/openhouse-2010-02.html",
				"cssClass":""
			},

			{
				"title":"Annual Auction 2009",
				"link":"events/silentAuction2009.html",
				"cssClass":""
			},

			{
				"title":"Open House - Feb 2009",
				"link":"events/openhouse.html",
				"cssClass":""
			},

			{
				"title":"2009 Christmas Tree Sale",
				"link":"events/2009-ChristmasTreeSale.html",
				"cssClass":""
			},
			
			{
				"title":"2008 Fall Festival",
				"link":"Home.html",
				"cssClass":""
			},
			
			{
				"title":"2008 Christmas Tree Sale",
				"link":"ChristmasTree2008/index.html",
				"cssClass":""
			}
			
		];
	return theMenu;
}


function getLeftNavMenuForSchoolAsJSON(){
	var theMenu = 
		[
			{
				"title": "Academics &amp; Programs",
				"link":"about.html",
				"cssClass": ""
			},
			
			{
				"title":"Faculty &amp; Staff",
				"link":"facultyStaff.html",
				"cssClass":""
			},

			{
				"title":"How to Register",
				"link":"register.html",
				"cssClass":""
			},

			{
				"title":"Parent Outreach",
				"link":"parentOutreach.html",
				"cssClass":""
			}
		];
	return theMenu;
}

function showRossMenu2(){
	var html = "";	
	var theMenu = getRossMenuAsJSON();

	html += asHTMLOpenTag("div", asHTMLAttribute("id", "mag_topMenu"));
	html += asHTMLOpenTag("table", "");
	
	html += asHTMLOpenTag("tr", "");
	
	for(menuItem = 0; menuItem < theMenu.length; menuItem++){
		html += asHTMLOpenTag("td", asHTMLAttribute("class", theMenu[menuItem].cssClass));
		html += asHTMLContainer("a", asHTMLAttribute("href", theMenu[menuItem].link), theMenu[menuItem].title);
		html += asHTMLCloseTag("td");		
	}
	
	html += asHTMLCloseTag("tr");
	
	html += asHTMLCloseTag("table");
	html += asHTMLCloseTag("div");
	
	document.write(html);		
}

/* 
    2010-0208 MAG 
    See also: RossTopMenu.xml, downloads.xsl and downloads.xml
    for now there's duplicate functionality with javascript and XML/XSL 
*/
function showRossMenu3(selectedTitle, linkPrefix){
	var html = "";	
	var cssClass = "";
	var theLink = "";
	
	var theMenu = getRossMenuAsJSON();

	html += asHTMLOpenTag("div", asHTMLAttribute("id", "mag_topMenu"));
	html += asHTMLOpenTag("table", "");
	
	html += asHTMLOpenTag("tr", "");
	
	for(menuItem = 0; menuItem < theMenu.length; menuItem++){
		cssClass = theMenu[menuItem].cssClass;
		if (selectedTitle == theMenu[menuItem].title){
			cssClass += " selected ";
		}
		html += asHTMLOpenTag("td", asHTMLAttribute("class", cssClass));
		
		if (selectedTitle == theMenu[menuItem].title){
			html += theMenu[menuItem].title;
		}else{
			theLink = theMenu[menuItem].link;
			if (linkPrefix != undefined){
				theLink = linkPrefix + theMenu[menuItem].link;
			}
			html += asHTMLContainer("a", asHTMLAttribute("href", theLink), theMenu[menuItem].title);
		}
		
		html += asHTMLCloseTag("td");		
	}
	
	html += asHTMLCloseTag("tr");
	
	html += asHTMLCloseTag("table");
	html += asHTMLCloseTag("div");
	
	document.write(html);		
}



/*    <li id="Chapter">Events</li> */
/*    <li onclick="parent.location='silentAuction2010.html'"><a href="silentAuction2010.html">Silent Auction 2010</a></li> */
/*    <li class="selected"><a href="openhouse-2010-02.html">Open House - Feb 2010</a></li> */

function showLeftNavMenu(chapterName, selectedTitle, linkPrefix){
	var html = "";	
	var cssClass = "";
	var theLink = "";
	var onClickAttribute = "";
	var attributesToAdd = "";
	
	var theMenu = getLeftNavMenuAsJSON();
	
	html += asHTMLOpenTag("ul", asHTMLAttribute("class", "mag_leftNavMenu"));

	html += asHTMLContainer("li", asHTMLAttribute("id", "Chapter"), chapterName);
	
	for(menuItem = 0; menuItem < theMenu.length; menuItem++){
	    attributesToAdd = "";

        theLink = theMenu[menuItem].link;
		if (linkPrefix != undefined){
			theLink = linkPrefix + theMenu[menuItem].link;
		}
		
		cssClass = theMenu[menuItem].cssClass;
		
		if (selectedTitle == theMenu[menuItem].title){
			cssClass += " selected ";
		}else{
		    onClickAttribute = asHTMLAttribute("onclick", "parent.location='"+theLink+"'");
		    attributesToAdd += onClickAttribute;
		}	
		
		if (cssClass.length > 0){
		    attributesToAdd += asHTMLAttribute("class", cssClass);
		}
		
		if (attributesToAdd.length > 0){
		    html += asHTMLOpenTag("li", attributesToAdd);
		} else {
		    html += asHTMLOpenTag("li");
		}
		
		html += asHTMLContainer("a", asHTMLAttribute("href", theLink), theMenu[menuItem].title);
		html += asHTMLCloseTag("li");		
	}
	
	html += asHTMLCloseTag("ul");
	// html += asHTMLContainer("div", asHTMLAttribute("style", "color: red;"), "menu from javascript");
	
	document.write(html);		
}


function showLeftNavMenuWithJSONMenu(theMenu, chapterName, selectedTitle, linkPrefix){
	var html = "";	
	var cssClass = "";
	var theLink = "";
	var onClickAttribute = "";
	var attributesToAdd = "";
	
	// the caller is responsible for sending this in
	// var theMenu = getLeftNavMenuAsJSON();
	
	html += asHTMLOpenTag("ul", asHTMLAttribute("class", "mag_leftNavMenu"));

	html += asHTMLContainer("li", asHTMLAttribute("id", "Chapter"), chapterName);
	
	for(menuItem = 0; menuItem < theMenu.length; menuItem++){
	    attributesToAdd = "";

        theLink = theMenu[menuItem].link;
		if (linkPrefix != undefined){
			theLink = linkPrefix + theMenu[menuItem].link;
		}
		
		cssClass = theMenu[menuItem].cssClass;
		
		if (selectedTitle == theMenu[menuItem].title){
			cssClass += " selected ";
		}else{
		    onClickAttribute = asHTMLAttribute("onclick", "parent.location='"+theLink+"'");
		    attributesToAdd += onClickAttribute;
		}	
		
		if (cssClass.length > 0){
		    attributesToAdd += asHTMLAttribute("class", cssClass);
		}
		
		if (attributesToAdd.length > 0){
		    html += asHTMLOpenTag("li", attributesToAdd);
		} else {
		    html += asHTMLOpenTag("li");
		}
		
		html += asHTMLContainer("a", asHTMLAttribute("href", theLink), theMenu[menuItem].title);
		html += asHTMLCloseTag("li");		
	}
	
	html += asHTMLCloseTag("ul");
	// html += asHTMLContainer("div", asHTMLAttribute("style", "color: red;"), "menu from javascript");
	
	document.write(html);		
}


