<!-- // Hide the script

/*
 * eventcheck.js
 *
 * Checks the date and prints important events corresponding with those dates
 * Michael Lieberman, 2001
 *
 * Date::getYear() fix
 */

// Constants
var MAX_ELEM   = 100; // The maximum number of events that the array can hold
var START_TIME = 0;   // The time to begin displaying events (24hr)
var END_TIME   = 24;  // The time to stop displaying events  (24hr)

var now = new Date();
if(now.getHours() >= START_TIME && now.getHours() < END_TIME)
{

/* Events is the two dimensional array holding the dates and events.
 * For any given i (under MAX_ELEM):
 *   Events[i][0] is the starting date string
 *   Events[i][1] is the ending date string
 *   Events[i][2] is the event string
 */
var Events = new Array(MAX_ELEM);

// "@" will be the string to flag the unfilled items
for(i=0; i<MAX_ELEM; i++)
{
   Events[i] = new Array(3);
   Events[i][0] = "@";
   Events[i][1] = "@";
   Events[i][2] = "@";
}

/* Manually fill in the dates / events.  I wanted to read from a text file
 *   but Javascript would not allow me...
 *
 * To add a new event, add three lines.  Examples:
 *   Events[0][0] = '10/31/2001';
 *   Events[0][1] = '10/31/2001';
 *   Events[0][2] = 'Halloween';
 *
 *   Events[1][0] = '1/1/2002';
 *   Events[1][1] = '1/8/2002';
 *   Events[1][2] = 'Celebration for a week';
 *
 * Time the event will be displayed:  Starting on Events[n][0],
 *                                    Ending at the end of the day Events[n][1]
 *
 * The event name can also have HTML tags.
 * The order in which events are entered does not matter.  The events will be
 *   displayed on the page (if the date is in the valid range) in whatever
 *   order they are in in the array.
 */

Events[0][0]    = '8/25/2009';
Events[0][1]    = '9/26/2009';
Events[0][2]    = '9/26 - Join us for the Kensington 8K to support the WJ Ed Foundation. ' +
                  '<a href="http://www.kensington8k.org/" target="_blank">Click here for info &amp; online registration</a>';

Events[1][0]    = '8/7/2009';
Events[1][1]    = '10/2/2009';
Events[1][2]    = '10/2 - Homecoming Football \'09 vs. Poolesville, 6:30 p.m.<br>' +
                  '<font size="-1">Come cheer on the Wildcats and check out the NEW WJ Stadium!</font>';

Events[2][0]    = '9/14/2009';
Events[2][1]    = '12/5/2009';
Events[2][2]    = '12/5 - Support the WJ Ed Foundation - Attend the Fall Gala at The Ratner Museum. ' +
                  '<a href="http://wjedfoundation.org/gala-museum.html" target="_blank">Click here for info about the Foundation, to buy tickets or to contribute to the silent auction</a>';

Events[3][0]    = '10/15/2009';
Events[3][1]    = '11/24/2009';
Events[3][2]    = 'Help WJ Win the Turkey Chase Scholarship. Designate WJ if you are participating in the YMCA Race. ' +
                  '<a href="http://www.turkeychase.com/" target="_blank">Click here for info &amp; online registration</a>.';

Events[4][0]    = '12/6/2009';
Events[4][1]    = '12/31/2009';
Events[4][2]    = 'Support the WJ Ed Foundation. ' +
                  '<a href="http://www.wjedfoundation.org/" target="_blank">Click here for info about the Foundation</a>.';

i = 0;

// The locations of the slashes in the date
var AFSlash, ALSlash, BFSlash, BLSlash;

// Starting date / ending date strings -- used for comparison
var sdate = "", edate = "";
var cdate;

    /* The Netscape and IE versions of Date::getYear() return different values.
     *   Netscape returns the number of years since 1900, while IE returns
     *   the four number year.
     *
     * NOTE: I have not tested this code on other browsers, so I am assuming
     *   that every other browser in existence returns the four number year. ;)
     */
    if(navigator.appName.toLowerCase().indexOf("netscape") != -1)
       cdate = parseInt(now.getYear()+1900) + "-";
//    else if(navigator.appName.toLowerCase().indexOf("internet explorer") != -1)
//       cdate = parseInt(now.getYear()) + "-";
    else
       cdate = parseInt(now.getYear()) + "-";

    if((now.getMonth()+1) < 10)
      cdate += "0";
    cdate += (parseInt(now.getMonth()+1) + "-");

    if(now.getDate() < 10)
      cdate += "0";
    cdate += parseInt(now.getDate());

for(i=0; i<MAX_ELEM; i++)
{
if ((Events[i][0] != "@" || Events[i][1] != "@") && Events[i][2] != "@")
{
  AFSlash = Events[i][0].indexOf("/");
  ALSlash = Events[i][0].lastIndexOf("/");
  BFSlash = Events[i][1].indexOf("/");
  BLSlash = Events[i][1].lastIndexOf("/");

  sdate = Events[i][0].substring(ALSlash+1,Events[i][0].length) + "-";

  if(parseInt(Events[i][0].substring(0,AFSlash)) < 10)
    sdate += "0";
  sdate += (Events[i][0].substring(0,AFSlash) + "-");

  if(parseInt(Events[i][0].substring(AFSlash+1,ALSlash)) < 10)
    sdate += "0";
  sdate += Events[i][0].substring(AFSlash+1,ALSlash);

  edate = Events[i][1].substring(BLSlash+1,Events[i][1].length) + "-";

  if(parseInt(Events[i][1].substring(0,BFSlash)) < 10)
    edate += "0";
  edate += (Events[i][1].substring(0,BFSlash) + "-");

  if(parseInt(Events[i][1].substring(BFSlash+1,BLSlash)) < 10)
    edate += "0";
  edate += Events[i][1].substring(BFSlash+1,BLSlash);

  if(sdate <= cdate && edate >= cdate)
       document.write('<h3>' +
       Events[i][2] + '</h3>');
// debugging
//  document.write(sdate + " " + cdate + " " + edate + "<br>");

}
}

} // date-check
document.write('<p></p>'); //blank line at the end


// End hiding the Script-->

