// JavaScript code for Whittier Regional Vocational Technical High School
// Author: Scott Abrams
//
// 01-08-04:  Fix to doTopMenu():  code fix for Netscape 4.8 to properly get value from element in select field
//  01-08-04:  Fix to doTechMenu():  character code change for bullet point to fix Netscape 4.8 bug
//
//****************************************************************************

// get date info
var today = new Date();
var year = today.getYear();
if (year < 2000) {
	year = year + 1900;
}
var currYear = year;
var month = today.getMonth();
var currMonth = month;
var currDay = today.getDate();
var currDayOfWeek = today.getDay();

// set up array for months
var arrMonthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var strMonthName = arrMonthName[month];

// set up array for days of the week
var arrDayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

// writes out string for today's date
var currDate = arrDayName[currDayOfWeek] + "<br>" + arrMonthName[currMonth] + " " + currDay + ", " + currYear;

//****************************************************************************
//* Returns: writes out the title, correct version of the css file, and page-related styles
//* There is one css file for IE4+ and Netscape4+ broswers
//****************************************************************************

document.write("<title>Whittier Regional Vocational Technical High School : " + pageId + "</title>");
document.write("<link rel=stylesheet type=\"text/css\" href=\"styles.css\">");

//****************************************************************************
//* Name:  switchImg
//* Parameters:	imageName = the image name in the <IMG> tag
//				imgageSrc = an image file with complete path
//* Returns:
//* Notes: assigns the image to the document object
//* Usage: eg. onMouseOver="switchImg('imageName', 'images/image.gif')"
//****************************************************************************

function switchImg(imageName, imageSrc) {
	if (document.images) {
    	document.images[imageName].src = imageSrc;
	}
}// end switchImg

//****************************************************************************
//* Name:  doHeader
//* Parameters:	strSubTopic = page name (comes from variables on top of each individual page)
//* Returns: header with logo, school name and page name
//* Usage: goes in body right in between the <!-- nested table for header -->
//* and <!-- end header --> tags
//****************************************************************************

function doHeader(strPage) {
	var head = "";
	head += "\t<table cellspacing=0 cellpadding=3 border=0>\n";
	head += "\t<tr>\n";
	head += "\t\t<!-- school logo -->\n";
	head += "\t\t<td rowspan=2 width=75><a href=\"http://www.whittier.mec.edu\"><img src=\"images/wtlogoflash.gif\" width=100 height=60 border=0 alt=\"\"></a></td>\n";
	head += "\t\t<!-- school name -->\n";
	head += "\t\t<td colspan=2 valign=bottom nowrap class=\"headSchool\" width=\"100%\">Whittier Regional Vocational Technical High School</td>\n";
	head += "\t</tr>\n";
	head += "\t<tr>\n";
	head += "\t\t<!-- page name -->\n";
	if (strPage == "Home" || strPage == "") {
		head += "\t\t<td valign=top class=\"headPage\"><font color=\"#ffffff\">WORKING</font> on your <font color=\"#ffffff\">FUTURE</font></td>\n";
	} else {
		head += "\t\t<td valign=top class=\"headPage\">" + strPage + "</td>\n";
	}
	head += "\t\t<td align=right valign=top class=\"textBody\">" + currDate + "</td>\n";
	head += "\t</tr>\n";
	head += "\t</table>\n";
	document.write(head);
}// end doHeader

//****************************************************************************
//* Name:  getOptions
//* Parameters:	none
//* Returns: list of options that go in <select></select> tags in dropdown list in top menu
//* Combs through Main Menu array and each subsequent submenu array, pulling out page names and urls and pushing them into a new array. Then sorts the array alphabetically.
//* Usage: menu += getOptions();
//****************************************************************************

function getOptions() {
	var arrBox = new Array();
	var strBox = "";
	var arrTmp = "";
	for (i = 0; i < arrMain.length; i++) { // main topic pages
		arrBox[arrBox.length] = arrMain[i][0] + "|" + arrMain[i][1];
		for (t = 0; t < arrMain[i][2].length; t++) { // sub topic pages
			arrBox[arrBox.length] = arrMain[i][2][t][0] + "|" + arrMain[i][2][t][1];
		}
	}
//****************************************************
//* The following 12 lines of code were removed on July 1, 2008
//* They were removed so the "Top Menu" work
//* Changes to the "left Menu" on that date caused issues in this code
//* Changes completed by Richard Porcelli
//****************************************************
	//for (s = 0; s < arrTechList.length; s++) { // tech. programs pages
	//	arrBox[arrBox.length] = arrTechList[s][0] + "|" + arrTechList[s][1];
	//}
	//for (x = 0; x < arrProg.length; x++) { // programs of study pages
	//	arrBox[arrBox.length] = arrProg[x][0] + "|" + arrProg[x][1];
	//}
	//for (x = 0; x < arrStudList.length; x++) { // student activity pages
	//	arrBox[arrBox.length] = arrStudList[x][0] + "|" + arrStudList[x][1];
	//}
	//for (x = 0; x < arrServList.length; x++) { // student-operated services pages
	//	arrBox[arrBox.length] = arrServList[x][0] + "|" + arrServList[x][1];
	//}
	arrBox.sort();
	// alert(arrBox.length);
	for (b = 0; b < arrBox.length; b++) {
		arrTmp = arrBox[b].split("|");
		if (arrTmp[0].toLowerCase() == pageId.toLowerCase()) {
			strBox += "<option value=\"" + arrTmp[1] + "\">" + arrTmp[0] + "</option>";
		} else {
			strBox += "<option value=\"" + arrTmp[1] + "\">" + arrTmp[0] + "</option>";
		}
	}
	// alert(strBox);
	return strBox;
} // end getOptions

//****************************************************************************
//* Name:  doTopMenu
//* Parameters:	none
//* Returns: top menu for basic links and dropdown listavailable on all pages
//* Usage: goes in body right in between the <!-- nested table for top menu -->
//* and <!-- end top menu --> tags
//****************************************************************************

function doTopMenu() {
	var menu = "";
	menu += "\t<table cellspacing=0 cellpadding=3 border=0 align=center>\n";
	menu += "\t<tr>\n";
	menu += "\t\t<td align=center class=\"textGold\">  <a href=\"https://ipass.whittier.tec.ma.us/school/ipass.wsc/syslogin.html\">iParent Login</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"index.htm\">Home</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"calendar.htm\">School Calendar</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"contact_info.htm\">Contact Info</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"mailto:comments@whittier.tec.ma.us\">E-Mail Us</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"sitemap.htm\">Site Map</a>&nbsp;&nbsp;</td>\n";
	// dropdown list of pages
	menu += "\t\t<form><td>";
	menu += "<select name=\"list\" onChange=\"if (list.selectedIndex != 0) { window.location=list[selectedIndex].value }\" class=\"drop\" length=15><option selected>Go to a Page \>\></option>";
	menu += getOptions();
	menu += "</select>";
	menu += "</td></form>\n";
	menu += "\t</tr>\n";
	menu += "\t</table>\n";
	document.write(menu);
}// end doTopMenu

//****************************************************************************
//* Name:  doLeftMenu
//* Parameters:	strTopic, strSubTopic = topic & page name (comes from variables on top of each individual page; pulls in all data from menu.js
//* Returns: left sided menu for more pages within topic
//* Usage: goes in body right in between the <!-- nested table for left menu -->
//* and <!-- end left menu --> tags
//****************************************************************************

function doLeftMenu(strTopic, strSubTopic) {
	var menu = "";
	menu += "\t<table cellspacing=5 cellpadding=0 border=0>\n";
	for (i = 0; i < arrMain.length; i++) {
		menu += "\t<tr>\n";
		if ((strTopic == arrMain[i][0]) && (arrMain[i][2].length == 0)) { // clicked-on topic WITHOUT a submenu
			menu += "\t\t<td valign=top><img src=\"images/shim.gif\" width=1 height=3 border=0 alt=\"\"><br><img src=\"images/arrow_roll.gif\" width=10 height=10 border=0 name=\"a" + i + "\"></td>\n";
			menu += "\t\t<td valign=top><a href=\"" + arrMain[i][1] + "\"><span class=\"textWhite\">" + arrMain[i][0] + "</span></a></td>\n";
		} else if ((strTopic.toLowerCase() == arrMain[i][0].toLowerCase()) && (arrMain[i][2].length > 0)) { // click-on topic WITH a submenu
			// checks to see if submenu page is clicked
			var subPage = false;
			for (t = 0; t < arrMain[i][2].length; t++) {
				// alert(strSubTopic);
				// alert(arrMain[i][2][t][0]);
				if (strSubTopic.toLowerCase() == arrMain[i][2][t][0].toLowerCase()) {
					subPage = true;
				}
			}
			// alert(subPage);
			if (subPage) { // submenu page is white, topic is gold
				menu += "\t\t<td valign=top><img src=\"images/shim.gif\" width=1 height=3 border=0 alt=\"\"><br><img src=\"images/arrow_down.gif\" width=10 height=10 border=0 name=\"a" + i + "\"></td>\n";
				menu += "\t\t<td valign=top><a href=\"" + arrMain[i][1] + "\" onMouseOver=\"switchImg('a" + i + "', 'images/arrow_down_roll.gif')\" onMouseOut=\"switchImg('a" + i + "', 'images/arrow_down.gif')\">" + arrMain[i][0] + "</a></td>\n";
			} else { // topic is white
				menu += "\t\t<td valign=top><img src=\"images/shim.gif\" width=1 height=3 border=0 alt=\"\"><br><img src=\"images/arrow_down_roll.gif\" width=10 height=10 border=0 name=\"a" + i + "\"></td>\n";
				menu += "\t\t<td valign=top><a href=\"" + arrMain[i][1] + "\"><span class=\"textWhite\">" + arrMain[i][0] + "</span></a></td>\n";
			}
			for (t = 0; t < arrMain[i][2].length; t++) {
				menu += "\t</tr>\n";
				menu += "\t<tr>\n";
				menu +=	"\t\t<td></td>\n";
				if (strSubTopic.toLowerCase() == arrMain[i][2][t][0].toLowerCase()) { // sub-topic is white
					menu += "\t\t<td><a href=\"" + arrMain[i][2][t][1] + "\"><span class=\"textWhite\">" + arrMain[i][2][t][0] + "</span></a></td>\n";
				} else { // sub-topic is gold
					menu += "\t\t<td><a href=\"" + arrMain[i][2][t][1] + "\">" + arrMain[i][2][t][0] + "</a></td>\n";
				}
			}
		} else { // all other topics
			menu += "\t\t<td valign=top><img src=\"images/shim.gif\" width=1 height=3 border=0 alt=\"\"><br><img src=\"images/arrow.gif\" width=10 height=10 border=0 name=\"a" + i + "\"></td>\n";
			menu += "\t\t<td valign=top><a href=\"" + arrMain[i][1] + "\" onMouseOver=\"switchImg('a" + i + "', 'images/arrow_roll.gif')\" onMouseOut=\"switchImg('a" + i + "', 'images/arrow.gif')\">" + arrMain[i][0] + "</a></td>\n";
		}
		menu += "\t</tr>\n";
	}
	// menu += "\t<tr>\n\t\t<td colspan=2 align=center><img src=\"images/cat_logo2.jpg\" width=75 height=89 border=0 alt=\"\" vspace=10></td>\n\t</tr>\n";
	menu += "\t</table>\n";
	// alert(menu)
	document.write(menu);
}// end doLeftMenu



//****************************************************************************
//* Name:  doTechProgMenu
//* Parameters:	none
//* Returns: horizontal list of tech programs
//* Usage: goes in bottom of content area after the <!-- Technical Programs Menu --> tag
//****************************************************************************

function doTechMenu() {
	var strTechMenu = "";
	var strBull = "";
	for (p = 0; p < arrTechList.length; p++) {
		strTechMenu += strBull + "<a href=\"" + arrTechList[p][1]  + "\"><span class=\"textMiniGold\">" + arrTechList[p][0]  + "</span></a>";
		strBull = " &#8226; ";
	}
	document.write(strTechMenu);
} // end doTechMenu

//****************************************************************************
//* Name: masterWindowOpen
//* Parameters: mstUrl the URL, mstName Name of the Window, 
//*				mstFeatures features for the window, mstX x-screen position, 
//*				mstY y-Screen position
//* Returns: nothing
//* Notes:  This function opens the window brings it to the front if it is already open and moves it to a specified (x, y) position
//* Usage: Only call this function from the other functions within this document 
//****************************************************************************

function masterWindowOpen(mstURL, mstName, mstFeatures, mstX, mstY) {
	var openWindow = window.open("", mstName, mstFeatures);
	openWindow.moveTo(mstX, mstY);
	openWindow.location.href = mstURL;
	return openWindow;
}

function doMonthPopUp(mstURL, mstName, mstWidth, mstHeight, mstX, mstY) {
	var mstFeatures = "width=" + mstWidth + ",height=" + mstHeight + ",scrollbars=no";
	masterWindowOpen(mstURL, mstName, mstFeatures, mstX, mstY);
}
//****************************************************************************
//* Name:  getQuerystring
//* Parameters:	pulls in value from querystring
//* Notes: returns value
//* Usage: just gets the value, does not write it out
//*   	   var strId = getQuerystring("id")
//*		   document.write(getQuerysting("id"))
//****************************************************************************

function getQuerystring(valName) {
	var strUrl = self.location + "";
	var strTmp = strUrl.split(valName + "=")[1];
	strTmp = strTmp.split("&")[0];
	if (strTmp == "undefined" || strTmp == null || strTmp == " ") {
		strTmp = "";
	}
	return unescape(strTmp);	
}



