var
	schoolYear = {

		'2008-08-19':'5',
		'2008-08-28':'6',
		// ...
		'2010-08-18':'M1',
		'2010-08-19':'1',
		'2010-08-20':'2',
		'2010-08-23':'3',
		'2010-08-24':'4',
		'2010-08-25':'5',
		'2010-08-26':'6',
		'2010-08-27':'1',
		'2010-08-30':'2',
		'2010-08-29':'3',

		'2010-09-01':'4c',
		'2010-09-02':'5',
		'2010-09-03':'6',
		'2010-09-06':'1',
		'2010-09-07':'h',
		'2010-09-08':'3',
		'2010-09-09':'4',
		'2010-09-10':'5',
		'2010-09-13':'6',
		'2010-09-14':'1',
		'2010-09-15':'2c',
		'2010-09-16':'3',
		'2010-09-17':'4',
		'2010-09-20':'5',
		'2010-09-21':'6',
		'2010-09-22':'1',
		'2010-09-23':'2',
		'2010-09-24':'3',
		'2010-09-27':'4',
		'2010-09-28':'5',
		'2010-09-29':'6',
		'2010-09-30':'1',
		'2010-10-01':'2',
		'2010-10-04':'3',
		'2010-10-05':'4',
		'2010-10-06':'5c',
		'2010-10-07':'6',
		'2010-10-08':'1',
		'2010-10-11':'2',
		'2010-10-12':'3',
		'2010-10-13':'4',
		'2010-10-14':'5',
		'2010-10-15':'6',
		'2010-10-18':'1',
		'2010-10-19':'2',
		'2010-10-20':'3c',
		'2010-10-21':'4',
		'2010-10-22':'5',
		'2010-10-25':'6',
		'2010-10-26':'1',
		'2010-10-27':'2',
		'2010-10-28':'3',
		'2010-10-29':'4',
		'2010-11-01':'5c',
		'2010-11-02':'6',
		'2010-11-03':'1',
		'2010-11-04':'2',
		'2010-11-05':'3',
		'2010-11-08':'4',
		'2010-11-09':'5',
		'2010-11-10':'6c',
		'2010-11-11':'h',
		'2010-11-12':'2',
		'2010-11-15':'3',
		'2010-11-16':'4',
		'2010-11-17':'5',
		'2010-11-18':'6',
		'2010-11-19':'1',
		'2010-11-22':'2',
		'2010-11-23':'3',
		'2010-11-24':'4m',
		'2010-11-29':'5',
		'2010-11-30':'2',
		'2010-12-01':'3c',
		'2010-12-02':'4',
		'2010-12-03':'5',
		'2010-12-06':'6',
		'2010-12-07':'1',
		'2010-12-08':'2',
		'2010-12-09':'3',
		'2010-12-10':'4',
		'2010-12-13':'5',
		'2010-12-14':'6',
		'2010-12-15':'m',
		'2010-12-16':'m',
		'2010-12-17':'m',
	

		'2011-01-03':'5',
		'2011-01-04':'6',
		'2011-01-05':'1c',
		'2011-01-06':'2',
		'2011-01-07':'3',
		'2011-01-10':'4',
		'2011-01-11':'5',
		'2011-01-12':'6',
		'2011-01-13':'1',
		'2011-01-14':'2',
		'2011-01-17':'3',
		'2011-01-18':'4',
		'2011-01-19':'5c',
		'2011-01-20':'6',
		'2011-01-21':'1',
		'2011-01-24':'2',
		'2011-01-25':'3',
		'2011-01-26':'4',
		'2011-01-27':'5',
		'2011-01-28':'6',
		'2011-01-31':'1',
		'2011-02-01':'2',
		'2011-02-02':'3',
		'2011-02-03':'4',
		'2011-02-04':'5',
		'2011-02-07':'6',
		'2011-02-08':'1',
		'2011-02-09':'2c',
		'2011-02-10':'3',
		'2011-02-11':'4',
		'2011-02-14':'4',
		'2011-02-15':'5',
		'2011-02-16':'6',
		'2011-02-17':'1',
		'2011-02-18':'2',
		'2011-02-28':'3',
		'2011-03-01':'4',
		'2011-03-02':'5c',
		'2011-03-03':'6',
		'2011-03-04':'1',
		'2011-03-07':'2',
		'2011-03-08':'3',
		'2011-03-09':'4',
		'2011-03-10':'5',
		'2011-03-11':'6',
		'2011-03-14':'1',
		'2011-03-15':'2',
		'2011-03-16':'3c',
		'2011-03-17':'4',
		'2011-03-18':'5',
		'2011-03-21':'6',
		'2011-03-22':'1',
		'2011-03-23':'2',
		'2011-03-24':'3',
		'2011-03-25':'4',
		'2011-04-28':'5',
		'2011-03-29':'6',
		'2011-03-30':'1',
		'2011-03-31':'2',
		'2011-04-01':'H',
		'2011-04-04':'H',
		'2011-04-05':'H',
		'2011-04-06':'H',
		'2011-04-07':'H',
		'2011-04-08':'H',
		'2011-04-11':'3',
		'2011-04-12':'4',
		'2011-04-13':'5',
		'2011-04-14':'6',
		'2011-04-15':'1',
		'2011-04-18':'2',
		'2011-04-19':'3',
		'2011-04-20':'4c',
		'2011-04-21':'5',
		'2011-04-22':'6',
		'2011-04-25':'1',
		'2011-04-26':'STAR2',
		'2011-04-27':'STAR3',
		'2011-04-28':'STAR4',
		'2011-04-29':'STAR5',
		'2011-05-02':'6',
		'2011-05-03':'1',
		'2011-05-04':'2c',
		'2011-05-05':'3',
		'2011-05-06':'4',
		'2011-05-09':'5',
		'2011-05-10':'6',
		'2011-05-11':'1',
		'2011-05-12':'2',
		'2011-05-13':'3',
		'2011-05-16':'4',
		'2011-05-17':'5',
		'2011-05-18':'6c',
		'2011-05-19':'1',
		'2011-05-20':'2',
		'2011-05-23':'3',
		'2011-05-24':'FINAL1',
		'2011-05-25':'FINAL1',
		'2011-05-26':'FINAL2',
		'2011-05-27':'FINAL3'


		

		
		
		

		
		
		
		
	},
	daySchedules = {
		'1':{
			'1°':'7:58 - 8:52',
			'2°':'8:58 - 9:52',
			'SSR':'9:58 - 10:16',
			'3°':'10:16 - 11:10',
			'4°':'11:16 - 12:10',
			'LUNCH':'12:10 - 12:45',
			'5°':'12:51 - 1:45',
			'6°':'1:51 - 2:45'
		},
		'2':{
			'2°':'7:58 - 8:52',
			'3°':'8:58 - 9:52',
			'SSR':'9:58 - 10:16',
			'4°':'10:16 - 11:10',
			'5°':'11:16 - 12:10',
			'LUNCH':'12:10 - 12:45',
			'6°':'12:51 - 1:45',
			'1°':'1:51 - 2:45'
		},
		'3':{
			'3°':'7:58 - 8:52',
			'4°':'8:58 - 9:52',
			'SSR':'9:58 - 10:16',
			'5°':'10:16 - 11:10',
			'6°':'11:16 - 12:10',
			'LUNCH':'12:10 - 12:45',
			'1°':'12:51 - 1:45',
			'2°':'1:51 - 2:45'
		},
		'4':{
			'4°':'7:58 - 8:52',
			'5°':'8:58 - 9:52',
			'SSR':'9:58 - 10:16',
			'6°':'10:16 - 11:10',
			'1°':'11:16 - 12:10',
			'LUNCH':'12:10 - 12:45',
			'2°':'12:51 - 1:45',
			'3°':'1:51 - 2:45'
		},
		'5':{
			'5°':'7:58 - 8:52',
			'6°':'8:58 - 9:52',
			'SSR':'9:58 - 10:16',
			'1°':'10:16 - 11:10',
			'2°':'11:16 - 12:10',
			'LUNCH':'12:10 - 12:45',
			'3°':'12:51 - 1:45',
			'4°':'1:51 - 2:45'
		},
		'6':{
			'6°':'7:58 - 8:52',
			'1°':'8:58 - 9:52',
			'SSR':'9:58 - 10:16',
			'2°':'10:16 - 11:10',
			'3°':'11:16 - 12:10',
			'LUNCH':'12:10 - 12:45',
			'4°':'12:51 - 1:45',
			'5°':'1:51 - 2:45'
		},
		'1st':{
			'HR°':'7:58 - 8:34',
			'1°':'8:40 - 9:08',
			'2°':'9:14 - 9:42',
			'3°':'9:48 - 10:16',
			'4°':'10:22 - 10:50',
			'BRUNCH':'10:50 - 11:10',
			'5°':'11:16 - 11:44',
			'6°':'11:50 - 12:18'
		},
		'6c':{
			'6°':'7:58 - 8:46',
			'1°':'8:52 - 9:40',
			'2°':'9:46 - 10:36',
			'3°':'10:42 - 11:30',
			'LUNCH':'11:30 - 12:05',
			'4°':'12:11 - 12:59',
			'5°':'1:05 - 1:53'
		},
		'5c':{
			'5°':'7:58 - 8:46',
			'6°':'8:52 - 9:40',
			'1°':'9:46 - 10:36',
			'2°':'10:42 - 11:30',
			'LUNCH':'11:30 - 12:05',
			'3°':'12:11 - 12:59',
			'4°':'1:05 - 1:53'
		},
		'4c':{
			'4°':'7:58 - 8:46',
			'5°':'8:52 - 9:40',
			'6°':'9:46 - 10:36',
			'1°':'10:42 - 11:30',
			'LUNCH':'11:30 - 12:05',
			'2°':'12:11 - 12:59',
			'3°':'1:05 - 1:53'
		},
		'3c':{
			'3°':'7:58 - 8:46',
			'4°':'8:52 - 9:40',
			'5°':'9:46 - 10:36',
			'6°':'10:42 - 11:30',
			'LUNCH':'11:30 - 12:05',
			'1°':'12:11 - 12:59',
			'2°':'1:05 - 1:53'
		},
		'2c':{
			'2°':'7:58 - 8:46',
			'3°':'8:52 - 9:40',
			'4°':'9:46 - 10:36',
			'5°':'10:42 - 11:30',
			'LUNCH':'11:30 - 12:05',
			'6°':'12:11 - 12:59',
			'1°':'1:05 - 1:53'
		},
		'1c':{
			'1°':'7:58 - 8:46',
			'2°':'8:52 - 9:40',
			'3°':'9:46 - 10:36',
			'4°':'10:42 - 11:30',
			'LUNCH':'11:30 - 12:05',
			'5°':'12:11 - 12:59',
			'6°':'1:05 - 1:53'
		},
		
		'FINAL1':{
			'Exam 1°':'7:58-9:18',
			'3°':'9:24-10:09',
			'4°':'10:15-11:00',
			'BRUNCH':'11:00-11:20',
			'Exam 2°':'11:26-12:46'
		},

		'FINAL2':{
			'Exam 3°':'7:58-9:18',
			'5°':'9:24-10:09',
			'6°':'10:15-11:00',
			'BRUNCH':'11:00-11:20',
			'Exam 4°':'11:26-12:46'
		},
		'FINAL3':{
			'Exam 5°':'7:58-9:18',
			'1°':'9:24-10:09',
			'2°':'10:15-11:00',
			'BRUNCH':'11:00-11:20',
			'Exam 6°':'11:26-12:46'
		},

		'STAR2':{
			'STAR Testing Language':'7:58-10:30',
			'2°':'10:39-11:46',
			'LUNCH':'11:46-12:21',
			'4°':'12:27-1:33',
			'5°':'1:39-2:45'
		},
		'STAR3':{
			'STAR Testing Social Studies':'7:58-10:30',
			'3°':'10:39-11:46',
			'LUNCH':'11:46-12:21',
			'5°':'12:27-1:33',
			'1°':'1:39-2:45'
		},

		'STAR4':{
			'STAR Testing Math':'7:58-10:30',
			'4°':'10:39-11:46',
			'LUNCH':'11:46-12:21',
			'6°':'12:27-1:33',
			'2°':'1:39-2:45'
		},
		
		'STAR5':{
			'STAR Testing Science':'7:58-10:30',
			'5°':'10:39-11:46',
			'LUNCH':'11:46-12:21',
			'1°':'12:27-1:33',
			'3°':'1:39-2:45'
		},
		'M1':{
			'1°':'7:58 - 8:33',
			'2°':'8:39 - 9:14',
			'3°':'9:20 - 9:55',
			'4°':'10:01 - 10:36',
			'BRUNCH':'10:36 - 10:56',
			'5°':'11:02 - 11:37',
			'6°':'11:43 - 12:18'
			
		}
	}
;

function getTodaysScheduleCode () {
	function asTwoDigits (_value) {return _value < 10 ? ('0' + _value) : _value}
	var
		today = new Date (),
		todayAsIso8601 = today.getFullYear () + '-' + asTwoDigits (today.getMonth () + 1) + '-' + asTwoDigits (today.getDate ())
	;
	return schoolYear [todayAsIso8601];
}


function getDaySchedule (scheduleCode) {
	return daySchedules [scheduleCode];
}

function getDayScheduleAsHtml (scheduleCode) {
	var
		html = '<table class="daySchedule">',
		daySchedule = getDaySchedule (scheduleCode)
	;
	for (periodKey in daySchedule)
		html += '<tr><td class="periodKey">' + periodKey + '</td><td class="periodTime">' + daySchedule [periodKey] + '</td></tr>'
	;
	html += '</table>';
	return html;
}

var dateAsText = '';
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year < 1000)
year+=1900
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var monthname = 
new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );
dateAsText += dayname[day] + ", ";
dateAsText += monthname[month] + " ";
if (date< 10) dateAsText += "" + date + ", ";
else dateAsText += date + ", ";
dateAsText += year;
// Easter
if ((month == emonth) && (date == edate)) dateAsText += "Easter Sunday (Western)   ";
// January
if ((month == 0) && (date == 1)) dateAsText += "New Year's Day";
if ((month == 0) && (day == 1) && (date > 14) && (date< 22)) dateAsText += "Martin Luther King's Birthday";
// February
if ((month == 1) && (date== 12)) dateAsText += "Lincoln's Birthday";
if((month == 1) && (date == 14)) dateAsText += "St. Valentine's Day";
if ((month == 1) && (date == 22)) dateAsText += "Washington's Birthday";
// March
if ((month == 2) && (date == 17)) dateAsText += "St. Patrick's Day";
// April
if ((month == 3) && (date == 1)) dateAsText += "April Fools' Day";

// May
if ((month == 4) && (day == 0) && (date > 7) && (date< 16)) dateAsText += "Mother's Day";
if ((month == 4) && (day == 1) && (date > 24)) dateAsText += "Memorial Day";
// June
if ((month == 5) && (date == 14)) dateAsText += "Flag Day";
if ((month == 5) && (date == 21)) dateAsText += "Summer Solstice";
if ((month == 5) && (day == 0) && (date > 15) && (date< 24)) dateAsText += "Father's Day";
// July
if ((month == 6) && (date == 4)) dateAsText += "Independence Day";
// August
// September
// October
if ((month == 9) && (day == 1) && (date > 7) && (date< 16)) dateAsText += "Columbus Day";
if ((month == 9) && (date == 31)) dateAsText += "Halloween";
// November
if ((month == 10) && (day == 4) && (date > 23) && (date< 30)) dateAsText += "Thanksgiving";
// December
if ((month == 11) && (date == 24)) dateAsText += "Christmas Eve";
if ((month == 11) && (date == 25)) dateAsText += "Christmas";
if ((month == 11) && (date == 31)) dateAsText += "New Year's Eve";

document.writeln(
	'<div class="dayScheduleShell">' +
	'<div class="dayScheduleShellInner">' +
	'<center>' +
	'<div class="dayScheduleTitle">' + dateAsText + '</div>' +
	getDayScheduleAsHtml (getTodaysScheduleCode ()) +
	'</center>' +
	'</div>' +
	'</div>'
);

