var
	schoolYear = {

		'2008-08-19':'5',
		'2008-08-28':'6',
		// ...
		'2011-08-17':'M1',
		'2011-08-18':'2',
		'2011-08-19':'3',

'2012-01-03':'1',
'2012-01-04':'2',
'2012-01-05':'3',
'2012-01-06':'4',
'2012-01-09':'5',
'2012-01-10':'6',
'2012-01-11':'1',
'2012-01-12':'2',
'2012-01-13':'3',
'2012-01-16':'4',
'2012-01-17':'5',
'2012-01-18':'6',
'2012-01-19':'1',
'2012-01-20':'2',
'2012-01-23':'3',
'2012-01-24':'4',
'2012-01-25':'5',
'2012-01-26':'6',
'2012-01-27':'1',
'2012-01-30':'2',
'2012-01-31':'3',
'2012-02-01':'4',
'2012-02-02':'5',
'2012-02-03':'6',
'2012-02-06':'1',
'2012-02-07':'2',
'2012-02-08':'3',
'2012-02-09':'4',
'2012-02-10':'5',
'2012-02-13':'6',
'2012-02-14':'1',
'2012-02-15':'2',
'2012-02-16':'3',
'2012-02-17':'4',
'2012-02-20':'5',
'2012-02-21':'6',
'2012-02-22':'1',
'2012-02-23':'2',
'2012-02-24':'3',
'2012-02-27':'4',
'2012-02-28':'5',
'2012-03-01':'6',
'2012-03-02':'1',
'2012-03-03':'2',
'2012-03-06':'3',
'2012-03-07':'4',
'2012-03-08':'5',
'2012-03-09':'6',
'2012-03-10':'1',
'2012-03-13':'2',
'2012-03-14':'3',
'2012-03-15':'4',
'2012-03-16':'5',
'2012-03-17':'6',
'2012-03-20':'1',
'2012-03-21':'2',
'2012-03-22':'3',
'2012-03-23':'4',
'2012-03-24':'5',
'2012-03-27':'6',
'2012-03-28':'1',
'2012-03-29':'2',
'2012-03-30':'3',
'2012-03-31':'4',
'2012-04-02':'5',
'2012-04-03':'6',
'2012-04-04':'1',
'2012-04-05':'2',
'2012-04-06':'3',
'2012-04-09':'4',
'2012-04-10':'5',
'2012-04-11':'6',
'2012-04-12':'1',
'2012-04-13':'2',
'2012-04-16':'3',
'2012-04-17':'4',
'2012-04-18':'5',
'2012-04-19':'6',
'2012-04-20':'1',
'2012-04-23':'2',
'2012-04-24':'3',
'2012-04-25':'4',
'2012-04-26':'5',
'2012-04-27':'6',
'2012-04-30':'1',
'2012-05-01':'2',
'2012-05-02':'3',
'2012-05-03':'4',
'2012-05-04':'5',
'2012-05-07':'6',
'2012-05-08':'1',
'2012-05-09':'2',
'2012-05-10':'3',
'2012-05-11':'4',
'2012-05-14':'5',
'2012-05-15':'6',
'2012-05-16':'1',
'2012-05-17':'2',
'2012-05-18':'3',
'2012-05-21':'4',
'2012-05-22':'5',
'2012-05-23':'M',
'2012-05-24':'M',
'2012-05-25':'M',

		'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'
		},

		'STAR1':{
			'STAR Testing Language Arts CST, Part I':'7:58-10:10',
			'1°':'10:16-10:50',
			'2°':'10:56-11:30',
			'LUNCH':'11:30-12:05',
			'3°':'12:11-12:45',
			'4°':'12:51-1:25',
			'5°':'1:31-2:05',
			'6°':'2:11-2:45'
		},
		'STAR2':{
			'STAR Testing Language Arts CST, Part II':'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 CST':'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 CST':'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 CST':'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>'
);


