showHolidays = true;
function holidays(day, month, year) { return my_holiday(day, month, year); }

showAltHoly = true;   //false
AltHolyFormat = "<font  size=2 color=#000000><b><center>|</center></b></font>";
function getAltHoly(day, month, year) { return my_alt_holiday(day, month, year); }

var weekday = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var dow = "";
var wom = 0;
var leapyear = true;
var quote = String.fromCharCode (34)

function appendTo (text) { return text == "" ? "" : (text + "<br />") }

function jDate (day, month, year) {
	var d = new Date ();
	d.setFullYear (year);
	d.setMonth (month - 1);
	d.setDate (day);
	dow = weekday [d.getDay()];
	wom = Math.floor ((day - 1) / 7) + 1;
	leapYear = (year % 4) == 0;
	preLeapYear = ((year + 1)  % 4) == 0;
	return d;}

function HolyDay (year, offset) {
	var e = new easter (year);
	e.setTime (e.getTime () + (offset * 86400000));
	return e;}

function easter (year) {
	var d = new Date ();
	d.setFullYear (year);

	/* the Golden number */
    	var golden = (year % 19) + 1;

	/* GREGORIAN CALENDAR */
	/* the "Dominical number" - finding a Sunday */
	var dom = (year + Math.floor(year/4) - Math.floor(year/100) + (Math.floor(year/400))) % 7;
	if (dom < 0) {dom += 7;}

	/* the solar and lunar corrections */
	var solar = Math.floor((year-1600)/100) - Math.floor((year-1600)/400);
	var lunar = (Math.floor((year-1400) / 100) * 8) / 25;

	/* uncorrected date of the Paschal full moon */
	var pfm = (3 - (11*golden) + solar - lunar) % 30;
	if (pfm < 0) {pfm += 30;}

	/* corrected date of the Paschal full moon - days after 21st March */
    	if ((pfm == 29) || (pfm == 28 && golden > 11)) {pfm--;}

	var tmp = (4-pfm-dom) % 7;
	if (tmp < 0) {tmp += 7;}

	/* Easter as the number of days after 21st March */
    	var easter = pfm + tmp + 1;

	if (easter < 11) {d.setMonth (2); d.setDate (easter + 21);}
	else {d.setMonth (3); d.setDate (easter - 10);}
	return d;}

function my_holiday (day, month, year) {
	var thisDate = jDate (day, month, year);
	var holText = "";

	switch (month) {
	case 1:  // January
		if (day == 1) holText = "New Year's Day";
		//if (dow == "Mon" && wom == 3) holText = "Martin Luther King, Jr. Day";
		//if (leapYear && day == 20) holText = appendTo (holText) + "Inauguration Day"

		break;
	case 2:  // February
		//if (day == 2) holText = "Groundhog Day";
		//if (day == 14) holText = "Valentine's Day";
		//if (dow == "Mon" && wom == 3) holText = "Presidents' Day";
		//if (dow == "Wed") {
			//var a = HolyDay (year, -46);
			//if (a.getMonth() == 1 && a.getDate() == day) {
				//holText = appendTo (holText) + "Ash Wednesday"; }}
		break;
	case 3:  // March
		//if (dow == "Wed" && day < 11) {
			//var a = HolyDay (year, -46);
			//if (a.getMonth() == 2 && a.getDate() == day) holText = "Ash Wednesday";}
		//if (dow == "Sun" && day > 14) {
			//var a = HolyDay (year, -7);
			//if (a.getMonth() == 2 && a.getDate() == day) holText = "Palm Sunday";}
		//if (day == 17) holText = appendTo (holText) + "St. Patrick's Day";
		//if (dow == "Fri" && day > 19) {
			//var a = HolyDay (year, -2);
			//if (a.getMonth() == 2 && a.getDate() == day) holText = "Good Friday";}
		//if (dow == "Sun" && day > 21) {
			//var e = easter (year);
			//if (e.getMonth() == 2 && e.getDate() == day) holText = "Easter";}
		break;
	case 4:  // April
		//if (day == 1) holText = "April Fool's Day";
		//if (dow == "Sun" && day < 20) {
			//var a = HolyDay (year, -7);
			//if (a.getMonth() == 3 && a.getDate() == day) holText = "Palm Sunday";}
		//if (dow == "Fri" && day < 25) {
			//var a = HolyDay (year, -2);
			//if (a.getMonth() == 3 && a.getDate() == day) holText = "Good Friday";}
		//if (dow == "Sun" && day < 27) {
			//var e = easter (year);
			//if (e.getMonth() == 3 && e.getDate() == day) holText = "Easter";}
		break;
	case 5:  // May
		//if (dow == "Sun" && day > 9) {
			//var a = HolyDay (year, 49);
			//if (a.getMonth() == 4 && a.getDate() == day) holText = "Pentecost";}
		//if (dow == "Sun" && wom == 2) holText = appendTo (holText) + "Mothers' Day";
		//if (dow == "Sat" && wom == 3) holText = appendTo (holText) + "Armed Forces Day";
		//if (dow == "Mon" && day > 24) holText = appendTo (holText) + "Memorial Day";
		break;
	case 6:  // June
		//if (dow == "Sun" && day < 15) {
			//var a = HolyDay (year, 49);
			//if (a.getMonth() == 5 && a.getDate() == day) holText = "Pentecost";}
		//if (day == 14) holText = appendTo (holText) + "Flag Day";
		//if (dow == "Sun" && wom == 3) holText = "Fathers' Day";
		break;
	case 7:  // July
		//if (day == 4) holText = "Independence Day";
		//if (dow == "Sun" && wom == 4) holText = "Parents' Day";
		break;
	case 8:  //August
		break;
	case 9:  // September
		//if (dow == "Mon" && wom == 1) holText = "Labor Day";
		//if (dow == "Sun" && day > 6 && day < 14) holText = "Grandparents' Day";
		break;
	case 10: // October
		//if (day == 24) holText = "United Nations Day";
		//if (day == 31) holText = "Halloween";
		break;
	case 11: // November
		//if (dow == "Tue" && day > 1 && day < 9) holText = "Election Day";
		//if (day == 11) holText = "Veterans Day";
		//if (dow == "Thu" && wom == 4) holText = "Thanksgiving Day";
		//if (dow == "Sun" && day > 26) holText = "First Sunday of Advent"
		break;
	case 12: // December
		//if (dow == "Sun" && day < 4) holText = "First Sunday of Advent"
		//if (dow == "Sun" && day > 3 && day < 11) holText = "Second Sunday of Advent"
		//if (dow == "Sun" && day > 10 && day < 18) holText = "Third Sunday of Advent"
		//if (dow == "Sun" && day > 17 && day < 25) holText = "Fourth Sunday of Advent"
		//if (day == 25) holText = "Christmas";
		if (day ==  31) holText = "<img border='0' src='images/fireworks1.gif' width='50' height='60' align='left'><span style='color: red'>New Year's Eve</span>";
		break;
}

	return holText;
}

function my_alt_holiday(day, month, year) {
	var thisDate = jDate (day, month, year);
	var holText = "";

	switch (month) {
	case 1:  // January
		if (dow == "Sat" && day < 6) holText = "Kiahk Praises";
		if (day == 7) holText = "<img border='0' src='images/NativityCoptic.jpg' width='50' height='60' align='left'><span style='color: red'>The Holy Nativity Feast</span>";
		if (day == 8 && year == 2012) holText = "<img border='0' src='images/NativityCoptic.jpg' width='50' height='60' align='left'><span style='color: red'>The Holy Nativity Feast (Second Day)</span>";
		
		if (leapYear && day == 15) holText = appendTo (holText) + "<img border='0' src='images/circumcision.jpg' width='50' height='60' align='left'><span style='color: red'>The Circumcision Feast</span>";
			if (leapYear == false && day == 14) holText = "<img border='0' src='images/circumcision.jpg' width='50' height='60' align='left'><span style='color: red'>The Circumcision Feast</span>";
		if (leapYear && day == 20) holText = appendTo (holText) + "<img border='0' src='images/EpiphanyCoptic.jpg' width='50' height='60' align='left'><span style='color: red'>The Holy Epiphany Feast</span>";
			if (leapYear == false && day == 19) holText = "<img border='0' src='images/EpiphanyCoptic.jpg' width='50' height='60' align='left'><span style='color: red'>The Holy Epiphany Feast</span>";
		if (leapYear && day == 22) holText = appendTo (holText) + "<img border='0' src='images/wedding_cana.jpg' width='50' height='60' align='left'><span style='color: red'>The Feast of the Wedding of Cana of Galilee</span>";
			if (leapYear == false && day == 21) holText = "<img border='0' src='images/wedding_cana.jpg' width='50' height='60' align='left'><span style='color: red'>The Feast of the Wedding of Cana of Galilee</span>";
		if (day == 25 && year == 2010) holText = "Jonah's (Nineveh) Fast";
		if (day == 26 && year == 2010) holText = "Jonah's (Nineveh) Fast";
		if (day == 27 && year == 2010) holText = "Jonah's (Nineveh) Fast";
		if (day == 28 && year == 2010) holText = "<span style='color: red'>Jonah's (Nineveh) Feast</span>";
		if (leapYear && day == 31) holText = appendTo (holText) + "<img border='0' src='images/anthony.jpg' width='50' height='60' align='left'><span style='color: red'>The Feast of St. Anthony the Great</span>";
			if (leapYear == false && day == 30) holText = "<img border='0' src='images/anthony.jpg' width='50' height='60' align='left'><span style='color: red'>The Feast of St. Anthony the Great</span>";
		if (leapYear && day == 30)	holText = appendTo (holText) + "<span style='color: red'>The Departure of St. Mary the Virgin</span>";
		break;
	case 2:  // February
		
		if (leapYear && day == 16) holText = appendTo (holText) + "<img border='0' src='images/presentation_temple.jpg' width='50' height='60' align='left'><span style='color: red'>Presentation of the Lord into the Temple</span>";
			if (leapYear == false && day == 15) holText = "<img border='0' src='images/presentation_temple.jpg' width='50' height='60' align='left'><span style='color: red'>Presentation of the Lord into the Temple</span>";
		if (day == 14 && year == 2011) holText = "Jonah's (Nineveh) Fast";
		if (day == 15 && year == 2011) holText = "Jonah's (Nineveh) Fast";
		if (day == 16 && year == 2011) holText = "Jonah's (Nineveh) Fast";
		if (day == 17 && year == 2011) holText = "<img border='0' src='images/Jonah.gif' width='50' height='60' align='left'><span style='color: red'>Jonah's (Nineveh) Feast</span>";
		if (day == 28 && year == 2011) holText = "Holy Great Lent<br>(through April 15)";
		if (day == 20 && year == 2012) holText = "Holy Great Lent<br>(through April 6)";
		if (day == 6 && year == 2012) holText = "Jonah's (Nineveh) Fast";
		if (day == 7 && year == 2012) holText = "Jonah's (Nineveh) Fast";
		if (day == 8 && year == 2012) holText = "Jonah's (Nineveh) Fast";
		if (day == 9 && year == 2012) holText = "<img border='0' src='images/Jonah.gif' width='50' height='60' align='left'><span style='color: red'>Jonah's (Nineveh) Feast</span>";
		

		
		break;
	case 3:  // March
		if (day == 9) holText = "<img border='0' src='images/popekyrillos6.jpg' width='50' height='60' align='left'>The Departure of H.H. Pope Kyrillos VI";
		if (day == 19) holText = "<span style='color: red'>The Feast of the Cross</span>"; //fix
		//if (day == 27) holText = "<span style='color: red'>Lazarus Saturday</span>";
		//if (day == 28) holText = "<span style='color: red'>Entry of our Lord into Jerusalem (Hosanna Sunday)</span>";
		//if (day == 29) holText = "Holy Pascha";
		//if (day == 30) holText = "Holy Pascha";
		//if (day == 31) holText = "Holy Pascha";


//		if (dow == "Sun" && day > 24 && year > 2006) holText = "Daylight Saving Time Begins";
		break;
	case 4:  // April
	 	if (day == 24 && year == 2011) holText = "<img border='0' src='images/resurrection.jpg' width='50' height='60' align='left'><span style='color: red'>Glorious Feast of the Resurrection</span>";
		
		//if (day == 1) holText = "<span style='color: red'>Covenant Thursday</span>";
		//if (day == 2) holText = "Good Friday";
		//if (day == 4) holText = "<span style='color: red'>The Glorious Feast of the Resurrection</span>";
		if (day == 7) holText = "<img border='0' src='images/annunciation.jpg' width='50' height='60' align='left'><span style='color: red'>The Annunciation Feast</span>";
		//if (day == 11) holText = "<span style='color: red'>Thomas’ Sunday</span>";

//		if (dow == "Sun" && wom == 1 && year < 2007) holText = "Daylight Saving Time Begins";
		break;
	case 5:  // May
		if (day == 1) holText = "<span style='color: red'>The Feast of St. George</span>";
		if (day == 8) holText = "Martyrdom of St. Mark the Evangelist"; //fix
		//if (day == 13) holText = "<span style='color: red'>The Holy Ascension Feast</span>";
		//if (day == 23) holText = "<span style='color: red'>The Holy Pentecost Feast</span>";
		//if (day == 24) holText = "The Apostles' Fast<br>(till July 11)";
		
		break;
	case 6:  // June
		if (day == 1) holText = "<span style='color: red'>Entry of the Lord into Egypt</span>"; //fix
		if (day == 12 && year == 2011) holText = "<span style='color: red'>The Holy Pentecost Feast</span>"; // not fix

		
		break;
	case 7:  // July
		if (day == 12) holText = "<span style='color: red'>The Apostles' Feast (Martyrdom of St. Peter & St. Paul)</span>"; //fix
//		if (year == 2005) {
//			if (dow == "Sat" && day > 23) {holText = "Family Camp";}
//			else {	if (dow == "Sun") {if (day > 24) holText = "Family Camp";}
//				else {if (day - thisDate.getDay() > 23) holText = "Family Camp";}}}
//		else {	if (dow == "Sat" && day > 22) {holText = "Family Camp";}
//			else {if (day - thisDate.getDay() > 23) holText = "Family Camp";}}
		break;
	case 8:  //August
		if (day ==  7) holText = "Virgin Mary's Fast<br>(till August 21)"; //fix
		if (day == 17) holText = "El Nahda begins"; //fix
		if (day == 19) holText = "<img border='0' src='images/transfiguration.jpg' width='50' height='60' align='top'><span style='color: red'>The Transfiguration Feast</span>"; //fix
		if (day == 22) holText = "<img border='0' src='images/assumption.jpg' width='50' height='60' align='left'><span style='color: red'>Virgin Mary's Feast (Assumption of St. Mary's Body)</span>"; //fix
//		if (thisDate.getDay() > day) holText = "Family Camp";
//		if (dow == "Sun" && day < 7) holText = "Family Camp";
		break;
	case 9:  // September
		if (preLeapYear && day == 12) holText = appendTo (holText) + "<span style='color: red'>El Nayrouz Feast (Coptic New Year)</span>"; //These change the year before Leap year
		if (preLeapYear == false && day == 11) holText = "<span style='color: red'>El Nayrouz Feast (Coptic New Year)</span>";	
		if (preLeapYear && day == 30) holText = appendTo (holText) + "<span style='color: red'>The Feast of the Cross</span>";
		if (preLeapYear == false && day == 27) holText = "<span style='color: red'>The Feast of the Cross</span>";
		if (day == 28) holText = "<span style='color: red'>The Feast of the Cross</span>"; //fix
		if (day == 29) holText = "<span style='color: red'>The Feast of the Cross</span>"; //fix
		break;
	case 10: // October
//		if (dow == "Sun" && day > 24 && year < 2007) holText = "Daylight Saving Time Ends";
		break;
	case 11: // November
		if (day ==  14) holText = "<img border='0' src='images/shenoudaIII.png' width='50' height='60' align='left'><span style='color: red'>Ordination of HH Pope Shenouda III</span>"; //fix
		if (preLeapYear && day == 17) holText = "<img border='0' src='images/StGeorge.png' width='50' height='60' align='left'><span style='color: red'>St. George's Feast</span>";
		if (preLeapYear == false && day == 16) holText = "<img border='0' src='images/StGeorge.png' width='50' height='60' align='left'><span style='color: red'>St. George's Feast</span>";
		if (day ==  22) holText = "<span style='color: red'>Archangel Michael's Feast</span>"; //fix??
		if (preLeapYear && day == 25) holText = "<img border='0' src='images/stMina.bmp' width='50' height='60' align='left'><span style='color: red'>St. Mina's Feast</span><br><br>";
		if (preLeapYear == false && day == 24) holText = "<img border='0' src='images/stMina.bmp' width='50' height='60' align='left'><span style='color: red'>St. Mina's Feast</span><br><br>";
		if (preLeapYear && day == 26) holText = "The Holy Nativity Fast<br>(till January 6)";
		if (preLeapYear == false && day == 25) holText = "The Holy Nativity Fast<br>(till January 6)";
		if (dow == "Sun" && wom == 1 && year > 2006) holText = "Daylight Saving Time Ends";
		break;
	case 12: // December
		if (preLeapYear && day == 5) holText = "<img border='0' src='images/abusefein.jpg' width='50' height='60' align='left'><span style='color: red'>Abu Sefein's Feast</span>";
		if (preLeapYear == false && day == 4) holText = "<img border='0' src='images/abusefein.jpg' width='50' height='60' align='left'><span style='color: red'>Abu Sefein's Feast</span>";
		if (preLeapYear && day == 13) holText = "<span style='color: red'>Entrance of St. Mary into the Temple</span>";
		if (preLeapYear == false && day == 12) holText = "<span style='color: red'>Entrance of St. Mary into the Temple</span>";
		if (dow == "Sat" && day > 8) holText = "Kiahk Praises";
		//if (day == 31) holText = "<img border='0' src='images/fireworks1.gif' width='50' height='60' align='left'><span style='color: red'>New Year's Eve</span>";
		break;
	}

	return holText;
}

