<!-- // Hide the script

/*
 * bellchg.js
 *
 * Checks the date and prints a banner message for days when the bell schedule changes
 * Maria Limarzi, 2009
 *
 * Date::getYear() fix
 */

// Constants
var MAX_ELEM   = 100; // The maximum number of events that the array can hold

var now = new Date();

/* 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 end of the filled portion of Events
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. 
 *
 * 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]    = '3/1/2009';
Events[0][1]    = '3/4/2009';
Events[0][2]    = '<div id="div-banner"><a href="/info/emergency/" target="_blank">Click here for MCPS Weather Announcements</a></div>';  
/*
Events[1][0]    = '2/1/2008';
Events[1][1]    = '2/1/2008';
Events[1][2]    = '<div id="div-banner">2/1 - Delayed Opening <a href="information/bells/delay.shtm">Bell Schedule</a>.</div>';

Events[2][0]    = '1/19/2008';
Events[2][1]    = '1/20/2008';
Events[2][2]    = '<div id="div-banner"><a href="http://www.montgomerycountymd.gov/cuptmpl.asp?url=/content/cupf/html/info-school/emerg.asp" target="_blank">Click ' + 
                  'here for weekend weather closings</div>';
*/
Events[1][0]    = '9/4/2009';
Events[1][1]    = '9/8/2009';
Events[1][2]    = '<div id="div-banner">Tues, Sept 8 is a <a href="information/bells/obama.shtm">special bell schedule</a></div>';

Events[2][0]    = '9/30/2009';
Events[2][1]    = '10/2/2009';
Events[2][2]    = '<div id="div-banner">Fri, Oct 2 is Homecoming Video &amp; early release<br><a href="information/bells/homecoming_video.shtm">special bell schedule</a></div>';

Events[3][0]    = '10/12/2009';
Events[3][1]    = '10/14/2009';
Events[3][2]    = '<div id="div-banner">Wed, Oct 14 is PSAT <a href="information/bells/psat.shtm">special bell schedule</a><br>' +
                  'Thurs, Oct 15 is assembly <a href="information/bells/assembly.shtm">special bell schedule</a></div>';

Events[4][0]    = '10/15/2009';
Events[4][1]    = '10/15/2009';
Events[4][2]    = '<div id="div-banner">Thurs, Oct 15 is assembly <a href="information/bells/assembly.shtm">special bell schedule</a></div>';

Events[5][0]    = '10/28/2009';
Events[5][1]    = '10/30/2009';
Events[5][2]    = '<div id="div-banner">Fri, Oct 30 is \"Bad Day To Be A Pumpkin\" <a href="information/bells/pumpkin.shtm">special bell schedule</a><br>' +
                  'Sun, Nov 1 Daylight Saving Time Ends. Turn Clocks Back 1 Hour!</div>';

Events[6][0]    = '10/30/2009';
Events[6][1]    = '11/1/2009';
Events[6][2]    = '<div id="div-banner">Sun, Nov 1 Daylight Saving Time Ends. Turn Clocks Back 1 Hour!</div>';

Events[7][0]    = '11/4/2009';
Events[7][1]    = '11/6/2009';
Events[7][2]    = '<div id="div-banner">Fri, Nov 6 - Walter Johnson, our namesake, born 1887.<br>Happy Birthday!</div>';

Events[8][0]    = '11/9/2009';
Events[8][1]    = '11/11/2009';
Events[8][2]    = '<div id="div-banner">Wed, Nov 11 is report card <a href="information/bells/report.shtm">special bell schedule</a></div>';

Events[9][0]    = '11/17/2009';
Events[9][1]    = '11/19/2009';
Events[9][2]    = '<div id="div-banner">Thur, Nov 19 is Senior Citizen Luncheon <a href="information/bells/srcit.shtm">special bell schedule</a></div>';

Events[10][0]    = '11/20/2009';
Events[10][1]    = '11/25/2009';
Events[10][2]    = '<div id="div-banner">Wed, Nov 25 is early release <a href="information/bells/early.shtm">special bell schedule</a><br>' +
                  'Nov 26-27 school closed. Happy Thanksgiving</div>';

Events[11][0]    = '1/9/2010';
Events[11][1]    = '1/22/2010';
Events[11][2]    = '<div id="div-banner">Jan 15-22 are final exam <a href="information/exam_winter_guidelines.shtm">special bell schedules</a></div>';

Events[12][0]    = '2/1/2010';
Events[12][1]    = '2/3/2010';
Events[12][2]    = '<div id="div-banner">Wed, Feb 3 is report card <a href="information/bells/report.shtm">special bell schedule</a></div>';

Events[13][0]    = '2/22/2010';
Events[13][1]    = '2/24/2010';
Events[13][2]    = '<div id="div-banner">Wed, Feb 24 is assembly <a href="information/bells/assembly.shtm">special bell schedule</a></div>';

Events[14][0]    = '2/24/2010';
Events[14][1]    = '2/26/2010';
Events[14][2]    = '<div id="div-banner">Fri, Feb 26 is early release <a href="information/bells/early.shtm">special bell schedule</a></div>';

Events[15][0]    = '3/1/2010';
Events[15][1]    = '3/4/2010';
Events[15][2]    = '<div id="div-banner">Sun, Mar 4 Daylight Saving Time Begins.<br>Turn Clocks Ahead 1 Hour!</div>';

Events[16][0]    = '4/12/2010';
Events[16][1]    = '4/14/2010';
Events[16][2]    = '<div id="div-banner">Wed, Apr 14 is report card <a href="information/bells/report.shtm">special bell schedule</a></div>';

Events[16][0]    = '5/11/2010';
Events[16][1]    = '5/21/2010';
Events[16][2]    = '<div id="div-banner">May 17, 18, 20 &amp; 21 are HSA &amp; Senior Exams<br><a href="depts/hsa_schedule.shtm">Special Bell Schedules/Delayed Openings</a></div>';

Events[18][0]    = '6/4/2010';
Events[18][1]    = '6/16/2010';
Events[18][2]    = '<div id="div-banner">Jan 10-16 are final exam <a href="depts/hsa_schedule.shtm">special bell schedules</a></div>';

Events[99][0]    = '11/13/2009';
Events[99][1]    = '11/16/2009';
Events[99][2]    = '<div id="div-banner"><a href="orgs/classes/senior/graduation.shtm">Commencement 2010 is June 1st at 7:00 p.m.</a><!-- Classes canceled for undergraduates--></div>';

i = 0;

// The locations of the slashes in the date
var AFSlash, ALSlash, BFSlash, BLSlash, display;

// Starting date / ending date strings -- used for comparison
var sdate = "", edate = ""; writestring = "";
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++)
{
display = 1 /* set the flag to display */
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);

  if(sdate <= cdate && edate >= cdate)
  {

if (edate == cdate) /* is the end date */
{
   if(now.getHours() > 14) display = 0 /* after 2 p.m. we don't want to display */
}
if (display == 1)
{
       writestring = '<span class="style9">' + Events[i][2] + '</span>'
       document.write(writestring);
} 
 }
// debugging
//  document.write(sdate + " " + cdate + " " + edate + "<br>");

}
}

// End hiding the Script-->
