// taherscript.js
// provides misc javascript functions for taher school template website
// Ben Willard - 2006
//

// changed 7-27-2006: moved random img swap code from here to individual files [faster load times w/ that implementation]


// setCurMonth: sets the Select item on the menu page to the correct month
// sets one month ahead of current month if date is in the last 7 days of the month
function setCurMonth()
{
	// if it is currently seven or less days until the new month, use the new month.
	var myDate=new Date();
	var myMonth = myDate.getMonth();
	var myMDay = myDate.getDate();

	monthDays = new Array(12);
	monthDays[0] = 31;
	monthDays[1] = 28; 
	monthDays[2] = 31;
	monthDays[3] = 30;
	monthDays[4] = 31;
	monthDays[5] = 30;
	monthDays[6] = 31;
	monthDays[7] = 31;
	monthDays[8] = 30;
	monthDays[9] = 31;
	monthDays[10] = 30;
	monthDays[11] = 31;

	if (myMDay > (monthDays[myMonth] - 7))
	{
		myMonth++;
		if (myMonth > 11)
		{
			myMonth = 0;
		}
	}

	document.monthForm.monthSelect.selectedIndex = myMonth;
}

// clickMenu: links schools and month select box to the proper file in Documents/Menus/...
// feel free to add more options to the menuNames array - just make sure that the files exist in all month folders
// in the Documents/Menus/ directory
function clickMenu(menuClicked)
{
	// if you wish to add more menus
	// add elements to the array
	// and then pass the correct array index to clickMenu for the onClick method for your link
	var selectedMonth = document.monthForm.monthSelect.selectedIndex;
	var menuNames = new Array();
	menuNames[0] = "Lunch 1";
	menuNames[1] = "Lunch 2";
	menuNames[2] = "Lunch 3";
	menuNames[3] = "Lunch 4";
	menuNames[4] = "Lunch 5";
	menuNames[5] = "Lunch 6";
	menuNames[6] = "Lunch 7";
	menuNames[7] = "Lunch 8";
	menuNames[8] = "Breakfast 1";
	menuNames[9] = "Breakfast 2";
	menuNames[10] = "Breakfast 3";
	menuNames[11] = "Breakfast 4";
	window.open("Documents/Menus/" + document.monthForm.monthSelect.options[document.monthForm.monthSelect.selectedIndex].text + "/" + menuNames[menuClicked] + ".pdf");
}

