/*Defines a LinkNode class. New LinkNodes need a name and an associaed link when created as objects.*/
function LinkNode(name, link) {
	this.name = name;
	this.link = link;
}

/*Inserts the header as HTML code. Call this method at the top of the appropriate pages.*/
function drawHeader() {
	document.write("<table class='header'><td class='logocell'><a href='http://www.calpoly.edu/~glbclub'><img class='logo' src='http://www.calpoly.edu/~glbclub/old stuff/spectrum.jpg' /></a></td>"); //starts the table and inserts the Spectrum logo
	document.write("<td class='textcell'><span class='headertext'>Spectrum: Cal Poly's<br/>Gender and Sexuality Alliance</span></td></tr></table>"); //inserts the header text and finishes the table
}

/*Inserts the header menu in HTML code. Call this method below drawHeader().*/
function drawMenu() {
	var allLinkNodes = new Array(); //creates an empty array into which the LinkNodes will be placed after their creation below
	allLinkNodes.push(new LinkNode("Home","index.html"));
	allLinkNodes.push(new LinkNode("News","news.html"));
	allLinkNodes.push(new LinkNode("Events","events.html"));
	allLinkNodes.push(new LinkNode("Resources","resources.html"));
	allLinkNodes.push(new LinkNode("About","about.html"));
	allLinkNodes.push(new LinkNode("People and Contacts","people.html"));
	/*Note: If you add more links above, the table should automatically reformat. Hooray for elegant code.*/
	
	var returnText = new String(); //sets up a new string  so that the proper HTML can be constructed piece by piece
	returnText += "<table class='menu'><tr>"; //first, start the link table
	for(var i = 0; i < allLinkNodes.length; i++) { //for each LinkNode in the list created above...
		returnText += "<td class='menucell"; //start a new table cell in HTML and add it to our growing text string
		if (i == 0) {returnText += " left";} //if it's the first link, add the "left" style attribute so it's pretty
		if (i == allLinkNodes.length - 1) {returnText += " right";} //if it's the last link, add the "right" style attribute so it, too, is pretty
		if (i > 0 && i < allLinkNodes.length - 1) {returnText += " middle";} //if it's neither "left" nor "right," it must be "middle"
		if (location.href.match(allLinkNodes[i].link) != null) {returnText += " accent";} //if the link is the one that's currently selected, accent the corresponding cell
		returnText += "' style='width: " + (100/allLinkNodes.length) + "%;'>"; //distribute the cells' widths evenly
		if (location.href.match(allLinkNodes[i].link) == null) { //if the link is NOT the one currently selected
			returnText += "<a class='nav' href='" + allLinkNodes[i].link + "'>" + allLinkNodes[i].name + "</a>"; //make the text to the page a link
		}
		else { //otherwise
			returnText += allLinkNodes[i].name; //just put the link name as text
		}
		returnText += "</td>"; //end this cell and go to the next one
	}
	returnText += "</tr></table>"; //finish the table
	document.write(returnText); //implement the generated HTML
}

/*Inserts the footer in HTML. This should be self-explanatory. Call at the bottom of the appropriate pages.*/
function drawFooter() {
	document.write("<div class='footer'>");
	document.write("<a href='http://validator.w3.org/check?uri=referer'><img src='http://www.w3.org/Icons/valid-xhtml11' alt='Valid XHTML 1.1' height='31' width='88' style='border-width: 0px; margin: 0px 5px 8px' /></a>"); //XHTML validation
	document.write("<a href='http://jigsaw.w3.org/css-validator/check/referer'><img style='border:0;width:88px; height:31px; margin: 0px 5px 8px;' src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' /></a>"); //CSS validation
	
	document.write("<!-- Start of StatCounter Code -->\n<script type='text/javascript'>\nvar sc_project=4953145;\nvar sc_invisible=1;\nvar sc_partition=57;\nvar sc_click_stat=1;\nvar sc_security='afed529e';\n</script>"); //StatCounter link
	document.write("<script type='text/javascript' src='http://www.statcounter.com/counter/counter_xhtml.js'></script>\n<!-- End of StatCounter Code -->");

	document.write("<a href='http://my.statcounter.com/project/standard/stats.php?project_id=4953145&guest=1'><img src='http://www.statcounter.com/images/button2.gif' alt='StatCounter' style='border:0;width:88px;height:31px;margin: 0px 5px 8px;' /></a>");
	
	
	document.write("<br />");
	document.write("&copy; 2010 by Spectrum. Website design by Ed Foley. Header picture by Alex Bendoyro.</div>"); //credit where credit is due
}
