// renderNav.js
// Stores the list of items on the array then displays according to the pageID

var image_path = "/education/isef/profiles/pix/";
var spacer = "/education/pix/spacer.gif";	// default location for spacer gif
var bullet_round = "<IMG SRC=\"/education/pix/left_nav/round_bul.gif\" WIDTH=\"8\" HEIGHT=\"8\" BORDER=\"0\" ALT=\"\" VSPACE=\"3\">";
var bullet_arrow = "<IMG SRC=\"/education/pix/left_nav/arrow_bul.gif\" WIDTH=\"8\" HEIGHT=\"11\" BORDER=\"0\" ALT=\"\" VSPACE=\"3\">";

var bullet;
var arrayID;

var curSize = 0;
var itemArray = null;

function instantiateArray(){
	itemArray = new Array(100);
	
	for(temp = 0; temp < 100; temp++)
		itemArray[temp] = new Array(4);
}

function addItems (id, title, url, level) {
	itemArray[curSize][0] = id;
	itemArray[curSize][1] = title;
	itemArray[curSize][2] = url;
	itemArray[curSize][3] = level;
	
	curSize++;
}

function renderNav (pageID) {

	var temp;
	
	for(temp = 0; temp < curSize; temp++){
		if (pageID == itemArray[temp][0])
			arrayID = temp;
	}
	
	// Start Table
	document.write("<TABLE WIDTH=\"135\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" ALIGN=\"center\">\n");
	
	for(temp = 0; temp < curSize; temp++){

		// set cell background color; light yellow when highlighted
		
		if (itemArray[temp][0] == pageID)
			title = "<FONT CLASS=\"newsnav\" COLOR=\"#000000\">" + itemArray[temp][1] + "</FONT>";
		else
			title = itemArray[temp][1];
			
		// display list of items according to the level#
		if (itemArray[temp][3] == 0) {
					
			document.write("<TR>\n");
			document.write("	<TD WIDTH=\"10\" VALIGN=\"top\">" + bullet_round + "</TD>\n");
			document.write("	<TD WIDTH=\"125\" VALIGN=\"top\" COLSPAN=\"2\" CLASS=\"newsnav\"><FONT CLASS=\"newsnav\"><A HREF=\"" + itemArray[temp][2] + "\"><B>" + title + "</B></A></FONT><BR>\n");
			document.write("		<IMG SRC=\"" + spacer + "\" WIDTH=\"1\" HEIGHT=\"3\" BORDER=\"0\" ALT=\"\"></TD>\n");
			document.write("</TR>\n");
	
		} else {
		
			//if current level # is same as the selected pageID, display child links
			if ((itemArray[temp][3] == itemArray[arrayID][3]) || (itemArray[temp][3] == itemArray[arrayID][0])) {

				document.write("<TR>\n");
				document.write("	<TD WIDTH=\"10\"><IMG SRC=\"" + spacer + "\" WIDTH=\"10\" HEIGHT=\"1\" BORDER=\"0\" ALT=\"\"></TD>\n");
				document.write("	<TD WIDTH=\"10\" VALIGN=\"top\">" + bullet_arrow + "</TD>\n");
				document.write("	<TD WIDTH=\"115\" VALIGN=\"top\" CLASS=\"newsnav\"><FONT CLASS=\"newsnav\"><A HREF=\"" + itemArray[temp][2] + "\">" + title + "</A></FONT><BR>\n");
				document.write("		<IMG SRC=\"" + spacer + "\" WIDTH=\"1\" HEIGHT=\"3\" BORDER=\"0\" ALT=\"\"></TD>\n");
				document.write("</TR>\n");
			}
		}
	}
	
	// End table
	document.write("</TABLE>\n");
}

function renderTopnav(sectionID, pageID) {

	var bgcolor;
	var header;
	var slideheader;
	
	if (sectionID == 'design') {
		bgcolor = "#66CC00";
		header = "<IMG SRC=\"/education/institutes/pix/top_presentation.gif\" WIDTH=\"127\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Presentation\">";
		slideheader = "<IMG SRC=\"/education/institutes/design/pix/header.gif\" WIDTH=\"378\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"An Introduction to Design and Discovery\">";
	} else if (sectionID == 'intro') {
		bgcolor = "#9933CC";
		header = "<IMG SRC=\"/education/institutes/pix/top_introduction.gif\" WIDTH=\"240\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Orientation and Overview\">";
		slideheader = "<IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"1\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"\">";
	} else if (sectionID == 'iwb') {
		bgcolor = "#a6a6a6";
		header = "<IMG SRC=\"/education/institutes/pix/top_workshop.gif\" WIDTH=\"104\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Workshop\">";
		slideheader = "<IMG SRC=\"/education/institutes/iwb/pix/header.gif\" WIDTH=\"225\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Ideas Worth Borrowing\">";
	} else if (sectionID == 'wildride') {
		bgcolor = "#a6a6a6";
		header = "<IMG SRC=\"/education/institutes/pix/top_workshop.gif\" WIDTH=\"104\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Workshop\">";
		slideheader = "<IMG SRC=\"/education/institutes/wild_ride/pix/header.gif\" WIDTH=\"385\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"It's a Wild Ride\">";
	} else if (sectionID == 'emergingtech') {
		bgcolor = "#a6a6a6";
		header = "<IMG SRC=\"/education/institutes/pix/top_workshop.gif\" WIDTH=\"104\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Workshop\">";
		slideheader = "<IMG SRC=\"/education/institutes/emerging_tech/pix/header.gif\" WIDTH=\"342\" HEIGHT=\"21\" BORDER=\"0\" ALT=\"Emerging Technologies in Education\">";
	} else if (sectionID == 'seeingreason') {
		bgcolor = "#a6a6a6";
		header = "<IMG SRC=\"/education/institutes/pix/top_workshop.gif\" WIDTH=\"104\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Workshop\">";
		slideheader = "<IMG SRC=\"/education/institutes/seeing_reason/pix/header.gif\" WIDTH=\"366\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Supporting Cause-and-Effect Thinking\">";
	} else {
		bgcolor = "#a6a6a6";
		header = "<IMG SRC=\"/education/institutes/pix/top_workshop.gif\" WIDTH=\"104\" HEIGHT=\"20\" BORDER=\"0\" ALT=\"Workshop\">";
		slideheader = "<IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"1\" HEIGHT=\"21\" BORDER=\"0\" ALT=\"\">";
	}
	
	document.write("<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n");
	document.write("<TR>\n");
	document.write("	<TD WIDTH=\"145\" BGCOLOR=\"#0033FF\" ROWSPAN=\"2\"><A HREF=\"/education/index.htm\"><IMG SRC=\"/education/institutes/pix/top_iielogo.gif\" WIDTH=\"155\" HEIGHT=\"61\" BORDER=\"0\" ALT=\"Intel(R) Innovation in Education\"></A></TD>\n");
	document.write("	<TD WIDTH=\"100%\" COLSPAN=\"2\" BGCOLOR=\"#3366FF\" ALIGN=\"right\" BACKGROUND=\"/education/institutes/pix/top_border_btm.gif\">\n");
	document.write("		<TABLE WIDTH=\"615\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n");
	document.write("		<TR>\n");
	document.write("			<TD WIDTH=\"612\" VALIGN=\"bottom\"><IMG SRC=\"/education/institutes/pix/slide_header.gif\" WIDTH=\"612\" HEIGHT=\"25\" BORDER=\"0\" ALT=\"Intel(R) Innovation in Education Institutes\"><BR>\n");
	document.write("				<IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"612\" HEIGHT=\"3\" BORDER=\"0\" ALT=\"\"></TD>\n");
	document.write("			<TD WIDTH=\"3\"><IMG SRC=\"/education/institutes/pix/top_border_right.gif\" WIDTH=\"3\" HEIGHT=\"41\" BORDER=\"0\" ALT=\"\"></TD>\n");
	document.write("		</TR>\n");
	document.write("		</TABLE>\n");
	document.write("	</TD>\n");
	document.write("</TR>\n");
	document.write("<TR>\n");
	document.write("	<TD WIDTH=\"1\" BGCOLOR=\"#a6a6a6\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"1\" HEIGHT=\"1\" BORDER=\"0\" ALT=\"\"></TD>\n");
	document.write("	<TD WIDTH=\"100%\" BGCOLOR=\"" + bgcolor + "\">\n");
	document.write("		<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n");
	document.write("		<TR>\n");
	document.write("			<TD WIDTH=\"50%\">" + header + "</TD>\n");
	document.write("			<TD WIDTH=\"50%\" ALIGN=\"right\">" + slideheader + "</TD>\n");
	document.write("		</TR>\n");
	document.write("		</TABLE>\n");
	document.write("	</TD>\n");
	document.write("</TR>\n");
	document.write("<TR>\n");
	document.write("	<TD WIDTH=\"145\"><A HREF=\"/education/index.htm\"><IMG SRC=\"/education/institutes/pix/top_education_home.gif\" WIDTH=\"155\" HEIGHT=\"18\" BORDER=\"0\" ALT=\"Education Home\"></A></TD>\n");
	document.write("	<TD WIDTH=\"1\" BGCOLOR=\"#a6a6a6\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"1\" HEIGHT=\"1\" BORDER=\"0\" ALT=\"\"></TD>\n");
	document.write("	<TD WIDTH=\"100%\" ALIGN=\"right\" VALIGN=\"bottom\">\n");

	renderButtons(pageID);
	
	document.write("	</TD>\n");
	document.write("</TR>\n");
	document.write("</TABLE>\n");
		
}

function renderButtons(pageID) {

	var temp;
	var slide_num;
	
	for(temp = 0; temp < curSize; temp++){
		if (pageID == itemArray[temp][0])
			arrayID = temp;
	}
	
	slide_num = arrayID + 1;
	
	document.write("<TABLE WIDTH=\"135\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" ALIGN=\"right\">\n");
	document.write("\t\t\t\t<TR>\n");
	
	if (arrayID == 1) {
		document.write("\t\t\t\t\t<TD WIDTH=\"94\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"94\" HEIGHT=\"1\" BORDER=\"0\"></TD>\n");
		document.write("\t\t\t\t\t<TD WIDTH=\"41\"><A HREF=\"" + itemArray[arrayID+1][2] + "\"><IMG SRC=\"" + image_path + "btn_next.gif\" WIDTH=\"41\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Next\" ALIGN=\"middle\"></A></TD>");
	} else if (arrayID == curSize - 1) {
		document.write("\t\t\t\t\t<TD WIDTH=\"74\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"74\" HEIGHT=\"1\" BORDER=\"0\"></TD>");
		document.write("\t\t\t\t\t<TD WIDTH=\"61\"><A HREF=\"" + itemArray[arrayID-1][2] + "\"><IMG SRC=\"" + image_path + "btn_prev.gif\" WIDTH=\"61\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Previous\" ALIGN=\"middle\"></A></TD>");
	} else if (itemArray[arrayID][3] != 0) {
	
		if (itemArray[arrayID-1][3] == 0) {
			document.write("\t\t\t\t\t<TD WIDTH=\"61\"><A HREF=\"" + itemArray[arrayID-2][2] + "\"><IMG SRC=\"" + image_path + "btn_prev.gif\" WIDTH=\"61\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Previous\" ALIGN=\"middle\"></A></TD>");
			document.write("\t\t\t\t\t<TD WIDTH=\"33\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"33\" HEIGHT=\"1\" BORDER=\"0\"></TD>\n");
			document.write("\t\t\t\t\t<TD WIDTH=\"41\"><A HREF=\"" + itemArray[arrayID+1][2] + "\"><IMG SRC=\"" + image_path + "btn_next.gif\" WIDTH=\"41\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Next\" ALIGN=\"middle\"></A></TD>");
		} else if (itemArray[arrayID+1][3] == 0) {
			document.write("\t\t\t\t\t<TD WIDTH=\"61\"><A HREF=\"" + itemArray[arrayID-1][2] + "\"><IMG SRC=\"" + image_path + "btn_prev.gif\" WIDTH=\"61\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Previous\" ALIGN=\"middle\"></A></TD>");
			document.write("\t\t\t\t\t<TD WIDTH=\"33\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"33\" HEIGHT=\"1\" BORDER=\"0\"></TD>\n");
			document.write("\t\t\t\t\t<TD WIDTH=\"41\"><A HREF=\"" + itemArray[arrayID+2][2] + "\"><IMG SRC=\"" + image_path + "btn_next.gif\" WIDTH=\"41\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Next\" ALIGN=\"middle\"></A></TD>");
		} else if ((itemArray[arrayID-1][3] == 0) && (itemArray[arrayID+1][3] == 0)) {
			document.write("\t\t\t\t\t<TD WIDTH=\"61\"><A HREF=\"" + itemArray[arrayID-2][2] + "\"><IMG SRC=\"" + image_path + "btn_prev.gif\" WIDTH=\"61\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Previous\" ALIGN=\"middle\"></A></TD>");
			document.write("\t\t\t\t\t<TD WIDTH=\"33\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"33\" HEIGHT=\"1\" BORDER=\"0\"></TD>\n");
			document.write("\t\t\t\t\t<TD WIDTH=\"41\"><A HREF=\"" + itemArray[arrayID+2][2] + "\"><IMG SRC=\"" + image_path + "btn_next.gif\" WIDTH=\"41\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Next\" ALIGN=\"middle\"></A></TD>");
		} else {
			document.write("\t\t\t\t\t<TD WIDTH=\"61\"><A HREF=\"" + itemArray[arrayID-1][2] + "\"><IMG SRC=\"" + image_path + "btn_prev.gif\" WIDTH=\"61\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Previous\" ALIGN=\"middle\"></A></TD>");
			document.write("\t\t\t\t\t<TD WIDTH=\"33\"><IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"33\" HEIGHT=\"1\" BORDER=\"0\"></TD>\n");
			document.write("\t\t\t\t\t<TD WIDTH=\"41\"><A HREF=\"" + itemArray[arrayID+1][2] + "\"><IMG SRC=\"" + image_path + "btn_next.gif\" WIDTH=\"41\" HEIGHT=\"14\" BORDER=\"0\" ALT=\"Next\" ALIGN=\"middle\"></A></TD>");
		}
	}

	document.write("\t\t\t\t</TR>\n");
	document.write("\t\t\t\t</TABLE>\n");
	document.write("\t\t\t\t<BR>\n<IMG SRC=\"" + spacer + "\" WIDTH=\"1\" HEIGHT=\"10\" BORDER=\"0\"><BR>");
}

function renderLinks() {
	// displays buttons on the left nav
	document.write("\t\t<A HREF=\"/education/index.htm\"><IMG SRC=\"/education/isef/profiles/pix/top_education_home.gif\" WIDTH=\"155\" HEIGHT=\"18\" BORDER=\"0\" ALT=\"Education Home\"></A><BR>\n");
	document.write("\t\t<A HREF=\"/education/isef/index.htm\"><IMG SRC=\"/education/isef/profiles/pix/top_isef_home.gif\" WIDTH=\"155\" HEIGHT=\"18\" BORDER=\"0\" ALT=\"Intel ISEF\"></A><BR>\n");
	document.write("\t\t<A HREF=\"/education/isef/profiles.htm\"><IMG SRC=\"/education/isef/profiles/pix/top_profiles_home.gif\" WIDTH=\"155\" HEIGHT=\"18\" BORDER=\"0\" ALT=\"Profiles of Success\"></A><BR>\n");
	document.write("\t\t<IMG SRC=\"/education/institutes/pix/top_leftnav.gif\" WIDTH=\"155\" HEIGHT=\"9\" BORDER=\"0\" ALT=\"\"><BR>\n");
	document.write("\t\t<IMG SRC=\"/education/pix/spacer.gif\" WIDTH=\"1\" HEIGHT=\"25\" BORDER=\"0\" ALT=\"\"><BR>\n");
}