/*
====================== HOLIDAY EVENT COUNTDOWN TIMER CODE =========================
Input holiday events, dates and 24 hour time format, and messages in this section  
All holidays MUST BE IN CHRONOLOGICAL ORDER.  Start with Rosh HaShannah.  Input    
as many holidays as you want. The selectHoliday function coding will automatically 
determine the length of the arrays. Code will display nothing if the current date  
goes past the last holiday.                                                        

Here is the html code for displaying this javascript in a webpage.  Include this   
code in the body of the page where you want to see it displayed:                   

<script language="javascript" src="eventTimer.js" type="text/javascript"></script> 
<div id="clock" style="position:relative;"></div>                                  

Permission granted to use this script for your own purposes. Include this notice.  
This Javascript designed by Yehoshua ben Avraham - June, 2004 • Sivan 5763         
===================================================================================
*/

initializeHolidays();
selectHoliday();


   <!-- ========== LIST OF HOLIDAYS ========== /-->

function initializeHolidays() {
   holidayArray = new Array(
      "Rosh HaShannah",
      "Fast of Gedalia",
      "Yom Kippur",
      "Sukkot",
      "Channukah",
      "Fast of Tevet",
      "Tu B' Shevat",
      "Purim",
      "Passover (Pesakh) -",
      "Holocaust Memorial Day (Yom HaShoah) -",
      "Israel Independence Day (Yom Ha'atzmaut) -",
      "Day of Remembrance",
      "Lag B'Omer (33rd day of Omer) -",
      "Shavuot [Pharisaic] -",
      "the Fast of Tammuz - ",
      "Tisha B'Av (Fast of Av) -",
      "Tu B'Av",
      "Rosh HaShannah" );


   holidayDateArray = new Array(                     <!--  Date Array # - HOLIDAY/DATES - LIST THE DAY BEFORE THE HOLYDAY  /-->
      new Date("September 28, 2011 18:00:00"),       <!--  0 - Rosh HaShannah                /-->
      new Date("October 1, 2011 18:00:00"),          <!--  1 - Fast of Gedalia               /-->
      new Date("October 7, 2011 18:00:00"),          <!--  2 - Yom Kippur                    /-->
      new Date("October 12, 2011 18:00:00"),         <!--  3 - Sukkot, Day 1                 /-->
      new Date("December 20, 2011 18:00:00"),        <!--  4 - Channukah, Day 1              /-->
      new Date("January 4, 2012 18:00:00"),          <!--  5 - Fast of Tevet                 /-->
      new Date("February 7, 2012 18:00:00"),         <!--  6 - Tu B' Shevat                  /-->
      new Date("March 7, 2012 18:00:00"),            <!--  7 - Purim                         /-->
      new Date("April 6, 2012 18:00:00"),            <!--  8 - Passover, Day 1               /-->
      new Date("April 18, 2012 18:00:00"),           <!--  9 - Holocaust Memorial Day        /-->
      new Date("April 24, 2012 18:00:00"),           <!-- 10 - Day of Remembrance            /-->
      new Date("April 25, 2012 18:00:00"),           <!-- 11 - Israel Independence Day       /-->
      new Date("May 9, 2012 18:00:00"),              <!-- 12 - Lag B'Omer                    /-->
      new Date("May 26, 2012 18:00:00"),             <!-- 13 - Shavuot (Pharisaic)           /-->
      new Date("July 7, 2012 18:00:00"),             <!-- 14 - Fast of Tammuz                /-->
      new Date("July 28, 2012 18:00:00"),            <!-- 15 - Tisha B'Av                    /-->
      new Date("August 2, 2012 18:00:00"),           <!-- 16 - Tu B'Av                       /-->
      new Date("September 16, 2012 18:00:00") );     <!-- 17 - Rosh HaShannah (Next year)    /-->



   <!-- ============== LIST OF HOLIDAY MESSAGES ============== /-->

   holidayMessageArray = new Array(
      "It's Rosh HaShannah 5772 - L'Shannah HaBa'ah B'Yerushalaim",
      "Today is the Fast of Gedalia",
      "It's Yom Kippur",
      "First Day of Sukkot - Feast of Booths or Tabernacles",
      "Happy Channukah! - First Day",
      "Today is the Fast of Tevet",
      "Today is Tu B' Shevat",
      "Happy Purim!",
      "It's Passover, Day 1 - Feast of Unleavened Bread",
      "Today is Yom HaShoah - Holocaust Memorial Day",
      "Today is Remembrance Day - Commemorating Israel's war dead",
      "Today is Israel's Independence Day! (Yom Ha'atzmaut)",
      "Today is Lag B'Omer (33rd day of Omer)",
      "It's Shavuot! - Feast of Weeks [Pharisaic]",
      "It's the Fast of Tammuz - Babylonian conquest in 586 B.C.E.",
      "It's Tisha B'Av - Both Temples were destroyed on this date",
      "It's Tu B'Av - Jewish Sweethearts Day",
      "It's Rosh HaShannah 5773 - L'Shannah HaBa'ah B'Yerushalaim" );



   <!-- ======================== MESSAGES FOR EIGHT DAY HOLIDAYS ======================== /-->

   SukkotMessageArray = new Array(         <!-- == LIST OF SUKKOT MESSAGES, DAYS 2 - 9 == /-->
      "Second Day of Sukkot",
      "Sukkot - Khol Ha'moed (intermediate day), First Day",
      "Sukkot - Khol Ha'moed, Second Day",
      "Sukkot - Khol Ha'moed, Third Day",
      "Sukkot - Khol Ha'moed, Fourth Day",
      "Sukkot - Seventh Day - Hoshannah Rabbah",
      "Sukkot - Eighth Day - Shemini Atzeret",
      "Simchat Torah (Rejoicing of the Torah)" );


   PassoverMessageArray = new Array(     <!-- == LIST OF PASSOVER MESSAGES, DAYS 2 - 8 == /-->
      "Second Day of Passover - Second Seder in Evening",
      "Passover - Khol Ha'moed (intermediate day), First Day",
      "Passover - Khol Ha'moed, Second Day",
      "Passover - Khol Ha'moed, Third Day",
      "Passover - Khol Ha'moed, Fourth Day",
      "Passover - Seventh Day",
      "Passover - Eighth Day" );

} <!-- End function initializeHolidays() /-->




function selectHoliday() {

   count = 0;
   now = new Date();
   days = Math.floor( ( holidayDateArray[count] - now ) / 86400000 );

   if ( days >= 0 ) { 
      holidayDate = holidayDateArray[count];
      holiday = holidayArray[count];
      holidayMessage = holidayMessageArray[count];
   }
   else {
      while (days < -1) {
         now = new Date();
         days = Math.floor( ( holidayDateArray[count] - now ) / 86400000 );
         count++;

         if ( count == holidayDateArray.length ) {
            break;
         }
      }
      count--;

      if ( count < 0 ) { count = 0 }

      if ( count == holidayDateArray.length ) {
         timeDisplay = "";
      }
      else {
         holidayDate = holidayDateArray[count];
         holiday = holidayArray[count];
         holidayMessage = holidayMessageArray[count];
      }
   }
} <!-- End function selectHoliday() /-->




   /* FUNCTION getTime() CONTINUOUSLY CALCULATES THE REMAINING TIME UNTIL THE COMING
      EVENT AND THEN RESETS ITSELF TO THE NEXT EVENT AFTER THE END OF THE COMING EVENT  */
function getTime() {
   now = new Date();
   days = Math.floor((holidayDate - now) / 86400000);
   hours = Math.floor((holidayDate - now) / 3600000 - (24 * days));
   minutes = Math.floor((holidayDate - now) / 60000 - (1440 * days) - (60 * hours));
   seconds = Math.round((holidayDate - now) / 1000 - (86400 * days) - (3600 * hours)
      - (60 * minutes));
   dayLabel = (days == 1) ? " day" : " days";
   hourLabel = (hours == 1) ? " hour" : " hours";
   minLabel = (minutes == 1) ? " minute" : " minutes";
   secLabel = (seconds == 1) ? " second " : " seconds ";

   if (days <= -2 ) {
      count++;
      holidayDate = holidayDateArray[count];
      holiday = holidayArray[count];
      holidayMessage = holidayMessageArray[count];
   }



<!-- ==================== RECORDS THE BEGINNING OF THE THREE EIGHT DAY HOLIDAYS AND COMPARES TO CURRENT DATE ==================== /-->

   Sukkot = holidayDateArray[3];       <!-- *** MAKE SURE THIS ARRAY # MATCHES THE HOLIDAY Date Array # IN THE HOLIDAY/DATES LIST FOR THE SUKKOT DATE ABOVE /-->
   SukkotDate = new Date();
   SukkotDays = Math.floor((SukkotDate - Sukkot) / 86400000) + 1;

   Channukah = holidayDateArray[4];    <!-- *** MAKE SURE THIS ARRAY # MATCHES THE HOLIDAY Date Array # IN THE HOLIDAY/DATES LIST FOR THE CHANNUKAH DATE ABOVE /-->
   ChannukahDate = new Date();
   ChannukahDays = Math.floor((ChannukahDate - Channukah) / 86400000) + 1;

   Passover = holidayDateArray[8];     <!-- *** MAKE SURE THIS ARRAY # MATCHES THE HOLIDAY Date Array # IN THE HOLIDAY/DATES LIST FOR THE PASSOVER DATE ABOVE /-->
   Omer = new Date();
   OmerDays = Math.floor((Omer - Passover) / 86400000);
   PassoverDays = OmerDays + 1;



<!-- ============== FORMATING OF DAYS, HOURS, MINUTES, AND SECONDS ============== /-->
   if (days >= 7 )
      { timeDisplay = days + dayLabel + " left until " + holiday + " (at 6:00 PM) "; }
   if (days >= 0 & days <= 6 )
      { timeDisplay = days + dayLabel + ", " + hours + hourLabel + " left until "
      + holiday + " (at 6:00 PM)"; }
   if (days == 0 )
      { timeDisplay = hours + hourLabel + ", " + minutes + minLabel + " left until "
      + holiday + " (at 6:00 PM)"; }
   if (days == 0 & hours == 0)
      { timeDisplay = minutes + minLabel + ", " + seconds + secLabel + "left until "
      + holiday + " (at 6:00 PM)"; }
   if (days == 0 & hours == 0 & minutes == 0)
      { timeDisplay = seconds + secLabel + "left until " + holiday + " (at 6:00 PM)"; }
   if (days == -1)
      { timeDisplay = holidayMessage }
   if (days <= -2 & ( count == holidayDateArray.length ) )
      { timeDisplay = ""; }



<!-- ============== BEGIN DISPLAY CODE ============== /-->

   if ( document.layers ) {
      write( timeDisplay );
      close();
   }



<!-- ================== DISPLAY EIGHT DAY HOLIDAYS ON SECOND LINE =================== /-->
   else if ( document.all && ( SukkotDays > 1 & SukkotDays < 10 ) ) {
      clock.innerHTML = SukkotMessageArray[SukkotDays - 2]
      + "<br><font color='#B5B5FF'>" + timeDisplay + "</font>"; }
   else if ( document.all && ( ChannukahDays > 1 & ChannukahDays < 9 ) ) {
      clock.innerHTML = "Channukah Day " + ChannukahDays
      + "<br><font color='#B5B5FF'>" + timeDisplay + "</font>"; }
   else if ( document.all && ( PassoverDays > 1 & PassoverDays < 9 ) ) {
      clock.innerHTML = PassoverMessageArray[PassoverDays - 2] + " - "
      + "<font color='#FF0000'>" + OmerDays  + " B'Omer</font><br><font color='#B5B5FF'>"
      + timeDisplay + "</font>"; }
   else if ( document.all && ( OmerDays > 7 & OmerDays < 50 ) ) {
      clock.innerHTML = timeDisplay + "<br><font color='#FF0000'>" + OmerDays 
      + " B'Omer</font>"; }



<!-- ===== DISPLAY REGULAR COUNTDOWN TIMER ===== /-->
   else if ( document.all ) {
      clock.innerHTML = timeDisplay }
   setTimeout( "getTime()", 1000 )  <!-- ===== REFRESH DISPLAY EVERY SECOND (1000 ms) ===== /-->

} <!-- End function getTime() /-->


window.onload = getTime;

