function autoNav()
{
  // order layout of navigation links in HTML table cells
  // first by column left to right, then rows top to bottom
  // array elements: filename, image name root, ALT text
  // use ("BLANK","","") for empty cells
  
  var arNav = new Array ( 
                         // row 1
                         new Array('Default.asp','home','Home'),
                         new Array('Membership.asp','membership','Membership'),
                         new Array('Events.asp','events','Events'),
                         new Array('MessageList.asp','messageboard','Message Board'),
                         // row 2
                         new Array('AboutUs.asp','about','About Us'),
                         new Array('Bulletin.asp','bulletin','Bulletin'),
                         new Array('Tips.asp','tips','Tips'),
			 new Array('http://www.spgfestival.com','spg','SPG')
			 //new Array('https://sites.google.com/site/spgfestival/','spg','SPG')
                         // row 3, for subsection pages
                         //new Array("
                        );
                         
  
//  printLinks(arPage, arImg);
  printLinks(arNav);
}

// function to construct navigation links table
function printLinks(linkList) 
{

  // the name of the page we're on
  var fileName = 
      location.pathname.substring(location.pathname.lastIndexOf('/') + 1);
  
  // local constants
  var IMG_ROOT    = 'images/nav_';
  var IMG_ON      = '_F2';
  var IMG_EXT     = '.gif';
  var IMG_H       = 24;
  var IMG_W       = 175;
  var FIELD_ONE   = 0;
  var FIELD_TWO   = 1;
  var FIELD_THREE = 2;
  var FIELD_FOUR  = 3;
  var NUM_COLS    = 4;
  
  var rowCount, colCount = 0;
  
  // start writing the table...
  document.write('<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">' +
                 '<TR><TD COLSPAN="' + NUM_COLS + '"><IMG SRC="images/spacer.gif" ' + 
                 'WIDTH="175" HEIGHT="8"></TD></TR>');
  //                  
  // loop through list of navigation links...
  for(listItem in linkList) 
  {
    var linkName = linkList[listItem][FIELD_ONE];
    var sectID   = linkList[listItem][FIELD_TWO];
    var altText  = linkList[listItem][FIELD_THREE];
    
    // only write TR at the start of the row
    if(colCount%NUM_COLS == 0)
      document.write("<TR>");
    document.write("<TD>");
    
    // if there is no link graphic for this cell, leave it blank
    if(linkName == "BLANK")
      document.write("&nbsp;");
    // if we're on a section subpage, make the image bold & clickable
    else if((sectMember == sectID) && (fileName != linkName)) 
    {
      document.write('<A HREF="' + linkName + '"><IMG NAME="' + sectID + 
                         '" SRC="' + IMG_ROOT + sectID + 
                         IMG_ON + IMG_EXT + 
                         '" WIDTH="' + IMG_W + '" HEIGHT="' + IMG_H + 
                         '" BORDER="0"' +
                         ' ALT="' + altText + '"></A>');
    } 
    // if we're on the section main page, make the image bold but not clickable
    else if(fileName == linkName) 
    {
      document.write('<IMG NAME="' + sectID + 
                         '" SRC="' + IMG_ROOT + sectID + 
                         IMG_ON + IMG_EXT + 
                         '" WIDTH="' + IMG_W + '" HEIGHT="' + IMG_H + 
                         '" BORDER="0"' +
                         ' ALT="' + altText + '">');
    } 
    // otherwise, just make it clickable with rollover highlighting
    else 
    {
      document.write('<A HREF="' + linkName + '" ' +
                         'onMouseOut="di20(\'' + sectID + '\',\'' + 
                         IMG_ROOT + sectID + IMG_EXT + '\');" ' +
                         'onMouseOver="di20(\'' + sectID + '\',\'' + 
                         IMG_ROOT + sectID + IMG_ON + IMG_EXT + 
                         '\');"><IMG NAME="' + sectID + 
                         '" SRC="' + IMG_ROOT + sectID + IMG_EXT +                          
                         '" WIDTH="' + IMG_W + '" HEIGHT="' + IMG_H + '" BORDER="0"' + 
                         ' ALT="' + altText + '"></A>');
    }
    document.write('</TD>');
    colCount++;
    
    // only write TR at the end of the row
    if(colCount%NUM_COLS == 0)
      document.write('</TR>');
  }
  document.write('</TABLE>');
}

// generate the navigation links table
autoNav();

