/////////////////////////////////////////////
/*	INSTRUCTIONS  

	To add new menus, use this syntax: nameofmenu = new menu();
	To add topics, use this syntax: nameofmenu.addTopic(nameoftopic,url,idnumber)
	To add subtopics, use this syntax: nameofmenu.addSubtopic(nameofsubtopic,url,parenttopic,idnumber)
	Include this whole file in each page you need a menu displayed.
	In the html file, use this syntax to display the appropriate topic menu:
	   nameofmenu.display() 				(if menu is to be displayed without any highlighting)
	   nameofmenu.display(topicnumber) 			(if you want a specific topic highlighted)
	   nameofmenu.display(topicnumber,subtopicnumber) 	(if you want a specific subtopic highlighted)
  	   nameofmenu.oneLine(topicnumber)			(if you just want a specific topic)
	   nameofmenu.oneLine(topicnumber,subtopicnumber)	(if you just want a specific subtopic)

	Advanced Features:
	For each menu, you can specify these properties: color, hcolor, font, fontsize, subfontsize. If not specified, they will be set to default
	   Use this syntax to do so: nameofmenu.nameofproperty = "whatever" (remember to put it in quotes!) 
	
*/
/////////////////////////////////////////////
//	MODIFY CODE BELOW //////////////////
////////////////////////////////////////////
var idea;
metrop=new menu();

metrop.addTopic('Menu','main.htm',3)
metrop.addTopic('The Metropolis Plan','5_3.htm',5)
metrop.addTopic('Technical Report','10_3.htm',10)
metrop.addTopic('Maps','15_3.htm',15)
metrop.addTopic('Presentation','20_3.htm',20)
metrop.addTopic('About Us','25_3.htm',25)





//////////////////////////////////////////////
//	DON'T TOUCH BELOW THIS LINE /////////
//////////////////////////////////////////////

document.write("<STYLE> \n .navlink {text-decoration: none} \n .navlink:hover {text-decoration: underline} \n </STYLE>")

function menu() {
   
   this.topics = new Array();
   this.color = '#236A00';
   this.hcolor = '#336633';
   this.font = 'Arial'
   this.fontsize= '1';
   this.subfontsize = '1';

   this.addTopic = addTopic;
   this.addSubtopic = addSubtopic;
   this.display = display;
   this.oneLine = oneLine;
   this.displayNavTable = displayNavTable;   
}

function addTopic(tname,url,index) {
   if (arguments.length != 3) { alert("Because of bad syntax, " + arguments[0] + " was not added."); return false }
   if (this.topics[index]) {alert("You overwrote " + this.topics[index][0].toUpperCase() + " with " + tname.toUpperCase()); }
   if (index) {this.topics[index] = new Array(tname, url); }
   else { alert("Please specify an index for " + tname); } 
}

function addSubtopic(sname,url,tindex,sindex) {
   if (arguments.length != 4) {alert('Your subtopic syntax for ' + arguments[0] + ' is wrong');return}
   if (!this.topics[tindex]["subtopics"]) { 
	this.topics[tindex]["subtopics"] = new Array();  
   }
   this.topics[tindex]["subtopics"][sindex] = new Array(sname,url);   
}

function oneLine(topic,stopic) {
   if (arguments.length == 2) { document.write(this.topics[topic]["subtopics"][stopic][0]) }
   else if (arguments.length == 1) { document.write(this.topics[topic][0]) }
   else {alert("Wrong number of arguments in oneLine");return}
}

function display(htopic,hsubtopic) {
   for (i=0;i<this.topics.length;i++) { 		// until highest topic index
     if (this.topics[i]) { 				// if topic index has a value
	document.write("<FONT SIZE=1><BR></FONT>"); 			// add break between topics
	if (i == htopic && !hsubtopic) { document.write("<B><FONT FACE='" + this.font + "' COLOR=" + this.hcolor + " SIZE = " + this.fontsize + ">" + this.topics[i][0] + "</FONT></B><BR>") }  // if this is the topic to be highlighted, and there is no subtopic to be highlighted 	   
	else if (this.topics[i][1] == null) { document.write("<FONT FACE='" + this.font + "' COLOR=" + this.color + " SIZE = " + this.fontsize +">" + this.topics[i][0] + "</FONT><BR>") }
	else { document.write("<A HREF='" + this.topics[i][1] + "' CLASS='navlink'><FONT FACE='" + this.font + "' COLOR=" + this.color + " SIZE = " + this.fontsize +">" + this.topics[i][0] + "</A></FONT><BR>") }
	if (i == htopic  && this.topics[i]["subtopics"]) {		// if that topic has subtopics
	   for (j=0;j<this.topics[i]["subtopics"].length;j++) {	// until highest subtopic index
		if (this.topics[i]["subtopics"][j]) {		// if that subtopic has a value
	      	   if (j == hsubtopic) {document.write("<FONT FACE='" + this.font + "' COLOR=" + this.hcolor + " SIZE = " + this.subfontsize + ">&nbsp;&nbsp;&nbsp;-" + this.topics[i]["subtopics"][j][0] + "</FONT><BR>")}
		   else {document.write("<FONT FACE='" + this.font + "' COLOR=" + this.color + " SIZE = " + this.subfontsize + ">&nbsp;&nbsp;&nbsp;-</FONT><A HREF='" + this.topics[i]["subtopics"][j][1] + "' CLASS='navlink'><FONT FACE='" + this.font + "' COLOR=" + this.color + " SIZE = " + this.subfontsize + ">" + this.topics[i]["subtopics"][j][0] + "</A></FONT><BR>")}
		}	
	   }
	}
     }
   }
} 



function displayNavTable() {
   for (i=0;i<this.topics.length;i++) { 		// until highest topic index
     if (this.topics[i]) { 				// if topic index has a value
	document.write(this.topics[i][0] + " has index of " + i + "<BR>")
        if (this.topics[i]["subtopics"]) {		// if that topic has subtopics
	   for (j=0;j<this.topics[i]["subtopics"].length;j++) {	// until highest subtopic index
		if (this.topics[i]["subtopics"][j]) {		// if that subtopic has a value
	      	   document.write("&nbsp;&nbsp;&nbsp;" + this.topics[i]["subtopics"][j][0] + " has subindex of " + j +"<BR>")
		}
     	   }
	}
     }
   } 
}

   