<!-- // 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(5);
   Events[i][0] = "@";
   Events[i][1] = "@";
   Events[i][2] = "@";
   Events[i][3] = "@";
   Events[i][4] = "@";
}

/* 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 five lines.  Examples:
 *   Events[0][0] = '10/31/2001';
 *   Events[0][1] = '10/31/2001';
 *   Events[0][2] = 'headline';
 *   Events[0][3] = 'link';
 *   Events[0][4] = 'blurb';
 *
 * 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[1][0]   = '8/31/2009';
Events[1][1]   = '1/15/2010';
Events[1][2]   = 'Did you know you DO NOT have to call WJ to report an absence?';
Events[1][3]   = '/schools/wjhs/studserve/attendance/';
Events[1][4]   = 'Click the above link to review WJ\'s attendance policies.';

Events[2][0]   = '1/1/2009';
Events[2][1]   = '12/31/2009';
Events[2][2]   = 'Shop the WJ School Store!';
Events[2][3]   = '/schools/wjhs/schoolstore/hours.shtm';
Events[2][4]   = 'Click the above link for store hours';

Events[6][0]   = '9/1/2009';
Events[6][1]   = '12/31/2009';
Events[6][2]   = 'Register your Giant Card so WJ earns <i>A+ Bonus Bucks</i>!'; 
Events[6][3]   = '/schools/wjhs/information/fundraising/giant.html';
Events[6][4]   = '';

Events[7][0]   = '9/1/2009';
Events[7][1]   = '12/31/2009';
Events[7][2]   = 'Register your Harris Teeter Card to Support WJ!'; 
Events[7][3]   = '/schools/wjhs/information/fundraising/harris_teeter.shtm';
Events[7][4]   = '';

Events[8][0]   = '9/1/2009';
Events[8][1]   = '12/31/2009';
Events[8][2]   = 'Register your Safeway Card to Support WJ!'; 
Events[8][3]   = '/schools/wjhs/information/fundraising/safeway.html';
Events[8][4]   = '';

Events[9][0]   = '9/15/2009';
Events[9][1]   = '10/15/2009';
Events[9][2]   = 'Hispanic Heritage Month through 10/15';
Events[9][3]   = '';
Events[9][4]   = '';

Events[10][0]   = '10/26/2009';
Events[10][1]   = '11/1/2009';
Events[10][2]   = '11/1 - Daylight Saving Time Ends - Turn Clock Back!';
Events[10][3]   = '';
Events[10][4]   = '';

Events[11][0]   = '11/1/2009';
Events[11][1]   = '11/30/2009';
Events[11][2]   = 'November is American-Indian Heritage Month';
Events[11][3]   = '';
Events[11][4]   = '';

Events[12][0]   = '2/1/2010';
Events[12][1]   = '2/28/2010';
Events[12][2]   = 'February is African-American Heritage Month';
Events[12][3]   = '';
Events[12][4]   = '';

Events[13][0]   = '3/1/2010';
Events[13][1]   = '3/31/2010';
Events[13][2]   = 'March is Women\'s History Month';
Events[13][3]   = '';
Events[13][4]   = '';

Events[14][0]   = '4/1/2010';
Events[14][1]   = '4/30/2010';
Events[14][2]   = 'April is Arab-American Heritage Month &amp; Autism Awareness Month';
Events[14][3]   = '';
Events[14][4]   = '';

Events[15][0]   = '5/1/2010';
Events[15][1]   = '5/31/2010';
Events[15][2]   = 'May is Asian-American Heritage Month';
Events[15][3]   = '';
Events[15][4]   = '';

Events[38][0]   = '9/1/2009';
Events[38][1]   = '9/17/2009';
Events[38][2]   = 'MCPS Community Forums 9/17 &amp; 10/15';
Events[38][3]   = '/community/forums/';
Events[38][4]   = 'The Board of Education invites parents, staff, students and community members to two community forums this fall. Speakers can give ' +
                  'their input on what is working and what needs improvement in the school system. ' +
                  'Click the above link for additional information, including times and locations.';

Events[39][0]   = '9/18/2009';
Events[39][1]   = '10/16/2008';
Events[39][2]   = 'MCPS Community Forum 10/15';
Events[39][3]   = '/community/forums/';
Events[39][4]   = 'The Board of Education invites parents, staff, students and community members to the 2nd community ' +
                  'forum this fall. Speakers can give their input on what is working and what needs improvement in the ' +
                  'school system. Click the above link for additional information, including time and location.';

Events[54][0]   = '9/1/2009';
Events[54][1]   = '4/1/2010';
Events[54][2]   = '2009-2010 Sports Schedules Are Online';
Events[54][3]   = '/schools/wjhs/athletics/';
Events[54][4]   = 'Click the above link and then "Fall", "Winter" or "Spring" and choose the sport you are interested in.';

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());

//document.write('<h1>News Items...</h1>'); //write the category heading

for(i=0; i<MAX_ELEM; i++)
{
if (Events[i][0] != "@")
{
  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);

/* prepare the data to display

 * If it's within the date range...
 * If blurb is blank don't display a + sign
 * If link is non-blank, code it.
 * Display the headline
 * Display any non-blank blurb 
 */

  if(sdate <= cdate && edate >= cdate)
   { var headline = "<h3>";
if (Events[i][4] != "")
  headline = headline + '<img src="/gr/collapse-small.gif" border="0" onclick="javascript:tdisplay(700' + i + ')" id="700' 
  + i + 'plus" class="plusminus"><img src="/gr/expand-small.gif" border="0" onclick="javascript:tdisplay(700' + i + 
  ')" id="700' + i + 'minus" style="display:none" class="plusminus">';

 if (Events[i][3] != "")
  headline = headline + '<a href="' + Events[i][3] + '" target="_blank">';  

 headline = headline + Events[i][2];

 if (Events[i][3] != "")
 headline = headline + '</a>';

 headline = headline + '</h3>';

 document.write('<span class="specstyle">' + headline + '</span>');

 if (Events[i][4] != "")
      document.write('<p id="700' + i + '" style="display:none">' + Events[i][4] + '</p>');

// Display the data
//       document.write('<span class="specstyle">' +
//       Events[i][2] + '</span><br><br>');
// debugging
//  document.write(sdate + " " + cdate + " " + edate + "<br>");

} 
} 
}
} // date-check
document.write('<p></p>'); //blank line at the end


// End hiding the Script-->
