// readfile.js
// updated November 16, 2008
//--------------------------------------------------------------------------------
//  variables
//--------------------------------------------------------------------------------
    var all_lines = new Array();                       // holds the lines read in the .csv file
    var current_lines = new Array();                   // holds the current lines in the array
    var numcurrent = 0;                                // holds the current number of lines in the array
    var gridline = "";                                 // holds the text to be displayed
    var links_all = new Array();                       // holds the lines read in the links.csv file
//--------------------------------------------------------------------------------
// getEvents - load the Events from the roundups_events.csv file into the div
//--------------------------------------------------------------------------------
    function getEvents() 
    {
        var event_years = new Array();                 // holds the years of events
        var numyears = 0;                              // holds the number of years
        var matched = 0;                               // holds results of comparison test

        // add the table header to the replacement text line
        gridline = "<table align='center'>";

        if (window.XMLHttpRequest) 
        { 
           // reset the years array and its counter to empty
           event_years = new Array();             numyears = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/roundups_events.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
               //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
               var fields=lines[n].split("|"); 
               // if the page field (field[5]) is "Events"
               if (fields[5] == "Events")
               {
                   // add the current line to the current lines array
                   current_lines[numcurrent] = lines[n];
                   // increment the number of current lines
                   numcurrent = numcurrent + 1;
                   // if the number of years is 0, meaning the line is the first line in the lines array  
                   if (numyears == 0) { 
                      // add the year in the years array 
                      event_years[numyears] = fields[1];    
                      // increment the number of years counter
                      numyears = numyears + 1;
                   }
                   // since the number of years is > 0, meaning not the first line in the array
                   else
                   {
                       // set the comparison flag to 0 for false
                       matched = 0;
                       // go through each of the years in the array
                       for (var k=0;k<numyears;k++){
                           // if the year of the current line (fields[5]) = the current year in the array
                           if (event_years[k] == fields[1]){
                               // set the comparison flag to 1 for true
                                matched = 1;
                           }
                       }
                       // if the comparison flag = 0, meaning the year of the current line is not in the
                       // years array
                       if (matched == 0)
                       {
                           // add the year in the years array 
                           event_years[numyears] = fields[1];    
                           // increment the number of years counter
                           numyears = numyears + 1;
                       }
                   }
               }
           }
           // for each of the years in the years array
           for(var k=0;k<numyears;k++)
           {
               // add the year heading's table row heading to the replacement text line
               gridline = gridline + " <tr>";
               gridline = gridline + "   <td>";
               gridline = gridline + "     <h3 id='links'>" + event_years[k] + "</h3>";
               gridline = gridline + "     <ul>";
               //for each line in the current lines array
               for (var n=0;n<current_lines.length;n++)
               {
                   // split the line into it components, using | as the delimiter
                   //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
                   //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
                   var fields=current_lines[n].split("|"); 
                   // if the current line's year (fields[1]) matches the current year 
                   if (fields[1] == event_years[k])
                   {
                      // add the information to the table
                      gridline = gridline + "       <li id='links_li'><a href='";
                      gridline = gridline + fields[7] + "'>" + fields[6] + "</a></li>";
                   }
               }
               // now that all of the information for the current year has been loaded
               // add the table row closing to the replacement text line
               gridline = gridline + "     </ul>";
               gridline = gridline + "   </td>";
               gridline = gridline + " </tr>";
           }
           // add the table closing to the replacement text line
           gridline = gridline + "</table>";
           // replace the "events_table" div's content with the replacement text line
           document.getElementById("events_table").innerHTML = gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the years array and its counter to empty
           event_years = new Array();             numyears = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/roundups_events.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
                  //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
                  var fields=lines[n].split("|"); 
                  // if the page field (field[5]) is "Events"
                  if (fields[5] == "Events")
                  {
                      // add the current line to the current lines array
                      current_lines[numcurrent] = lines[n];
                      // increment the number of current lines
                      numcurrent = numcurrent + 1;
                      // if the number of years is 0, meaning the line is the first line in the lines array  
                      if (numyears == 0) { 
                         // add the year in the years array 
                         event_years[numyears] = fields[1];    
                         // increment the number of years counter
                         numyears = numyears + 1;
                      }
                      // since the number of years is > 0, meaning not the first line in the array
                      else
                      {
                          // set the comparison flag to 0 for false
                          matched = 0;
                          // go through each of the years in the array
                          for (var k=0;k<numyears;k++){
                              // if the year of the current line (fields[5]) = the current year in the array
                              if (event_years[k] == fields[1]){
                                  // set the comparison flag to 1 for true
                                  matched = 1;
                              }
                          }
                          // if the comparison flag = 0, meaning the year of the current line is not in the years array
                          if (matched == 0)
                          {
                              // add the year in the years array 
                              event_years[numyears] = fields[1];    
                              // increment the number of years counter
                              numyears = numyears + 1;
                          }
                      }
                  }
              }
              // for each of the years in the years array
              for(var k=0;k<numyears;k++)
              {
                  // add the year heading's table row heading to the replacement text line
                  gridline = gridline + " <tr>";
                  gridline = gridline + "   <td>";
                  gridline = gridline + "     <h3 id='links'>" + event_years[k] + "</h3>";
                  gridline = gridline + "     <ul>";
                  //for each line in the current lines array
                  for (var n=0;n<current_lines.length;n++)
                  {
                      // split the line into it components, using | as the delimiter
                      //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
                      //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
                      var fields=current_lines[n].split("|"); 
                      // if the current line's year (fields[1]) matches the current year 
                      if (fields[1] == event_years[k])
                      {
                         // add the information to the table
                         gridline = gridline + "       <li id='links_li'><a href='";
                         gridline = gridline + fields[7] + "'>" + fields[6] + "</a></li>";
                      }
                  }
                  // now that all of the information for the current year has been loaded
                  // add the table row closing to the replacement text line
                  gridline = gridline + "     </ul>";
                  gridline = gridline + "   </td>";
                  gridline = gridline + " </tr>";
              }
              // add the table closing to the replacement text line
              gridline = gridline + "</table>";
              // replace the "events_table" div's content with the replacement text line
              document.getElementById("events_table").innerHTML = gridline;
          }
       }
    }

//--------------------------------------------------------------------------------
// getRoundups -  - load the Roundups from the roundups_events.csv file into the div
//--------------------------------------------------------------------------------
    function getRoundups() 
    {
        var roundups = new Array();                    // holds the roundups
        var numroundups = 0;                           // holds the number of roundups
        var matched = 0;                               // holds results of comparison test

        // add the table header to the replacement text line
        gridline = "<table align='center'>";
        if (window.XMLHttpRequest) 
        { 
           // reset the roundups array and its counter to empty
           roundups = new Array();             numroundups = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/roundups_events.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
               //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
               var fields=lines[n].split("|"); 
               // if the page field (field[5]) is "Roundups"
               if (fields[5] == "Roundups")
               {
                   // add the current line to the current lines array
                   current_lines[numcurrent] = lines[n];
                   // increment the number of current lines
                   numcurrent = numcurrent + 1;
                   // if the number of roundups is 0, meaning the line is the first line in the lines array  
                   if (numroundups == 0)
                   {
                      // add the month and year to the roundups array 
                      roundups[numroundups] = fields[2] + " " + fields[1];
                      // increment the number of roundups counter
                      numroundups = numroundups + 1;
                   }
                   // since the number of roundups is > 0, meaning not the first line in the array
                   else
                   {
                       // set the comparison flag to 0 for false
                       matched = 0;
                       // go through each of the roundups in the array
                       for (var k=0;k<numroundups;k++){
                           // if the roundup of the current line (fields[2] + " " + fields[1]) = the current roundup in the array
                           if (roundups[k] == (fields[2] + " " + fields[1])){
                               // set the comparison flag to 1 for true
                               matched = 1;
                           }
                       }
                       // if the comparison flag = 0, meaning the roundup of the current line is not in the roundups array
                       if (matched == 0)
                       {
                           // add the month and year to the roundups array 
                           roundups[numroundups] = fields[2] + " " + fields[1];
                           // increment the number of roundups counter
                           numroundups = numroundups + 1;
                       }
                   }
               }
           }
           // for each of the roundups in the roundups array
           for(var k=0;k<numroundups;k++)
           {
               // add the roundups heading's table row heading to the replacement text line
               gridline = gridline + " <tr>";
               gridline = gridline + "   <td>";
               gridline = gridline + "     <h3 id='links'>" + roundups[k] + "</h3>";
               gridline = gridline + "     <ul>";
               //for each line in the current lines array
               for (var n=0;n<current_lines.length;n++)
               {
                   // split the line into it components, using | as the delimiter
                   //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
                   //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
                   var fields=current_lines[n].split("|"); 
                   // if the current line's roundup ((fields[2] + " " + fields[1])) matches the current roundup
                   if (((fields[2] + " " + fields[1])) == roundups[k])
                   {
                      // add the information to the table
                      gridline = gridline + "       <li id='links_li'><a href='" + fields[7] + "'>" + fields[6] + "</a></li>";
                   }
               }
               // now that all of the information for the current year has been loaded
               // add the table row closing to the replacement text line
               gridline = gridline + "     </ul>";
               gridline = gridline + "   </td>";
               gridline = gridline + " </tr>";
           }
           // add the table closing to the replacement text line
           gridline = gridline + "</table>";
           // replace the "events_table" div's content with the replacement text line
           document.getElementById("roundups_table").innerHTML = gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the roundups array and its counter to empty
           roundups = new Array();             numroundups = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/roundups_events.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
                  //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
                  var fields=lines[n].split("|"); 
                  // if the page field (field[5]) is "Roundups"
                  if (fields[5] == "Roundups")
                  {
                      // add the current line to the current lines array
                      current_lines[numcurrent] = lines[n];
                      // increment the number of current lines
                      numcurrent = numcurrent + 1;
                      // if the number of roundups is 0, meaning the line is the first line in the lines array  
                      if (numroundups == 0)
                      {
                         // add the month and year to the roundups array 
                         roundups[numroundups] = fields[2] + " " + fields[1];
                         // increment the number of roundups counter
                         numroundups = numroundups + 1;
                      }
                      // since the number of roundups is > 0, meaning not the first line in the array
                      else
                      {
                          // set the comparison flag to 0 for false
                          matched = 0;
                          // go through each of the roundups in the array
                          for (var k=0;k<numroundups;k++){
                              // if the roundup of the current line (fields[2] + " " + fields[1]) = the current roundup in the array
                              if (roundups[k] == (fields[2] + " " + fields[1])){
                                  // set the comparison flag to 1 for true
                                  matched = 1;
                              }
                          }
                          // if the comparison flag = 0, meaning the roundup of the current line is not in the roundups array
                          if (matched == 0)
                          {
                              // add the month and year to the roundups array 
                              roundups[numroundups] = fields[2] + " " + fields[1];
                              // increment the number of roundups counter
                              numroundups = numroundups + 1;
                          }
                      }
                  }
              }
              // for each of the roundups in the roundups array
              for(var k=0;k<numroundups;k++)
              {
                  // add the roundups heading's table row heading to the replacement text line
                  gridline = gridline + " <tr>";
                  gridline = gridline + "   <td>";
                  gridline = gridline + "     <h3 id='links'>" + roundups[k] + "</h3>";
                  gridline = gridline + "     <ul>";
                  //for each line in the current lines array
                  for (var n=0;n<current_lines.length;n++)
                  {
                      // split the line into it components, using | as the delimiter
                      //  0   |  1 |  2  | 3 |  4 |  5 |  6  | 7
                      //IGNORE|YEAR|MONTH|DAY|CITY|PAGE|TITLE|URL
                      var fields=current_lines[n].split("|"); 
                      // if the current line's roundup ((fields[2] + " " + fields[1])) matches the current roundup
                      if (((fields[2] + " " + fields[1])) == roundups[k])
                      {
                         // add the information to the table
                         gridline = gridline + "       <li id='links_li'><a href='";
                         gridline = gridline + fields[7] + "'>" + fields[6] + "</a></li>";
                      }
                  }
                  // now that all of the information for the current year has been loaded
                  // add the table row closing to the replacement text line
                  gridline = gridline + "     </ul>";
                  gridline = gridline + "   </td>";
                  gridline = gridline + " </tr>";
              }
              // add the table closing to the replacement text line
              gridline = gridline + "</table>";
              // replace the "events_table" div's content with the replacement text line
              document.getElementById("roundups_table").innerHTML = gridline;
          }
       }
    }


//--------------------------------------------------------------------------------
// getMeetings(district) - get all of the meetings for the passed in district
//                         from the aa_meetings.csv and return as a string to the
//                         calling function
//--------------------------------------------------------------------------------
    function getMeetings(district) 
    {
        var meetings = new Array();                    // holds the meetings
        var nummeetings = 0;                           // holds the number of meetings
        var matched = 0;                               // holds results of comparison test
        var columnnumber = 0;                          // holds the number of columns added for the current line in the table

        // add the table header to the replacement text line
        gridline = "<table align='center'>";
        if (window.XMLHttpRequest) 
        { 
           // reset the meetings array and its counter to empty
           meetings = new Array();             nummeetings = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //     0  |    1   |       2    |   3    |    4  | 5  |  6 
               //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
               var fields=lines[n].split("|"); 
               // if the district (fields[1]) of the current line matches the passed district
               if (fields[1] == district)
               {
                  // add the current line to the meetings array
                  meetings[nummeetings] = lines[n];
                  // increment the number of meetings
                  nummeetings = nummeetings + 1;
               }
           }
           // if there are meetings for the passed district
           if (nummeetings > 0)
           {
               // add the header line to the replacement text line
               gridline = gridline + "<h3 id='links'><center><u>Meetings</u></center></h3>";
               // add the table header line to the replacement text line
               gridline = gridline + "<table align='center'>";
               // reset the column number to 0 for no columns added to the current table row
               var columnnumber = 0;
               for (var n=0;n<nummeetings;n++)
               {
                   // split the line into it components, using | as the delimiter
                   //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                   //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                   var fields=meetings[n].split("|"); 
                   // if the current column counter = 0, meaning the first column
                   if (columnnumber == 0){
                         // add the row header to the replacement text line
                         gridline = gridline + " <tr>";
                   }
                   // add the current row's information as a list with no bullets to a column in the current row 
                   // in the replacement text line
                   //        meeting name                          fields[2] (bold)
                   //        location                              fields[3] if not = "null"
                   //        address                               fields[4] if not = "null"
                   //        city                                  fields[5] (bold)
                   //        times                                 fields[6]
                   gridline = gridline + "   <td valign='top'>";
                   gridline = gridline + "     <ul>";
                   gridline = gridline + "       <li id='meeting_name_li'>"+fields[2];
                   gridline = gridline + "         <ul>";
                   gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
                   if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
                   if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
                   gridline = gridline + "<b>"+fields[5]+"</b><br>"+fields[6]+"</li>";
                   gridline = gridline + "         </ul>";
                   gridline = gridline + "       </li>";
                   gridline = gridline + "     </ul>";
                   gridline = gridline + "   </td>";
                   // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
                   if (columnnumber == 2){
                       // reset the number of columns added to the current row in the table to 0
                       columnnumber = 0;
                       // add the row closing to the replacement text line
                       gridline = gridline + " </tr>";
                   }
                   // otherwise increment the number of columns added to the current row in the table
                   else{columnnumber = columnnumber + 1;}
               }
               // if the number of columns added to the table = 0, add two empty columns to the current row in the table
               if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
               // if the number of columns added to the table = 1, add one empty columns to the current row in the table
               if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
               // add the table closing to the replacement text line
               gridline = gridline + "</table>";
           }
           // return the gridline to the calling function
           return gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the meetings array and its counter to empty
           meetings = new Array();             nummeetings = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                  //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                  var fields=lines[n].split("|"); 
                  // if the district (fields[1]) of the current line matches the passed district
                  if (fields[1] == district)
                  {
                     // add the current line to the meetings array
                     meetings[nummeetings] = lines[n];
                     // increment the number of meetings
                     nummeetings = nummeetings + 1;
                  }
              }
              // if there are meetings for the passed district
              if (nummeetings > 0)
              {
                  // add the header line to the replacement text line
                  gridline = gridline + "<h3 id='links'><center><u>Meetings</u></center></h3>";
                  // add the table header line to the replacement text line
                  gridline = gridline + "<table align='center'>";
                  // reset the column number to 0 for no columns added to the current table row
                  var columnnumber = 0;
                  for (var n=0;n<nummeetings;n++)
                  {
                      // split the line into it components, using | as the delimiter
                      //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                      //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                      var fields=meetings[n].split("|"); 
                      // if the current column counter = 0, meaning the first column
                      if (columnnumber == 0){
                            // add the row header to the replacement text line
                            gridline = gridline + " <tr>";
                      }
                      // add the current row's information as a list with no bullets to a column in the current row 
                      // in the replacement text line
                      //        meeting name                          fields[2] (bold)
                      //        location                              fields[3] if not = "null"
                      //        address                               fields[4] if not = "null"
                      //        city                                  fields[5] (bold)
                      //        times                                 fields[6]
                      gridline = gridline + "   <td valign='top'>";
                      gridline = gridline + "     <ul>";
                      gridline = gridline + "       <li id='meeting_name_li'>"+fields[2];
                      gridline = gridline + "         <ul>";
                      gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
                      if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
                      if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
                      gridline = gridline + "<b>"+fields[5]+"</b><br>"+fields[6]+"</li>";
                      gridline = gridline + "         </ul>";
                      gridline = gridline + "       </li>";
                      gridline = gridline + "     </ul>";
                      gridline = gridline + "   </td>";
                      // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
                      if (columnnumber == 2){
                          // reset the number of columns added to the current row in the table to 0
                          columnnumber = 0;
                          // add the row closing to the replacement text line
                          gridline = gridline + " </tr>";
                      }
                      // otherwise increment the number of columns added to the current row in the table
                      else{columnnumber = columnnumber + 1;}
                  }
                  // if the number of columns added to the table = 0, add two empty columns to the current row in the table
                  if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
                  // if the number of columns added to the table = 1, add one empty columns to the current row in the table
                  if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
                  // add the table closing to the replacement text line
                  gridline = gridline + "</table>";
              }
              // return the gridline to the calling function
              return gridline;
          }
       }
    }


//--------------------------------------------------------------------------------
// getLinks - load the links.csv into the grid
//--------------------------------------------------------------------------------
    function getLinks() 
    {
        var links = new Array();                       // holds the links
        var numlinks = 0;                              // holds the number of links
        var matched = 0;                               // holds results of comparison test

        // add the table header to the replacement text line
        gridline = "<table align='center'>";
        if (window.XMLHttpRequest) 
        { 
           // reset the links array and its counter to empty
           links = new Array();             numlinks = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/links.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //   0  |    1           |  2  | 3 |        4              |   5 |   6
               //IGNORE|GROUP HEADING|TEXT|URL|FORWARDING_INFO_PAGE|LINK|CAPTION#
               var fields=lines[n].split("|"); 
               // if the number of links is 0, meaning the current line is the first line in the array
               if (numlinks == 0){ 
                   // add the current link heading (fields[1]) to the links array  
                   links[numlinks] = fields[1];  
                   // increment the number of links
                   numlinks = numlinks + 1;
               }
               // since this is not the first line in the array
               else
               {
                   // reset the comparison to 0 for false
                   matched = 0;
                   // for each of the links in the links array
                   for (var k=0;k<numlinks;k++){
                        // if the current link (fields[1]) matches the link in the links array
                        if (links[k] == fields[1]){ 
                            // set the comparison flag to 1 for true
                            matched = 1;
                        }
                   }
                   // if comparison flag = 0 for false
                   if (matched == 0){
                      // add the current link heading (fields[1]) to the links array  
                      links[numlinks] = fields[1];  
                      // increment the number of links
                      numlinks = numlinks + 1;
                   }
               }
           }
           // for each link in the links array
           for(var k=0;k<numlinks;k++)
           {
               // add the row heading to the replacement text line
               gridline = gridline + " <tr>   ";
               // add the current link heading to the replacement text line
               gridline = gridline + "<td>     <h3 id='links'>" + links[k] + "</h3>     <ul>";
               //for each line in the lines array, staring with line 1 to ignore the header line
               for (var n=1;n<lines.length-1;n++)
               {
                   // split the line into it components, using | as the delimiter
                   //   0  |    1           |  2  | 3 |        4              |   5 |   6
                   //IGNORE|GROUP HEADING|TEXT|URL|FORWARDING_INFO_PAGE|LINK|CAPTION#
                   var fields=lines[n].split("|"); 
                   // if the current link (fields[1]) = current link
                   if (fields[1] == links[k])
                   {
                      // add the link to the "forwarding" page (fields[4]) with the caption (fields[2]) to the replacement text line
                      //gridline = gridline + "       <li id='links_li'><a href='../links/";
                      //gridline = gridline + fields[4] + "'>" + fields[2] + "</a></li>";
                      gridline = gridline + "       <li id='links_li'><a href='../code/link_specific.html?link=";
                      gridline = gridline + fields[5] + "'>" + fields[2] + "</a></li>";
                   }
               }
               // add the row closing to the replacement text line
               gridline = gridline + "     </ul>   </td> </tr>";
           }
           // add the table closing to the replacement text line
           gridline = gridline + "</table>";
           // replace the "links_table" div's content with the replacement text line
           document.getElementById("links_table").innerHTML = gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the links array and its counter to empty
           links = new Array();             numlinks = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/links.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1        |  2 | 3 |        4  
                  //IGNORE|GROUP HEADING|TEXT|URL|FORWARDING_INFO_PAGE
                  var fields=lines[n].split("|"); 
                  // if the number of links is 0, meaning the current line is the first line in the array
                  if (numlinks == 0){ 
                      // add the current link heading (fields[1]) to the links array  
                      links[numlinks] = fields[1];  
                      // increment the number of links
                      numlinks = numlinks + 1;
                  }
                  // since this is not the first line in the array
                  else
                  {
                      // reset the comparison to 0 for false
                      matched = 0;
                      // for each of the links in the links array
                      for (var k=0;k<numlinks;k++){
                           // if the current link (fields[1]) matches the link in the links array
                           if (links[k] == fields[1]){ 
                               // set the comparison flag to 1 for true
                              matched = 1;
                           }
                      }
                      // if comparison flag = 0 for false
                      if (matched == 0){
                         // add the current link heading (fields[1]) to the links array  
                         links[numlinks] = fields[1];  
                         // increment the number of links
                         numlinks = numlinks + 1;
                      }
                  }
              }
              // for each link in the links array
              for(var k=0;k<numlinks;k++)
              {
                  // add the row heading to the replacement text line
                  gridline = gridline + " <tr>   ";
                  // add the current link heading to the replacement text line
                  gridline = gridline + "<td>     <h3 id='links'>" + links[k] + "</h3>     <ul>";
                  //for each line in the lines array, staring with line 1 to ignore the header line
                  for (var n=1;n<lines.length-1;n++)
                  {
                      // split the line into it components, using | as the delimiter
                      //   0  |    1        |  2 | 3 |        4  
                      //IGNORE|GROUP HEADING|TEXT|URL|FORWARDING_INFO_PAGE
                      var fields=lines[n].split("|"); 
                      // if the current link (fields[1]) = current link
                      if (fields[1] == links[k])
                      {
                         // add the link to the "forwarding" page (fields[4]) with the caption (fields[2]) to the replacement text line
                         //gridline = gridline + "       <li id='links_li'><a href='../links/";
                         //gridline = gridline + fields[4] + "'>" + fields[2] + "</a></li>";
                         gridline = gridline + "       <li id='links_li'><a href='../code/link_specific.html?link=";
                         gridline = gridline + fields[5] + "'>" + fields[2] + "</a></li>";
                      }
                  }
                  // add the row closing to the replacement text line
                  gridline = gridline + "     </ul>   </td> </tr>";
              }
              // add the table closing to the replacement text line
              gridline = gridline + "</table>";
              // replace the "links_table" div's content with the replacement text line
              document.getElementById("links_table").innerHTML = gridline;
          }
       }
    }

//-------------------------------------------------------------------------------------------------------
// getMeetingList - load the aa_meetings.csv into the div, sorted alphabetically and then by District
//                - hot link to the first occurrance of a city with each letter of the alphabet
//-------------------------------------------------------------------------------------------------------
    function getMeetingList() 
    {
        var meetings = new Array();                       // holds the meetings
        var nummeetings = 0;                              // holds the number of meetings
        var matched = 0;                                  // holds results of comparison test
        var columnnumber = 0;                             // holds the number of columns added for the current line in the table
        var flag = 0;                                     // incidates if the current line in the array is the first occurrance
                                                          // of the starting letter in the meetings
        var letter = new Array();                         // array of the number of hotlink letters
        var letternames = "ABCDEFGHIJKLMNOPQRSTUVWXYX";   // array of the letters of the alphabet

        // add the table header to the replacement text line
        gridline = "<table align='center'>";
        if (window.XMLHttpRequest) 
        { 
           // reset the meetings array and its counter to empty
           meetings = new Array();             nummeetings = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //     0  |    1   |       2    |   3    |    4  | 5  |  6 
               //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
               var fields=lines[n].split("|"); 
               // add the appropriate information for the meeting to the meetings array
               //   CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
               meetings[nummeetings] = fields[5]+"|"+fields[1]+"|"+fields[2]+"|"+fields[3]+"|"+fields[4]+"|"+fields[6];
               // increment the number of meetings
               nummeetings = nummeetings + 1;
           }
           // now sort the meetings array alphabetically by city (fields[0] in the meetings line)
           // for each meeting in the meetings array except the last line
           for (var n = 0; n < nummeetings-1;n++)
           {
               // split the line into it components, using | as the delimiter
               //   0  |    1   |       2    |   3   |  4
               //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
               var fields=meetings[n].split("|"); 
               // for each meeting in the meetings array starting with the meeting below the above and
               // going to the end of the meetings array
               for (var z = n+1; z < nummeetings;z++)
               {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |       2    |   3   |  4
                  //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  var fieldsz=meetings[z].split("|"); 
                  // if the city (fields[0]) of the outside loop starts alphabetically later than the city (fieldsz[0]) of the inside loop
                  if (fields[0] > fieldsz[0])
                  {
                     // store the outside meetings line in a temporary variable
                     var temp = meetings[n];
                     // copy the inside meetings line into the outside meetings line
                     meetings[n] = meetings[z];
                     // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                     meetings[z] = temp;
                     // split the updated outside meeting line into it components, using | as the delimiter
                     //   0  |    1   |       2    |   3   |  4
                     //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                     var fields=meetings[n].split("|"); 
                  }
                  else
                  {
                    // if the city (fields[0]) of the outside loop starts the same alphabetically to the city (fieldsz[0]) of the inside loop
                     if (fields[0] == fieldsz[z])
                     {
                        // if the district number as integer (parseInt(fields[1])) of the outside loop is
                        // numerically greater than the district number as integer (parseInt(fieldsz[1])) of the inside loop is
                        if (parseInt(fields[1]) > parseInt(fieldsz[1]))
                        {
                            // store the outside meetings line in a temporary variable
                            var temp = meetings[n];
                            // copy the inside meetings line into the outside meetings line
                            meetings[n] = meetings[z];
                            // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                            meetings[z] = temp;
                            // split the updated outside meeting line into it components, using | as the delimiter
                            //   0  |    1   |       2    |   3   |  4
                            //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                            var fields=meetings[n].split("|"); 
                        }
                     }
                  }
               }
           }
           // add the table heading to the replacement text line
           gridline = gridline + "<table align='center'>";
           // reset number of columns added to current row in table to 0
           columnnumber = 0;
           // set all of the elements in the letters array to 0
           for (var n = 0; n < 26; n++){ letter[n] = 0;}
           // for each meeting line in the meetings array
           for (var n=0;n<nummeetings;n++)
           {
               // split the line into it components, using | as the delimiter
               //   0  |    1   |       2    |   3   |  4
               //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
               var fields=meetings[n].split("|");               
               // if the current column counter = 0, meaning the first column
               if (columnnumber == 0){
                     // add the row header to the replacement text line
                     gridline = gridline + " <tr>";
               }
               // add the current row's information as a list with no bullets to a column in the current row 
               // in the replacement text line
               //        (hotlinked if first occurrance of that starting letter of the city)
               //        meeting name                          fields[2] (bold)
               //        location                              fields[3] if not = "null"
               //        address                               fields[4] if not = "null"
               //        city                                  fields[5] (bold) 
               //        times                                 fields[6]
               gridline = gridline + "   <td valign='top'>";
               gridline = gridline + "     <ul>";
               gridline = gridline + "       <li id='meeting_name_li'";
               // reset the indicator of this meeting's city being the first occurrence of that starting letter in the meetings array
               flag = 0;
               // for each letter of the alphabet
               for (var k = 0; k < 26; k++)
               {
                   // get the current alphabet letter from the letternames 
                   var alphabet = letternames.charAt(k);      
                   // if the first letter of the City (fields[0].charAt(0)) = current alphabet letter AND
                   // the counter for that letter is 0
                   if (fields[0].charAt(0) == alphabet && letter[k] ==  0){ 
                        // add a hotlink for that letter of the alphabet to the replacement text line
                        gridline = gridline + "><a name='" + alphabet + "'>" + alphabet + "</a>"+fields[0].substr(1); 
                        // set the count for that letter to 1
                        letter[k] = 1; 
                        // set the indicator to 1 to indicate that a hotlink for that letter has been set
                        flag = 1;
                   }
               }
               // if the indicator = 1,  indicating that a city that starts with that letter have already been hotlinked
               if (flag == 0){
                     // add the meeting city to the replacement text line without the hotlink to that letter
                     gridline = gridline + ">" + fields[0];
               }
               gridline = gridline + "         <ul>";
               gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
               gridline = gridline + "District "+fields[1]+"<br><b>"+fields[2]+"</b><br>";
               if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
               if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
               gridline = gridline + fields[5]+"</li>";
               gridline = gridline + "         </ul>";
               gridline = gridline + "       </li>";
               gridline = gridline + "     </ul>";
               gridline = gridline + "   </td>";
               // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
               if (columnnumber == 2){
                   // reset the number of columns added to the current row in the table to 0
                   columnnumber = 0;
                   // add the row closing to the replacement text line
                   gridline = gridline + " </tr>";
               }
               // otherwise increment the number of columns added to the current row in the table
               else{columnnumber = columnnumber + 1;}
           }
           // if the number of columns added to the table = 0, add two empty columns to the current row in the table
           if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
           // if the number of columns added to the table = 1, add one empty columns to the current row in the table
           if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
           // add the table closing to the replacement text line
           gridline = gridline + "</table>";
           // replace the "meetings_table" div's content with the replacement text line
           document.getElementById("meetings_table").innerHTML = gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the meetings array and its counter to empty
           meetings = new Array();             nummeetings = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                  //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                  var fields=lines[n].split("|"); 
                  // add the appropriate information for the meeting to the meetings array
                  //   CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  meetings[nummeetings] = fields[5]+"|"+fields[1]+"|"+fields[2]+"|"+fields[3]+"|"+fields[4]+"|"+fields[6];
                  // increment the number of meetings
                  nummeetings = nummeetings + 1;
              }
              // now sort the meetings array alphabetically by city (fields[0] in the meetings line)
              // for each meeting in the meetings array except the last line
              for (var n = 0; n < nummeetings-1;n++)
              {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |       2    |   3   |  4
                  //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  var fields=meetings[n].split("|"); 
                  // for each meeting in the meetings array starting with the meeting below the above and
                  // going to the end of the meetings array
                  for (var z = n+1; z < nummeetings;z++)
                  {
                     // split the line into it components, using | as the delimiter
                     //   0  |    1   |       2    |   3   |  4
                     //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                     var fieldsz=meetings[z].split("|"); 
                     // if the city (fields[0]) of the outside loop starts alphabetically later than the city (fieldsz[0]) of the inside loop
                     if (fields[0] > fieldsz[0])
                     {
                        // store the outside meetings line in a temporary variable
                        var temp = meetings[n];
                        // copy the inside meetings line into the outside meetings line
                        meetings[n] = meetings[z];
                        // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                        meetings[z] = temp;
                        // split the updated outside meeting line into it components, using | as the delimiter
                        //   0  |    1   |       2    |   3   |  4
                        //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                        var fields=meetings[n].split("|"); 
                     }
                     else
                     {
                    // if the city (fields[0]) of the outside loop starts the same alphabetically to the city (fieldsz[0]) of the inside loop
                        if (fields[0] == fieldsz[z])
                        {
                           // if the district number as integer (parseInt(fields[1])) of the outside loop is
                           // numerically greater than the district number as integer (parseInt(fieldsz[1])) of the inside loop is
                           if (parseInt(fields[1]) > parseInt(fieldsz[1]))
                           {
                               // store the outside meetings line in a temporary variable
                               var temp = meetings[n];
                               // copy the inside meetings line into the outside meetings line
                               meetings[n] = meetings[z];
                               // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                               meetings[z] = temp;
                               // split the updated outside meeting line into it components, using | as the delimiter
                               //   0  |    1   |       2    |   3   |  4
                               //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                               var fields=meetings[n].split("|"); 
                           }
                        }
                     }
                  }
              }
              // add the table heading to the replacement text line
              gridline = gridline + "<table align='center'>";
              // reset number of columns added to current row in table to 0
              columnnumber = 0;
              // set all of the elements in the letters array to 0
              for (var n = 0; n < 26; n++){ letter[n] = 0;}
              // for each meeting line in the meetings array
              for (var n=0;n<nummeetings;n++)
              {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |       2    |   3   |  4
                  //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  var fields=meetings[n].split("|");               
                  // if the current column counter = 0, meaning the first column
                  if (columnnumber == 0){
                        // add the row header to the replacement text line
                        gridline = gridline + " <tr>";
                  }
                  // add the current row's information as a list with no bullets to a column in the current row 
                  // in the replacement text line
                  //        (hotlinked if first occurrance of that starting letter of the city)
                  //        meeting name                          fields[2] (bold)
                  //        location                              fields[3] if not = "null"
                  //        address                               fields[4] if not = "null"
                  //        city                                  fields[5] (bold) 
                  //        times                                 fields[6]
                  gridline = gridline + "   <td valign='top'>";
                  gridline = gridline + "     <ul>";
                  gridline = gridline + "       <li id='meeting_name_li'";
                  // reset the indicator of this meeting's city being the first occurrence of that starting letter in the meetings array
                  flag = 0;
                  // for each letter of the alphabet
                  for (var k = 0; k < 26; k++)
                  {
                      // get the current alphabet letter from the letternames 
                      var alphabet = letternames.charAt(k);      
                      // if the first letter of the City (fields[0].charAt(0)) = current alphabet letter AND
                      // the counter for that letter is 0
                      if (fields[0].charAt(0) == alphabet && letter[k] ==  0){ 
                           // add a hotlink for that letter of the alphabet to the replacement text line
                           gridline = gridline + "><a name='" + alphabet + "'>" + alphabet + "</a>"+fields[0].substr(1); 
                           // set the count for that letter to 1
                           letter[k] = 1; 
                           // set the indicator to 1 to indicate that a hotlink for that letter has been set
                           flag = 1;
                      }
                  }
                  // if the indicator = 1,  indicating that a city that starts with that letter have already been hotlinked
                  if (flag == 0){
                     // add the meeting city to the replacement text line without the hotlink to that letter
                     gridline = gridline + ">" + fields[0];
                  }
                  gridline = gridline + "         <ul>";
                  gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
                  gridline = gridline + "District "+fields[1]+"<br><b>"+fields[2]+"</b><br>";
                  if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
                  if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
                  gridline = gridline + fields[5]+"</li>";
                  gridline = gridline + "         </ul>";
                  gridline = gridline + "       </li>";
                  gridline = gridline + "     </ul>";
                  gridline = gridline + "   </td>";
                  // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
                  if (columnnumber == 2){
                      // reset the number of columns added to the current row in the table to 0
                      columnnumber = 0;
                      // add the row closing to the replacement text line
                      gridline = gridline + " </tr>";
                  }
                  // otherwise increment the number of columns added to the current row in the table
                  else{columnnumber = columnnumber + 1;}
              }
              // if the number of columns added to the table = 0, add two empty columns to the current row in the table
              if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
              // if the number of columns added to the table = 1, add one empty columns to the current row in the table
              if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
              // add the table closing to the replacement text line
              gridline = gridline + "</table>";
              // replace the "meetings_table" div's content with the replacement text line
              document.getElementById("meetings_table").innerHTML = gridline;
          }
       }
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------------------
// getTownsDays -  load the aa_meetings.csv 
//              -  build the town picklist from all of the towns in the aa_meetings.csv, sorted by town
//              -  return picklist and a picklist of all of the days of the week to calling function
//--------------------------------------------------------------------------------
    function getTownsDays()
    {
        var towns = new Array();                        // holds the towns
        var numtowns = 0;                                 // holds the number of towns
        var matched = 0;                                  // holds results of comparison test

        if (window.XMLHttpRequest) 
        { 
           // reset the towns array and its counter to empty
           towns = new Array();             numtowns = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //     0  |    1   |       2    |   3    |    4  | 5  |  6 
               //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
               var fields=lines[n].split("|"); 
               // set the comparison indicator to 0 for false
               matched = 0;
               // for each of the towns in the array
               for (var k=0;k<towns.length;k++){ 
                   // if the current line's town (fields[5]) = current town
                   if (fields[5] == towns[k]){
                       // set the indicator flag to 1 for true
                       matched = 1;
                   }
               }
               // if the indicator flag  = 0 for false
               if (matched == 0)
               {
                  // add the current town (fields[5]) to the towns array
                  towns[numtowns] = fields[5];
                  // increment the number of towns
                  numtowns = numtowns + 1;
               }
           }
           // now sort the towns array alphabetically
           // for each town in the towns array except the last line
           for (var n = 0; n < numtowns-1;n++)
           {
                // for each town in the towns array starting with the town below the above and
                // going to the end of the town array
                for (var z = n+1; z < numtowns;z++)
                {
                     // if the outside town is greater alphabetically than the inside town
                     if (towns[n] > towns[z])
                     {
                        // store the outside towns line in a temporary variable
                        var temp = towns[n];
                        // copy the inside towns line into the outside towns line
                        towns[n] = towns[z];
                        // copy the temporary variable, being the original outside towns line, into the inside towns line
                        towns[z] = temp;
                     }
                }
           }
           // add the pick list heading to the replacement text line
           gridline = "<center><table style='font-weight:bold;'><tr><td>Search By Town/City:</td><td><select id='picktown' onchange='showTown();'>";
           // for each town in the towns array
           for (var n = 0; n < numtowns; n++)
           { 
               // add the town to the pick list
               gridline = gridline + "<option value ='" + towns[n] + "' >" + towns[n] + "</option>";
           }
           // add the pick list ending to the replacement text line
           gridline = gridline + "</select></td></tr>";
           // add the days of the week pick list to the replacement text line
           gridline = gridline + "<tr><td>Search By Day:</td><td><select id='pickday' onchange='showDay();'>";
           gridline = gridline + "<option value ='Mon' >Mon</option>";
           gridline = gridline + "<option value ='Tue' >Tue</option>";
           gridline = gridline + "<option value ='Wed' >Wed</option>";
           gridline = gridline + "<option value ='Thu' >Thu</option>";
           gridline = gridline + "<option value ='Fri' >Fri</option>";
           gridline = gridline + "<option value ='Sat' >Sat</option>";
           gridline = gridline + "<option value ='Sun' >Sun</option>";
           gridline = gridline + "</select></td></tr></table></center>";
           // replace the "meetings_table" div's content with the replacement text line
           document.getElementById("meetings_table").innerHTML = gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the towns array and its counter to empty
           towns = new Array();             numtowns = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                  //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                  var fields=lines[n].split("|"); 
                  // set the comparison indicator to 0 for false
                  matched = 0;
                  // for each of the towns in the array
                  for (var k=0;k<towns.length;k++){ 
                      // if the current line's town (fields[5]) = current town
                      if (fields[5] == towns[k]){
                          // set the indicator flag to 1 for true
                          matched = 1;
                      }
                  }
                  // if the indicator flag  = 0 for false
                  if (matched == 0)
                  {
                     // add the current town (fields[5]) to the towns array
                     towns[numtowns] = fields[5];
                     // increment the number of towns
                     numtowns = numtowns + 1;
                  }
              }
              // now sort the towns array alphabetically
              // for each town in the towns array except the last line
              for (var n = 0; n < numtowns-1;n++)
              {
                   // for each town in the towns array starting with the town below the above and
                   // going to the end of the town array
                   for (var z = n+1; z < numtowns;z++)
                   {
                        // if the outside town is greater alphabetically than the inside town
                        if (towns[n] > towns[z])
                        {
                           // store the outside towns line in a temporary variable
                           var temp = towns[n];
                           // copy the inside towns line into the outside towns line
                           towns[n] = towns[z];
                           // copy the temporary variable, being the original outside towns line, into the inside towns line
                           towns[z] = temp;
                        }
                   }
              }
              // add the pick list heading to the replacement text line
              gridline = "<center><table style='font-weight:bold;'><tr><td>Search By Town/City:</td>";
              gridline = gridline + "<td><select id='picktown' onchange='showTown();'>";
              // for each town in the towns array
              for (var n = 0; n < numtowns; n++)
              { 
                  // add the town to the pick list
                  gridline = gridline + "<option value ='" + towns[n] + "' >" + towns[n] + "</option>";
              }
              // add the pick list ending to the replacement text line
              gridline = gridline + "</select></td></tr>";
              // add the days of the week pick list to the replacement text line
              gridline = gridline + "<tr><td>Search By Day:</td><td><select id='pickday' onchange='showDay();'>";
              gridline = gridline + "<option value ='Mon' >Mon</option>";
              gridline = gridline + "<option value ='Tue' >Tue</option>";
              gridline = gridline + "<option value ='Wed' >Wed</option>";
              gridline = gridline + "<option value ='Thu' >Thu</option>";
              gridline = gridline + "<option value ='Fri' >Fri</option>";
              gridline = gridline + "<option value ='Sat' >Sat</option>";
              gridline = gridline + "<option value ='Sun' >Sun</option>";
              gridline = gridline + "</select></td></tr></table></center>";
              // replace the "meetings_table" div's content with the replacement text line
              document.getElementById("meetings_table").innerHTML = gridline;
          }
       }
    }

//--------------------------------------------------------------------------------
// getInfoTown - call getMeetingsTown to get all of the meetings for the passed town
//             - replace the "meetings_table" with the returned value from above
//             - update the "headingtxt" with the heading for the passed town
//--------------------------------------------------------------------------------
    function getTownInfo(town) 
    {
        var info = "";                          // holds the return value from getMeetingsTown(town);

        // call getMeetingsTown(town) to get all of the meetings for town
        info = getMeetingsTown(town);           
        // replace the "meetings_table" div's content with the results from getMeetingsTown(town);                
        document.getElementById("meetings_table").innerHTML = info;
        // set the "headingtxt" to the show the name of the passed town
        document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR " + town.toUpperCase() + "</h1>";
    }

//----------------------------------------------------------------------------------------------------
// getMeetingListTown(town) - load the aa_meetings.csv into the div, for the passed town, sorted by District
//----------------------------------------------------------------------------------------------------
    function getMeetingsTown(town) 
    {
        var meetings = new Array();                       // holds the meetings
        var nummeetings = 0;                              // holds the number of meetings
        var matched = 0;                                  // holds results of comparison test
        var columnnumber = 0;                             // holds the number of columns added for the current line in the table

        // add the table header to the replacement text line
        gridline = "<table align='center'>";
        if (window.XMLHttpRequest) 
        { 
           // reset the meetings array and its counter to empty
           meetings = new Array();             nummeetings = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //     0  |    1   |       2    |   3    |    4  | 5  |  6 
               //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
               var fields=lines[n].split("|"); 
               // if the current line's town (fields[5]) = passed town
               if (fields[5] == town)
               {
                  // add the line for the meeting to the meetings array
                  meetings[nummeetings] = lines[n];
                  // increment the number of meetings
                  nummeetings = nummeetings + 1;
               }
           }
           // if the number of meetings > 0
           if (nummeetings > 0)
           {
              // add the table heading to the replacement text line
              gridline = gridline + "<table align='center'>";
              // reset number of columns added to current row in table to 0
              columnnumber = 0;
              // for each meeting line in the meetings array
              for (var n=0;n<nummeetings;n++)
              {
                  // split the line into it components, using | as the delimiter
                  //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                  //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                  var fields=meetings[n].split("|");               
                  // if the current column counter = 0, meaning the first column
                  if (columnnumber == 0){
                        // add the row header to the replacement text line
                        gridline = gridline + " <tr>";
                  }
                  // add the current row's information as a list with no bullets to a column in the current row 
                  // in the replacement text line
                  //        meeting name                          fields[2] (bold)
                  //        location                              fields[3] if not = "null"
                  //        address                               fields[4] if not = "null"
                  //        city                                  fields[5] (bold) 
                  //        times                                 fields[6]
                   gridline = gridline + "   <td>";
                   gridline = gridline + "     <ul>";
                   gridline = gridline + "       <li id='meeting_name_li'>"+fields[2];
                   gridline = gridline + "         <ul>";
                   gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
                   if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
                   if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
                   gridline = gridline + "<b>"+fields[5]+"</b><br><b>"+fields[6]+"</li>";
                   gridline = gridline + "         </ul>";
                   gridline = gridline + "       </li>";
                   gridline = gridline + "     </ul>";
                   gridline = gridline + "   </td>";
                   // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
                   if (columnnumber == 2){
                       // reset the number of columns added to the current row in the table to 0
                       columnnumber = 0;
                       // add the row closing to the replacement text line
                       gridline = gridline + " </tr>";
                   }
                   // otherwise increment the number of columns added to the current row in the table
                   else{columnnumber = columnnumber + 1;}
               }
               // if the number of columns added to the table = 0, add two empty columns to the current row in the table
               if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
               // if the number of columns added to the table = 1, add one empty columns to the current row in the table
               if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
               // add the table closing to the replacement text line
               gridline = gridline + "</table>";
           }
           // return the replacement line to the calling function
           return gridline;
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the towns array and its counter to empty
           towns = new Array();             numtowns = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                  //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                  var fields=lines[n].split("|"); 
                  // if the current line's town (fields[5]) = passed town
                  if (fields[5] == town)
                  {
                     // add the line for the meeting to the meetings array
                     meetings[nummeetings] = lines[n];
                     // increment the number of meetings
                     nummeetings = nummeetings + 1;
                  }
              }
              // if the number of meetings > 0
              if (nummeetings > 0)
              {
                 // add the table heading to the replacement text line
                 gridline = gridline + "<table align='center'>";
                 // reset number of columns added to current row in table to 0
                 columnnumber = 0;
                 // for each meeting line in the meetings array
                 for (var n=0;n<nummeetings;n++)
                 {
                     // split the line into it components, using | as the delimiter
                     //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                     //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                     var fields=meetings[n].split("|");               
                     // if the current column counter = 0, meaning the first column
                     if (columnnumber == 0){
                           // add the row header to the replacement text line
                           gridline = gridline + " <tr>";
                     }
                     // add the current row's information as a list with no bullets to a column in the current row 
                     // in the replacement text line
                     //        meeting name                          fields[2] (bold)
                     //        location                              fields[3] if not = "null"
                     //        address                               fields[4] if not = "null"
                     //        city                                  fields[5] (bold) 
                     //        times                                 fields[6]
                     gridline = gridline + "   <td>";
                     gridline = gridline + "     <ul>";
                     gridline = gridline + "       <li id='meeting_name_li'>"+fields[2];
                     gridline = gridline + "         <ul>";
                     gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
                     if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
                     if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
                     gridline = gridline + "<b>"+fields[5]+"</b><br><b>"+fields[6]+"</li>";
                     gridline = gridline + "         </ul>";
                     gridline = gridline + "       </li>";
                     gridline = gridline + "     </ul>";
                     gridline = gridline + "   </td>";
                     // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
                     if (columnnumber == 2){
                         // reset the number of columns added to the current row in the table to 0
                         columnnumber = 0;
                         // add the row closing to the replacement text line
                         gridline = gridline + " </tr>";
                     }
                     // otherwise increment the number of columns added to the current row in the table
                     else{columnnumber = columnnumber + 1;}
                  }
                  // if the number of columns added to the table = 0, add two empty columns to the current row in the table
                  if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
                  // if the number of columns added to the table = 1, add one empty columns to the current row in the table
                  if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
                  // add the table closing to the replacement text line
                  gridline = gridline + "</table>";
              }
              // return the replacement line to the calling function
              return gridline;
          }
       }
    }

//--------------------------------------------------------------------------------
// getMeetingListDay(day) - load the aa_meetings.csv into the div for the passed day, sorted alphabetically and then by District
//                        - hot link to the first occurrance of a city with each letter of the alphabet
//--------------------------------------------------------------------------------
    function getMeetingListDay(day) 
    {
        var meetings = new Array();                       // holds the meetings
        var nummeetings = 0;                              // holds the number of meetings
        var matched = 0;                                  // holds results of comparison test
        var columnnumber = 0;                             // holds the number of columns added for the current line in the table
        var flag = 0;                                     // incidates if the current line in the array is the first occurrance
                                                          // of the starting letter in the meetings
        var letter = new Array();                         // array of the number of hotlink letters
        var letternames = "ABCDEFGHIJKLMNOPQRSTUVWXYX";   // array of the letters of the alphabet

        // add the table header to the replacement text line
        gridline = "<table align='center'>";
        if (window.XMLHttpRequest) 
        { 
           // reset the meetings array and its counter to empty
           meetings = new Array();             nummeetings = 0;
           // reset the current lines array and its counter to empty
           current_lines = new Array();           numcurrent = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //     0  |    1   |       2    |   3    |    4  | 5  |  6 
               //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
               var fields=lines[n].split("|"); 
               // set the comparison flag to 0 for false
               matched = 0;
               // starting with the beginning of times (fields[6]) and going to the last 3 characters
               //    if the current 3 characters of times (fields[6].substring(k,k+3)) = passed day
               for (var k=0;k<fields[6].length;k++){ 
                   // if the current 3 characters of times (fields[6].substring(k,k+3)) = passed day
                   if (fields[6].substring(k,k+3) == day){
                      // set the comparison flag to 1 for true
                      matched = 1;
                   }
               }
               // if the comparison flag = 1 for true
               if (matched == 1)
               {
                   // add the appropriate information for the meeting to the meetings array
                   //   CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                   meetings[nummeetings] = fields[5]+"|"+fields[1]+"|"+fields[2]+"|"+fields[3]+"|"+fields[4]+"|"+fields[6];
                   // increment the number of meetings
                   nummeetings = nummeetings + 1;
               }
           }
           // now sort the meetings array alphabetically by city (fields[0] in the meetings line)
           // for each meeting in the meetings array except the last line
           for (var n = 0; n < nummeetings-1;n++)
           {
               // split the line into it components, using | as the delimiter
               //   0  |    1   |       2    |   3   |  4
               //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
               var fields=meetings[n].split("|"); 
               // for each meeting in the meetings array starting with the meeting below the above and
               // going to the end of the meetings array
               for (var z = n+1; z < nummeetings;z++)
               {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |       2    |   3   |  4
                  //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  var fieldsz=meetings[z].split("|"); 
                  // if the city (fields[0]) of the outside loop starts alphabetically later than the city (fieldsz[0]) of the inside loop
                  if (fields[0] > fieldsz[0])
                  {
                     // store the outside meetings line in a temporary variable
                     var temp = meetings[n];
                     // copy the inside meetings line into the outside meetings line
                     meetings[n] = meetings[z];
                     // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                     meetings[z] = temp;
                     // split the updated outside meeting line into it components, using | as the delimiter
                     //   0  |    1   |       2    |   3   |  4
                     //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                     var fields=meetings[n].split("|"); 
                  }
                  else
                  {
                    // if the city (fields[0]) of the outside loop starts the same alphabetically to the city (fieldsz[0]) of the inside loop
                     if (fields[0] == fieldsz[z])
                     {
                        // if the district number as integer (parseInt(fields[1])) of the outside loop is
                        // numerically greater than the district number as integer (parseInt(fieldsz[1])) of the inside loop is
                        if (parseInt(fields[1]) > parseInt(fieldsz[1]))
                        {
                            // store the outside meetings line in a temporary variable
                            var temp = meetings[n];
                            // copy the inside meetings line into the outside meetings line
                            meetings[n] = meetings[z];
                            // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                            meetings[z] = temp;
                            // split the updated outside meeting line into it components, using | as the delimiter
                            //   0  |    1   |       2    |   3   |  4
                            //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                            var fields=meetings[n].split("|"); 
                        }
                     }
                  }
               }
           }
           // add the table heading to the replacement text line
           gridline = gridline + "<table align='center'>";
           // reset number of columns added to current row in table to 0
           columnnumber = 0;
           // set all of the elements in the letters array to 0
           for (var n = 0; n < 26; n++){ letter[n] = 0;}
           // for each meeting line in the meetings array
           for (var n=0;n<nummeetings;n++)
           {
               // split the line into it components, using | as the delimiter
               //   0  |    1   |       2    |   3   |  4
               //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
               var fields=meetings[n].split("|");               
               // if the current column counter = 0, meaning the first column
               if (columnnumber == 0){
                     // add the row header to the replacement text line
                     gridline = gridline + " <tr>";
               }
               // add the current row's information as a list with no bullets to a column in the current row 
               // in the replacement text line
               //        (hotlinked if first occurrance of that starting letter of the city)
               //        meeting name                          fields[2] (bold)
               //        location                              fields[3] if not = "null"
               //        address                               fields[4] if not = "null"
               //        city                                  fields[5] (bold) 
               //        times                                 fields[6]
               gridline = gridline + "   <td valign='top'>";
               gridline = gridline + "     <ul>";
               gridline = gridline + "       <li id='meeting_name_li'";
               // reset the indicator of this meeting's city being the first occurrence of that starting letter in the meetings array
               flag = 0;
               // for each letter of the alphabet
               for (var k = 0; k < 26; k++)
               {
                   // get the current alphabet letter from the letternames 
                   var alphabet = letternames.charAt(k);      
                   // if the first letter of the City (fields[0].charAt(0)) = current alphabet letter AND
                   // the counter for that letter is 0
                   if (fields[0].charAt(0) == alphabet && letter[k] ==  0){ 
                        // add a hotlink for that letter of the alphabet to the replacement text line
                        gridline = gridline + "><a name='" + alphabet + "'>" + alphabet + "</a>"+fields[0].substr(1); 
                        // set the count for that letter to 1
                        letter[k] = 1; 
                        // set the indicator to 1 to indicate that a hotlink for that letter has been set
                        flag = 1;
                   }
               }
               // if the indicator = 1,  indicating that a city that starts with that letter have already been hotlinked
               if (flag == 0){
                     // add the meeting city to the replacement text line without the hotlink to that letter
                     gridline = gridline + ">" + fields[0];
               }
               gridline = gridline + "         <ul>";
               gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
               gridline = gridline + "District "+fields[1]+"<br><b>"+fields[2]+"</b><br>";
               if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
               if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
               gridline = gridline + fields[5]+"</li>";
               gridline = gridline + "         </ul>";
               gridline = gridline + "       </li>";
               gridline = gridline + "     </ul>";
               gridline = gridline + "   </td>";
               // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
               if (columnnumber == 2){
                   // reset the number of columns added to the current row in the table to 0
                   columnnumber = 0;
                   // add the row closing to the replacement text line
                   gridline = gridline + " </tr>";
               }
               // otherwise increment the number of columns added to the current row in the table
               else{columnnumber = columnnumber + 1;}
           }
           // if the number of columns added to the table = 0, add two empty columns to the current row in the table
           if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
           // if the number of columns added to the table = 1, add one empty columns to the current row in the table
           if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
           // add the table closing to the replacement text line
           gridline = gridline + "</table>";
           // replace the "meetings_table" div's content with the replacement text line
           document.getElementById("meetings_table").innerHTML = gridline;
           // set the "headingtxt" to the passed day of the week
           if (day == "Mon"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR MONDAY</h1>";}
           if (day == "Tue"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR TUESDAY</h1>";}
           if (day == "Wed"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR WEDNESDAY</h1>";}
           if (day == "Thu"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR THURSDAY</h1>";}
           if (day == "Fri"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR FRIDAY</h1>";}
           if (day == "Sat"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR SATURDAY</h1>";}
           if (day == "Sun"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR SUNDAY</h1>";}
        } 
        else if (window.ActiveXObject) 
        { 
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // reset the meetings array and its counter to empty
              meetings = new Array();             nummeetings = 0;
              // reset the current lines array and its counter to empty
              current_lines = new Array();           numcurrent = 0;
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/aa_meetings.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //     0  |    1   |       2    |   3    |    4  | 5  |  6 
                  //  IGNORE|DISTRICT|MEETING_NAME|LOCATION|ADDRESS|CITY|TIMES#
                  var fields=lines[n].split("|"); 
                  // set the comparison flag to 0 for false
                  matched = 0;
                  // starting with the beginning of times (fields[6]) and going to the last 3 characters
                  //    if the current 3 characters of times (fields[6].substring(k,k+3)) = passed day
                  for (var k=0;k<fields[6].length;k++){ 
                      // if the current 3 characters of times (fields[6].substring(k,k+3)) = passed day
                      if (fields[6].substring(k,k+3) == day){
                         // set the comparison flag to 1 for true
                        matched = 1;
                      }
                  }
                  // if the comparison flag = 1 for true
                  if (matched == 1)
                  {
                      // add the appropriate information for the meeting to the meetings array
                      //   CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                      meetings[nummeetings] = fields[5]+"|"+fields[1]+"|"+fields[2]+"|"+fields[3]+"|"+fields[4]+"|"+fields[6];
                      // increment the number of meetings
                      nummeetings = nummeetings + 1;
                  }
              }
              // now sort the meetings array alphabetically by city (fields[0] in the meetings line)
              // for each meeting in the meetings array except the last line
              for (var n = 0; n < nummeetings-1;n++)
              {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |       2    |   3   |  4
                  //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  var fields=meetings[n].split("|"); 
                  // for each meeting in the meetings array starting with the meeting below the above and
                  // going to the end of the meetings array
                  for (var z = n+1; z < nummeetings;z++)
                  {
                     // split the line into it components, using | as the delimiter
                     //   0  |    1   |       2    |   3   |  4
                     //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                     var fieldsz=meetings[z].split("|"); 
                     // if the city (fields[0]) of the outside loop starts alphabetically later than the city (fieldsz[0]) of the inside loop
                     if (fields[0] > fieldsz[0])
                     {
                        // store the outside meetings line in a temporary variable
                        var temp = meetings[n];
                        // copy the inside meetings line into the outside meetings line
                        meetings[n] = meetings[z];
                        // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                        meetings[z] = temp;
                        // split the updated outside meeting line into it components, using | as the delimiter
                        //   0  |    1   |       2    |   3   |  4
                        //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                        var fields=meetings[n].split("|"); 
                     }
                     else
                     {
                   // if the city (fields[0]) of the outside loop starts the same alphabetically to the city (fieldsz[0]) of the inside loop
                        if (fields[0] == fieldsz[z])
                        {
                           // if the district number as integer (parseInt(fields[1])) of the outside loop is
                           // numerically greater than the district number as integer (parseInt(fieldsz[1])) of the inside loop is
                           if (parseInt(fields[1]) > parseInt(fieldsz[1]))
                           {
                               // store the outside meetings line in a temporary variable
                               var temp = meetings[n];
                               // copy the inside meetings line into the outside meetings line
                               meetings[n] = meetings[z];
                               // copy the temporary variable, being the original outside meetings line, into the inside meeting line
                               meetings[z] = temp;
                               // split the updated outside meeting line into it components, using | as the delimiter
                               //   0  |    1   |       2    |   3   |  4
                               //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                               var fields=meetings[n].split("|"); 
                           }
                        }
                     }
                  }
              }
              // add the table heading to the replacement text line
              gridline = gridline + "<table align='center'>";
              // reset number of columns added to current row in table to 0
              columnnumber = 0;
              // set all of the elements in the letters array to 0
              for (var n = 0; n < 26; n++){ letter[n] = 0;}
              // for each meeting line in the meetings array
              for (var n=0;n<nummeetings;n++)
              {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |       2    |   3   |  4
                  //  CITY|DISTRICT|MEETING_NAME|ADDRESS|TIMES
                  var fields=meetings[n].split("|");               
                  // if the current column counter = 0, meaning the first column
                  if (columnnumber == 0){
                        // add the row header to the replacement text line
                        gridline = gridline + " <tr>";
                  }
                  // add the current row's information as a list with no bullets to a column in the current row 
                  // in the replacement text line
                  //        (hotlinked if first occurrance of that starting letter of the city)
                  //        meeting name                          fields[2] (bold)
                  //        location                              fields[3] if not = "null"
                  //        address                               fields[4] if not = "null"
                  //        city                                  fields[5] (bold) 
                  //        times                                 fields[6]
                  gridline = gridline + "   <td valign='top'>";
                  gridline = gridline + "     <ul>";
                  gridline = gridline + "       <li id='meeting_name_li'";
                  // reset the indicator of this meeting's city being the first occurrence of that starting letter in the meetings array
                  flag = 0;
                  // for each letter of the alphabet
                  for (var k = 0; k < 26; k++)
                  {
                      // get the current alphabet letter from the letternames 
                      var alphabet = letternames.charAt(k);      
                      // if the first letter of the City (fields[0].charAt(0)) = current alphabet letter AND
                      // the counter for that letter is 0
                      if (fields[0].charAt(0) == alphabet && letter[k] ==  0){ 
                           // add a hotlink for that letter of the alphabet to the replacement text line
                           gridline = gridline + "><a name='" + alphabet + "'>" + alphabet + "</a>"+fields[0].substr(1); 
                           // set the count for that letter to 1
                           letter[k] = 1; 
                           // set the indicator to 1 to indicate that a hotlink for that letter has been set
                           flag = 1;
                      }
                  }
                  // if the indicator = 1,  indicating that a city that starts with that letter have already been hotlinked
                  if (flag == 0){
                        // add the meeting city to the replacement text line without the hotlink to that letter
                        gridline = gridline + ">" + fields[0];
                  }
                  gridline = gridline + "         <ul>";
                  gridline = gridline + "           <li id='meeting_info_li'><nostyle>";
                  gridline = gridline + "District "+fields[1]+"<br><b>"+fields[2]+"</b><br>";
                  if (fields[3] == "null"){}else{gridline = gridline+fields[3]+"<br>";}
                  if (fields[4] == "null"){}else{gridline = gridline+fields[4]+"<br>";}
                  gridline = gridline + fields[5]+"</li>";
                  gridline = gridline + "         </ul>";
                  gridline = gridline + "       </li>";
                  gridline = gridline + "     </ul>";
                  gridline = gridline + "   </td>";
                  // if the number of columns added = 2, meaning three columns have been added to the current row in the table 
                  if (columnnumber == 2){
                      // reset the number of columns added to the current row in the table to 0
                      columnnumber = 0;
                      // add the row closing to the replacement text line
                      gridline = gridline + " </tr>";
                  }
                  // otherwise increment the number of columns added to the current row in the table
                  else{columnnumber = columnnumber + 1;}
              }
              // if the number of columns added to the table = 0, add two empty columns to the current row in the table
              if (columnnumber == 0){gridline = gridline+"<td>&nbsp;</td><td>&nbsp;</td></tr>";}
              // if the number of columns added to the table = 1, add one empty columns to the current row in the table
              if (columnnumber == 1){gridline = gridline+"<td>&nbsp;</td></tr>";}
              // add the table closing to the replacement text line
              gridline = gridline + "</table>";
              // replace the "meetings_table" div's content with the replacement text line
              document.getElementById("meetings_table").innerHTML = gridline;
              // set the "headingtxt" to the passed day of the week
              if (day == "Mon"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR MONDAY</h1>";}
              if (day == "Tue"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR TUESDAY</h1>";}
             if (day == "Wed"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR WEDNESDAY</h1>";}
              if (day == "Thu"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR THURSDAY</h1>";}
              if (day == "Fri"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR FRIDAY</h1>";}
              if (day == "Sat"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR SATURDAY</h1>";}
              if (day == "Sun"){document.getElementById("headingtxt").innerHTML = "<h1 id='allcaps'>AREA 91 MEETING LIST FOR SUNDAY</h1>";}
          }
       }
    }


//--------------------------------------------------------------------------------
// getFooter - returns a string containing the footer navigation bar for the bottom
//             of the page
//--------------------------------------------------------------------------------
   function getFooter()
   {
       var returnline = '';                 // holds the string to be returned to the calling function

       // note - this is where any changes to bmp's and the .html's is edited
       returnline = returnline + '<hr size=4 />';
       returnline = returnline + '<center>';
       returnline = returnline + '<a href="../index.html"><img src="../images/trial_home.bmp" alt="home" border="none"></a>';
       returnline = returnline + '<a href="../districts/district.html"><img src="../images/trial_districts.bmp" alt="district" border="none"></a>';
       returnline = returnline + '<a href="../districts/search.html"><img src="../images/trial_search.bmp" alt="search" border="none"></a>';
       returnline = returnline + '<a href="../districts/meetings.html"><img src="../images/trial_meetings.bmp" alt="alpha" border="none"></a>';
       returnline = returnline + '<a href="../committees/committees.html"><img src="../images/trial_committees.bmp" alt="committees" border="none"></a>';
       returnline = returnline + '<a href="../special_events/roundup.html"><img src="../images/trial_roundups.bmp" alt="roundup" border="none"></a>'; 
       returnline = returnline + '<a href="../special_events/special.html"><img src="../images/trial_events.bmp" alt="special" border="none"</a>';
       returnline = returnline + '<a href="../contact/contact.html"><img src="../images/trial_contacts.bmp" alt="contact" border="none"</a>';
       returnline = returnline + '<a href="../code/links.html"><img src="../images/trial_links.bmp" alt="links" border="none"</a>';
       returnline = returnline + '</center>';
       returnline = returnline + '<hr size=4 />';
       returnline = returnline + '<center><img src="../images/camel_walking.gif" border="none"/></center>';
       returnline = returnline + '<BR><BR>';
       returnline = returnline + '<center>http://www.aasask.org<br /><a href=mailto:webservant@aasask.org>contact the web servant</a></center>';
       returnline = returnline + '<br />';

       // return the results to the calling function
       return returnline;
   }

//--------------------------------------------------------------------------------
// getDistrictHeading - get the heading information for the passed district 
//                      from district_headings.csv
//--------------------------------------------------------------------------------
    function getDistrictHeading(district) 
    {
        var returnline = '';                           // holds the heading to be returned
        var matched = 0;                               // holds results of comparison test

        if (window.XMLHttpRequest) 
        { 
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/district_headings.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // split the line into it components, using | as the delimiter
               //   0  |    1   |     2 
               //IGNORE|DISTRICT|INFORMATION#
               var fields=lines[n].split("|"); 
               // if the district (fields[1]) is the same as the passed in district (districtpassed)
               if (fields[1] == district)
               {
                   // store the heading tags and the information (fields[2]) in the returnline
                   returnline = "<h3 id='locations2'>" + fields[2] + "</h3><hr size=4 />";
               }
           }
           // return the stored information to the calling function
           return returnline;
        } 
        else if (window.ActiveXObject) 
        { 
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/district_headings.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // split the line into it components, using | as the delimiter
                  //   0  |    1   |     2 
                  //IGNORE|DISTRICT|INFORMATION#
                  var fields=lines[n].split("|"); 
                  // if the district (fields[1]) is the same as the passed in district (districtpassed)
                  if (fields[1] == district)
                  {
                      // store the heading tags and the information (fields[2]) in the returnline
                      returnline = "<h3 id='locations2'>" + fields[2] + "</h3><hr size=4 />";
                  }
              }
              // return the stored information to the calling function
              return returnline;
          }
       }
    }

//--------------------------------------------------------------------------------
// getLinksArray - load the links.csv into the links_all array
//--------------------------------------------------------------------------------
    function getLinksArray() 
    {
        links_all = new Array();                       // holds the links
        var numlinks = 0;                              // holds the number of links

        if (window.XMLHttpRequest) 
        { 
           // reset the links array and its counter to empty
           links = new Array();             numlinks = 0;
           // code for Mozilla, Safari, etc 
           var xmlhttp = new XMLHttpRequest();
           // set the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.open('GET', '../xmls/links.csv', false);
           // invoke the XMLHttpRequest to get the contents of the .csv file
           xmlhttp.send(null);
           // store the bulk returned contents as a string
           var csv = xmlhttp.responseText;
           // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
           var lines=csv.split("#"); 
           //for each line in the lines array, staring with line 1 to ignore the header line
           for(var n=1;n<lines.length-1;n++) 
           {
               // add the line to the links_all array
               links_all[numlinks] = lines[n];
               // increment the number of lines in the lines_all array
               numlinks = numlinks + 1;
           }
        } 
        else if (window.ActiveXObject) 
        { 
           // reset the links array and its counter to empty
           links = new Array();             numlinks = 0;
           //IE 
           xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
           if (xmlhttp) 
           {
              // set the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.open('GET', '../xmls/links.csv', false);
              // invoke the XMLHttpRequest to get the contents of the .csv file
              xmlhttp.send();
              // store the bulk returned contents as a string
              var csv = xmlhttp.responseText;
              // split the bulk returned contents into lines using # as the delimiter and store in the lines array     
              var lines=csv.split("#"); 
              //for each line in the lines array, staring with line 1 to ignore the header line
              for(var n=1;n<lines.length-1;n++) 
              {
                  // add the line to the links_all array
                  links_all[numlinks] = lines[n];
                  // increment the number of lines in the lines_all array
                  numlinks = numlinks + 1;
              }
          }
       }
    }


                    