<!-- // 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[0][0]    = '10/6/2009';
Events[0][1]    = '10/11/2009';
Events[0][2]    = '10/12 - Parents Welcome for Open House, 7:30-10:30 a.m. - Student Commons';
Events[0][3]    = 'information/openhouse.shtm';
Events[0][4]    = '';


Events[1][0]    = '1/7/2008';
Events[1][1]    = '1/24/2008';
Events[1][2]    = 'Join us for two important parent events on 1/24 &amp; 1/31';
Events[1][3]    = '';
Events[1][4]    = 'The annual information meeting for registration for the 2008-2009 school year will be held on ' +
                  'the 24th. <a href="information/letters/registration.pdf">Read Dr. Garran\'s letter</a> for more ' + 
                  'information. Second Semester Back-to-School Night will be on the 31st. ' +
                  '<a href="information/letters/btsn2.pdf">Read Dr. Garran\'s letter</a> for more information.';

Events[2][0]    = '10/13/2009';
Events[2][1]    = '10/16/2009';
Events[2][2]    = 'MD DHHS to offer free H1N1 (swine) flu vaccine to MCPS students';
Events[2][3]    = '';
Events[2][4]    = 'Click the H1N1 graphic to the left of the screen for more information.';

Events[3][0]    = '10/1/2009';
Events[3][1]    = '12/31/2009';
Events[3][2]    = 'Free SAT/ACT Test Prep And Study Guides Available OnLine';
Events[3][3]    = '/curriculum/hsi/testprep.shtm';
Events[3][4]    = 'There are two FREE test prep courses available to all MCPS high school students. Click the above link for more information and to access the courses.';

Events[4][0]    = '8/5/2009';
Events[4][1]    = '8/24/2009';
Events[4][2]    = '9/26 - Kensington 8K/2M/1K Proceeds to Benefit WJ. Register To Participate Today!';
Events[4][3]    = 'http://www.kensington8k.org';
Events[4][4]    = 'Proceeds from this annual event benefit Kensington Parkwood Elementary, North Bethesda Middle School and Walter Johnson High School. Click the above link for ' +
                  'more information and to register online.';

Events[5][0]    = '3/1/2009';
Events[5][1]    = '4/15/2009';
Events[5][2]    = 'Submit a Nomination for the 2009 "Hall of Fame" Awards!';
Events[5][3]    = 'orgs/ptsa/hof_award/';
Events[5][4]    = 'The PTSA is again requesting nominations for WJ\'s annual "Hall of Fame" Awards for deserving  ' + 
                  'members of the faculty and staff. Click the link above for more information and to submit ' +
                  'your nomination. The deadline is April 15th so do it today!';

Events[20][0]    = '8/10/2009';
Events[20][1]    = '8/27/2009';
Events[20][2]    = 'About Student Address Changes';
Events[20][3]    = 'studserve/registrar';
Events[20][4]    = 'Address changes for WJ students must be provided to WJ Registrar Clara Matos in person. A current lease, property tax bill or the closing documents from a home purchase ' +
                   'must be presented as proof of residency in the WJ school district. Click the above link for information about the Registrar\'s Office';

Events[21][0]    = '8/29/2009';
Events[21][1]    = '9/17/2009';
Events[21][2]    = 'Student Parking Permit Information';
Events[21][3]    = 'studserve/security/parking.shtm';
Events[21][4]    = 'Click the above link for information on what to bring and where to go for permit permits.';

Events[22][0]    = '9/16/2008';
Events[22][1]    = '9/29/2008';
Events[22][2]    = 'Congratulations to WJ\'s National Merit Scholarship Semifinalists';
Events[22][3]    = 'information/student_awards/nm.shtm';
Events[22][4]    = '';

Events[23][0]    = '9/4/2009';
Events[23][1]    = '9/30/2009';
Events[23][2]    = '<i>The Pitch</i> Goes Online';
Events[23][3]    = 'http://wjpitch.com/';
Events[23][4]    = 'In addition to the printed newspaper, staff sponsor Hilary Gates and her students have started timely online reporting of stories of interest. Click the above link ' +
                    'to read <i>The Pitch</i> Online';
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('<hr>'); //write the divider

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(900' + i + ')" id="900' 
  + i + 'plus" class="plusminus"><img src="/gr/expand-small.gif" border="0" onclick="javascript:tdisplay(900' + i + 
  ')" id="900' + 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="900' + 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('<hr>'); //write the divider

//document.write('<p></p>'); //blank line at the end


// End hiding the Script-->
