//  SET ARRAYS
var day_of_week = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var month_of_year = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

//  DECLARE AND INITIALIZE VARIABLES
var Calendar = new Date();

var year = Calendar.getYear();	    // Returns year
var month = Calendar.getMonth();    // Returns month (0-11)
var today = Calendar.getDate();    // Returns day (1-31)
var weekday = Calendar.getDay();    // Returns day (1-31)

var DAYS_OF_WEEK = 7;    // "constant" for number of days in a week
var DAYS_OF_MONTH = 31;    // "constant" for number of days in a month
var cal;    // Used for printing

Calendar.setDate(1);    // Start the calendar day at '1'
Calendar.setMonth(month);    // Start the calendar month at now

/* VARIABLES FOR FORMATTING
NOTE: You can format the 'BORDER', 'BGCOLOR', 'CELLPADDING', 'BORDERCOLOR'
      tags to customize your caledanr's look. */

var TR_start = '<TR>';
var TR_end = '</TR>';
var highlight_start = '<TD WIDTH="30"><table align=center border=0 cellspacing=0 bgcolor=#FFFFFF><TR><TD class=calh WIDTH=20><B><CENTER>';
var highlight_end   = '</CENTER></TD></TR></TABLE></B>';
var TD_start = '<TD WIDTH="30"><CENTER>';
var TD_end = '</CENTER></TD>';

/* my additions... */
var holiday_start = '<TD WIDTH="30"><table align=center border=1 cellspacing=0 bgcolor=#FFFFFF class=calhol><TR><TD WIDTH=20><B><CENTER>';
var holiday_end   = '</CENTER></B></TD></TR></TABLE>';

var dCount = 0;
var quotes = new Array();
var today_day = new Date(); // today
var mon = month_of_year[Calendar.getMonth() + 1]; // this month
var days = new Array();
var dMonthHols = 0;
var currMonth = new Array();

/* year fix */
if(year < 1000)
year = year + 1900;
/* */

function preloaddate(qdate, qdescription) {  
    quotes[dCount] = new Array(2);	
    quotes[dCount][0] = qdate + ", " + year;
    quotes[dCount][1] = qdescription;
    dCount++;
}

function thisMonthHols() {
  for (i = 0; i < dCount; i++) {
    tempdate = new Date(quotes[i][0]);
    tempmonth = month_of_year[tempdate.getMonth() + 1];
    tempday = tempdate.getDate();

    if (mon == tempmonth) {
	   currMonth[dMonthHols] = tempday;
	   dMonthHols++;
	}	   
  }
}

function holdayList() {
  for (i = 0; i < dCount; i++) {
    tempdate = new Date(quotes[i][0]);
    tempmonth = month_of_year[tempdate.getMonth() + 1];
    tempday = tempdate.getDate();
    
    if (mon == tempmonth)
    document.writeln("<li style='list-style-type : none;'>" + quotes[i][0] + ": " + quotes[i][1] + "</li>"); 
		   
  }
}

preloaddate("January 1"," New Year's Day, Emancipation Day, Japanese New Year");
preloaddate("January 18","World Religion Day");
preloaddate("January 19","Martin Luther King, Jr's Birthday");
preloaddate("January 22","Chinese New Year, Tet Nguyen Dan");
preloaddate("February 1"," Super Bowl XXXVIII, Black History Month, Eid al-Adha");
preloaddate("February 2"," Groundhog Day");
preloaddate("February 8"," Pro Bowl");
preloaddate("February 12","Lincoln's Birthday");
preloaddate("February 14","Valentine's Day, Wacky's Birthday");
preloaddate("February 16","Presidents' Day");
preloaddate("February 22","Washington's Birthday");
preloaddate("February 24","Mardi Gras");
preloaddate("February 25","Ash Wednesday");
preloaddate("March 1"," Women's History Month");
preloaddate("March 2"," Islamic New Year");
preloaddate("March 7"," Purim");
preloaddate("March 8"," International Women's Day");
preloaddate("March 17","St. Patrick's Day");
preloaddate("March 21","Baha'i New Year, Spring Equinox");
preloaddate("April 1"," April Fool's Day");
preloaddate("April 4"," Daylight Savings Time begins:  Spring Forward!!");
preloaddate("April 6"," Passover");
preloaddate("April 11","Easter");
preloaddate("April 18","Yom Ha Shoah");
preloaddate("April 25","Earth Day");
preloaddate("April 18","Patriot's Day");
preloaddate("April 29","Walpurgis Night, Eve of Beltane");
preloaddate("April 30","Arbor Day, Beltane");
preloaddate("May 1"," May Day");
preloaddate("May 5"," Cinco de Mayo");
preloaddate("May 9"," Mother's Day");
preloaddate("May 15","Armed Forces Day");
preloaddate("May 19","Malcolm X's Birthday");
preloaddate("May 26","Shavuot");
preloaddate("May 31","Memorial Day");
preloaddate("June 1"," LGBT Pride Month");
preloaddate("June 14","Flag Day");
preloaddate("June 19","Juneteenth, Midsummer's Eve");
preloaddate("June 20","Father's Day, Summer Solstice");
preloaddate("June 26","Gay Pride Day");
preloaddate("June 27","National Children's Day");
preloaddate("July 4"," Independence Day, Fil-American Friendship Day");
preloaddate("August 1"," Lughnasadh");
preloaddate("August 26","Women's Equality Day");
preloaddate("August 28","March on Washington Anniversary");
preloaddate("September 6"," Labor Day");
preloaddate("September 12","Grandparent's Day");
preloaddate("September 15","National Hispanic Heritage Month");
preloaddate("September 16","Rosh Hashanah, Step-Family Day");
preloaddate("September 18","Religious Freedom Week");
preloaddate("September 21","Autumnal Equinox");
preloaddate("September 30","Sukkot");
preloaddate("October 1"," LGBT History Month, Breast Cancer Awareness Month");
preloaddate("October 6"," Yom Kippur");
preloaddate("October 11","Columbus Day, National Coming Out Day");
preloaddate("October 16","Ramadan, Sweetest Day");
preloaddate("October 25","Diwali");
preloaddate("October 31","Halloween, Fall Back!");
preloaddate("November 1"," Dia de los Muertos, All Saint's Day");
preloaddate("November 11","Veterans Day");
preloaddate("November 14","Eid al-Fitr");
preloaddate("November 25","Thanksgiving Day");
preloaddate("December 1"," World AIDS Day, Day Without Art");
preloaddate("December 20","Chanukah");
preloaddate("December 22","Winter Solstice");
preloaddate("December 24","Christmas Eve");
preloaddate("December 25","Christmas Day");
preloaddate("December 26","Kwanzaa, Boxing Day");
preloaddate("December 31","New Year's Eve");

thisMonthHols();

/* my additions... */


/* BEGIN CODE FOR CALENDAR
NOTE: You can format the 'BORDER', 'BGCOLOR', 'CELLPADDING', 'BORDERCOLOR'
tags to customize your calendar's look.*/

cal =  '<table bgcolor=#FFFFFF align=center border=0 cellspacing=0 CELLPADDING=0><tr bgcolor=#FFFFFF><TD bgcolor=#FFFFFF>';
cal += '<TABLE bgcolor=#FFFFFF align=center BORDER=0 CELLSPACING=0 CELLPADDING=2 class=caldates>' + TR_start;
cal += '<TD COLSPAN="' + DAYS_OF_WEEK + '" class="calheader"><CENTER><B>';
cal += month_of_year[month]  + '   ' + year + '</B>' + TD_end + TR_end;
cal += TR_start;

// LOOPS FOR EACH DAY OF WEEK
for(index=0; index < DAYS_OF_WEEK; index++)
{

// BOLD TODAY'S DAY OF WEEK
if(weekday == index)
cal += TD_start + '<B>' + day_of_week[index] + '</B>' + TD_end;

// PRINTS DAY
else
cal += TD_start + day_of_week[index] + TD_end;
}

cal += TD_end + TR_end;
cal += TR_start;

i = 0;
// FILL IN BLANK GAPS UNTIL TODAY'S DAY
for(index=0; index < Calendar.getDay(); index++)
cal += TD_start + '  ' + TD_end;

	// LOOPS FOR EACH DAY IN CALENDAR
	for(index=0; index < DAYS_OF_MONTH; index++)
	{
		if( Calendar.getDate() > index )
		{
  			// RETURNS THE NEXT DAY TO PRINT
  			week_day =Calendar.getDay();

			// START NEW ROW FOR FIRST DAY OF WEEK
			if(week_day == 0)
  			cal += TR_start;

  			if(week_day != DAYS_OF_WEEK)
  			{

	  			// SET VARIABLE INSIDE LOOP FOR INCREMENTING PURPOSES
	  			var day  = Calendar.getDate();
			
	  			// HIGHLIGHT TODAY'S DATE
	  			if( today==Calendar.getDate() )
				cal += highlight_start + day + highlight_end + TD_end;
				
				else
					{
  						// my addition - highlight holidays
  						if( currMonth[i] == day )
						{
  							cal += holiday_start + day + holiday_end + TD_end;
							i++;
						}
  						else
  						// my addition
		  				// PRINTS DAY
		  				cal += TD_start + day + TD_end;
					}
  			}

  			// END ROW FOR LAST DAY OF WEEK
  			if(week_day == DAYS_OF_WEEK)
  			cal += TR_end;
  		}

		// INCREMENTS UNTIL END OF THE MONTH
  		Calendar.setDate(Calendar.getDate()+1);

	}// end for loop

cal += '</TD></TR></TABLE></TABLE>';

//  PRINT CALENDAR
document.write(cal);
//  End -->
