/*
 *                          *****************
 *                          *   Dennis So   *
 *                          *****************
 *
 *                          Extracurricular Activities
 *                          School Days
 *                          #1
 *
 *							Wednesday, September 30, 2009
 */

var d = new Date();
var date = d.getDate();
var day = d.getDay();

function schoolDay5(){
	var weekNo = Math.ceil(date/7); //See bottom of the page to see how it works
	if (weekNo == 1){
		return 1;
	}
	else if (weekNo == 2){	//Every fifth week is a Day 1
		return 2; 
	}
	else if (weekNo == 3){	//Every fifth week is a Day 1
		return 1; 
	}
	else if (weekNo == 4){	//Every fifth week is a Day 1
		return 2; 
	}
	else if (weekNo == 5){	//Every fifth week is a Day 1
		return 1; 
	}
	else{
		return 0;	//Error
	}
}

//function schoolDay(){
//	if (day >= 1 && day <= 4){	//Return regular day
//		return day;
//	}
//	else if (day == 5){
//		return schoolDay5();	//Call function to find school day on a Friday
//	}
//	else {
//		return 0;	//Weekend or error
//	}
//}

function displaySchoolDay(){
	var docBody = document.getElementsByTagName("body").item(0);
	var schoolDayText = document.createTextNode ("Week " + weekNo());
	docBody.appendChild(schoolDayText);
	//document.write("Day ", schoolDay()) //Display the school day in this format "Day X"
}

/*
The equation, Math.ceil(date/7), finds the week number of the month because 
every week has 7 days. By dividing the current date by 7 and always rounding up, we can find
the week number.

To illustrate, the dates in the:
1st week is always between 1 and 7.
2nd week is always between 8 and 14.
3rd week is always between 15 and 21.
4th week is always between 22 and 28.
5th week is always greater than 29.
*/

