/* 
 * This is a JavaScript file for the StPriscilla.org website
 * Author: Basel Sarraf
 *
 */
 
/* Function returns a string for current mass schedule purposes.
 * weekday excluding Wednesday, Saturday, Sunday, Holiday, Vigil, or Wednesday are given values:
 * 1				, 2	, 3	, 4 	, 5	, 6
 * NOTE: Please apply Easter dates after 2015 A.D.!!!!!!!!!!!!!!!!
 */
function whatDay() {
	var today  = new Date().toDateString();
	if (today.indexOf("Dec 24") > -1)
		return 5;		// Christmas
  if (	
   			(today.indexOf("Apr 24 2011") > -1) ||	// Easter 2011
   			(today.indexOf("Apr 08 2012") > -1) ||	// Easter 2012
   			(today.indexOf("Mar 31 2013") > -1) ||	// Easter 2013
   			(today.indexOf("Apr 20 2014") > -1) ||	// Easter 2014
   			(today.indexOf("Apr 05 2015") > -1) 		// Easter 2015
   		)
   		return 4;		// Holiday
   else if (today.indexOf("Sat") > -1)
   		return 2;		// Saturday
   else if (today.indexOf("Sun") > -1)
   		return 3;		// Sunday
   else if (today.indexOf("Wed") > -1)
   		return 6;		// Wednesday
	return 1;			// Weekday excluding Wednesday
}

// Function that displays the current English Mass Schedule
function enMass() {
var txt = "<table><tr><th>Today's Holy Mass</th></tr>";
	var today = whatDay();
	switch (today) {
		// Holiday
		case 4:
			txt += "<tr><td>6:30AM</td><tr>";
			txt += "<tr><td>8:00AM</td><tr>";
			txt += "<tr><td>11:00AM</td><tr>";
			break;
		// Vigil
		case 5:
			txt += "<tr><td>7:00PM</td><tr>";
			break;
		// Sunday
		case 3:
			txt += "<tr><td>8:30AM</td><tr>";
			txt += "<tr><td>12:15PM</td><tr>";
			break;
		// Saturday
		case 2:
			txt += "<tr><td>8:00AM</td><tr>";
			txt += "<tr><td>4:00PM</td><tr>";
			break;
		// Weekday and Default
		default:
			txt += "<tr><td>8:00AM</td><tr>";
			break;
	}
	txt += "</table>";
	return txt;
}

// Function that displays the current English Mass Schedule
function plMass() {
	var txt = "<table><tr><th>Dzisiejsze Msze Święte</th></tr>";
	var today = whatDay();
	switch (today) {
		// Holiday
		case 4:
			txt +="<tr><td>7:00PM</td><tr>";
			break;
		// Vigil
		case 5:
			txt +="<tr><td>7:00PM</td><tr>";
			break;
		// Sunday
		case 3:
			txt +="<tr><td>10:30AM</td><tr>";
			txt +="<tr><td>6:00PM</td><tr>";
			break;
		// Saturday
		case 2:
			txt +="<tr><td>8:30AM</td><tr>";
			break;
		// Wednesday
		case 6:
			txt +="<tr><td>8:30AM</td><tr>";
			break;
		default:
			txt +="<tr><td>Nie ma Polskiej mszy</td><tr>";
			break;
	}
	txt += "</table>";
	return txt;
}
// Returns a link to the current day's reading from the U.S. Conference of Catholic Bishops
function getReadingLink() {
	var myDate = new Date();
	var day = myDate.getDate();
	var month = myDate.getMonth() + 1;
	var year  = myDate.getFullYear();
	document.write("<a href=\"http://www.usccb.org/nab/");
	if ( month < 10 )
		document.write("0"+month);
	else
		document.write(month);
	if ( day < 10 )
		document.write( "0"+day);
	else
		document.write(day);
	document.write(year.toString().slice(2)+".shtml\" name=\"Today\'s Reading from United States Conference of Catholic Bishops\">Today\'s Reading</a>");
}

// POLISH Returns a link to the current day's reading from the U.S. Conference of Catholic Bishops
function getReadingLinkPL() {
	var myDate = new Date();
	var day = myDate.getDate();
	var month = myDate.getMonth() + 1;
	var year  = myDate.getFullYear();
	document.write("<a href=\"http://www.usccb.org/nab/");
	if ( month < 10 )
		document.write("0"+month);
	else
		document.write(month);
	if ( day < 10 )
		document.write( "0"+day);
	else
		document.write(day);
	document.write(year.toString().slice(2)+".shtml\" name=\"Dzisiejsze czytanie Pisma Świętego ze strony United States Conference of Catholic Bishops\">Dzisiejsze Czytanie</a>");
}
