var contactsPage    = 'contacts';
var documentsPage   = 'documents';
var facilitiesPage  = 'facilities';
var homePage        = 'home';
var linksPage       = 'links';
var locationsPage   = 'locations';
var membersPage     = 'members';
var newsPage        = 'news';
var newslettersPage = 'newsletters';
var photosPage      = 'photos';
var schedulePage    = 'schedule';
var tracksPage      = 'tracks';

var otherEvent  = 0;
var otherEvents = new Array();
otherEvents[otherEvent++] = 
   new objectOtherEvent("2010","7/10","US-TN-CSME","Card Order");
otherEvents[otherEvent++] = 
   new objectOtherEvent("2010","9/25","US-TN-MSLS","Fall Run");
otherEvents[otherEvent++] = 
   new objectOtherEvent("2010","10/9 - 10/10","US-TN-CSME","Card Order");
otherEvents[otherEvent++] = 
   new objectOtherEvent("2010","10/15 - 10/17","US-TN-CSME","Fall Run");

function addEventBlock(text,bgColor) {
   return(
      '<td nowrap="1" width="25">' + 
      '<table bgcolor="' + bgColor + 
      '" cellpadding="0" cellspacing="0" width="100%">' + 
      '<tr>' + 
      '<td class="calendarEvent11" nowrap="1"/>' + 
      '<td class="calendarEvent12" nowrap="1"/>' + 
      '<td class="calendarEvent13" nowrap="1"/></tr>' + 
      '<tr>' + 
      '<td class="calendarEvent21" nowrap="1"/>' + 
      '<td class="calendarEvent22">' + text + '</td>' + 
      '<td class="calendarEvent23" nowrap="1"/></tr>' + 
      '<tr>' + 
      '<td class="calendarEvent31" nowrap="1"/>' + 
      '<td class="calendarEvent32" nowrap="1"/>' + 
      '<td class="calendarEvent33" nowrap="1"/></tr>' + 
      '</table></td>');
}

function addOtherEvents() {
   var count        = 0;
   var otherEvent   = '';
   var previousYear = '';

   for(var x=0; x<otherEvents.length; x++) {
      otherEvent = otherEvents[x];

      if(previousYear != otherEvent.year) {
         w('<tr>' + 
           '<td align="center" bgcolor="#f3efec" class="otherEvent"' + 
           ' colspan="4" nowrap="1">' + otherEvent.year + '</td></tr>' + 
           '<tr><td class="gap2" nowrap="1"/></tr>');
         previousYear = otherEvent.year;
      }

      w('<tr>' + 
        '<td><li class="otherEvent"/></td>' + 
        '<td class="otherEvent" nowrap="1">' + otherEvent.dateRange + '</td>' + 
        '<td class="otherEvent" nowrap="1">&nbsp;-&nbsp;</td>' + 
        '<td class="otherEvent" nowrap="1">');
      if(otherEvent.marker == 'US-FL-MCR') {
         w('<a href="http://matson.us/fls/manatee_home_page.htm" target="' + 
           otherEvent.marker + '">Manatee Central Railroad</a>');
      }
      else if(otherEvent.marker == 'US-FL-NEFLS') {
         w('<a href="http://neflsri.com" target="' + otherEvent.marker + 
           '">NorthEast Florida Live Steamers</a>');
      }
      else if(otherEvent.marker == 'US-FL-RLS') {
         w('<a href="http://www.ridgeclub.org" target="' + otherEvent.marker + 
           '">Ridge Live Steamers</a>');
      }
      else if(otherEvent.marker == 'US-OH-MCC') {
         w('<a href="http://www.millcreekcentral.com" target="' + 
           otherEvent.marker + '">Mill Creek Central</a>');
      }
      else if(otherEvent.marker == 'US-TN-CSME') {
         w('<a href="http://www.sn3.org/csme" target="' + otherEvent.marker + 
           '">Chattenooga Society of Model Engineers</a>');
      }
      else if(otherEvent.marker == 'US-TN-MSLS') {
         w('<a href="http://www.midsouthlivesteamers.org" target="' + 
           otherEvent.marker + '">Mid-South Live Steamers</a>');
      }
      else {
         w(otherEvent.marker);
      }
      if(otherEvent.event != '') {
         w('<tr>' + 
           '<td/><td/><td/>' + 
           '<td class="otherEvent" nowrap="1">' + otherEvent.event + 
           '</td></tr>');
      }
      w('</td></tr>' + 
        '<tr><td class="gap2" nowrap="1"/></tr>');
      count++;
   }
   if(count == 0) {
      w('<li class="otherEvent">No other club events scheduled</li>');
   }
}

function addPageBottom() {
   w('</table></td></tr>' + 
     '</table>' + 
     '<br/>' + 
     '<font face="arial" size="2">All rights reserved. Copyright 2009, 2010 Dale King</font>');
}

function addPageTop(currentPage) {
   w('<table class="page">' + 
     '<tr><td>' + 
     '<table cellpadding="0" cellspacing="0">' + 
     '<tr><td>' + 
     '<table cellpadding="0" cellspacing="0" width="100%">' + 
     '<tr>' + 
     '<td><img border="0" src="images/logo-75.gif"/></td>' + 
     '<td align="right" nowrap="1" valign="bottom" width="100%"/>' + 
     '<td><a href="http://www.nmra.org/" target="nmra">' + 
     '<img border="0" src="images/nmra.gif"/></a></td></tr>' + 
     '</table></td></tr>' + 
     '<tr><td height="5" nowrap="1"/></tr>' + 
     '<tr><td class="toolbar" nowrap="1" width="100%">' + 
     '<table cellpadding="0" cellspacing="0" width="100%">' + 
     '<tr>');
   addToolBarItem('Start','',false);
   addToolBarItem(
      'Home','index.htm',((currentPage == homePage) ? true : false));
// addToolBarItem(
//    'News','news.htm',((currentPage == newsPage) ? true : false));
   addToolBarItem(
      'Locations','locations.htm',
      ((currentPage == locationsPage) ? true : false));
   addToolBarItem(
      'Tracks','tracks.htm',((currentPage == tracksPage) ? true : false));
// addToolBarItem(
//    'Facilities','facilities.htm',
//    ((currentPage == facilitiesPage) ? true : false));
   addToolBarItem(
      'Schedule','schedule.htm',
      ((currentPage == schedulePage) ? true : false));
   addToolBarItem(
      'Photos','photos.htm',((currentPage == photosPage) ? true : false));
   addToolBarItem(
      'Members','members.htm',
      ((currentPage == membersPage) ? true : false));
   addToolBarItem(
      'Newsletters','newsletters.htm',
      ((currentPage == newslettersPage) ? true : false));
// addToolBarItem(
//    'Links','links.htm',((currentPage == linksPage) ? true : false));
   addToolBarItem(
      'Documents','documents.htm',
      ((currentPage == documentsPage) ? true : false));
   addToolBarItem(
      'Contacts','contacts.htm',
      ((currentPage == contactsPage) ? true : false));
   addToolBarItem('Stop','',false);
   w('</tr>' + 
     '</table>' + 
     '<tr><td height="5" nowrap="1"/></tr>' + 
     '<tr><td width="100%">' + 
     '<table cellpadding="0" cellspacing="0" width="100%">');
}

function addSectionBottom(section) {
   w('</td>' + 
     '<td class="section' + section + '-33" nowrap="1"/></tr>' + 
     '<tr>' + 
     '<td class="section' + section + '-41" nowrap="1"/>' + 
     '<td class="section' + section + '-42" nowrap="1"/>' + 
     '<td class="section' + section + '-43" nowrap="1"/></tr>' + 
     '</table>');
}

function addSectionTop(section,title) {
   w('<table class="section" cellpadding="0" cellspacing="0" width="100%">' + 
     '<tr>' + 
     '<td class="section' + section + '-11" nowrap="1"/>' + 
     '<td class="section' + section + '-12" nowrap="1">' + title + '</td>' + 
     '<td class="section' + section + '-13" nowrap="1"/></tr>' + 
     '<tr>' + 
     '<td class="section' + section + '-21" nowrap="1"/>' + 
     '<td class="section' + section + '-22" nowrap="1"/>' + 
     '<td class="section' + section + '-23" nowrap="1"/></tr>' + 
     '<tr>' + 
     '<td class="section' + section + '-31" nowrap="1"/>' + 
     '<td bgcolor="white" nowrap="1" width="100%">');
}

function addToolBarItem(title,link,active) {
   var itemClass = '';

   if(title == 'Start') {
      w('<td>' + 
        '<table cellpadding="0" cellspacing="0">' + 
        '<tr>' + 
//      '<td class="toolbarBlank" colspan="2" nowrap="1"/></tr>' + 
        '<td class="toolbarBlank" nowrap="1"/></tr>' + 
        '<tr>' + 
        '<td class="toolbarStart" nowrap="1"/>' + 
//      '<td class="toolbarGap" nowrap="1"/></tr>' + 
        '</table></td>');
   }
   else if(title == 'Stop') {
      w('<td width="100%">' + 
        '<table cellpadding="0" cellspacing="0" width="100%">' + 
        '<tr>' + 
        '<td class="toolbarBlank" nowrap="1"/></tr>' + 
        '<tr>' + 
        '<td class="toolbarStop1" nowrap="1"/>' + 
        '<td class="toolbarStop2" nowrap="1"/></tr>' + 
        '</table></td>');
   }
   else {
      itemClass = ((active) ? 'toolbarActive' : 'toolbarInactive');

      w('<td>' + 
        '<table cellpadding="0" cellspacing="0">' + 
        '<tr>' + 
        '<td class="' + itemClass + '11" nowrap="1"/>' + 
        '<td class="' + itemClass + '21" nowrap="1"/>' + 
        '<td class="' + itemClass + '31" nowrap="1"/>' + 
//      '<td class="toolbarBlank" nowrap="1"/></tr>' + 
        '<tr>' + 
        '<td class="' + itemClass + '12" nowrap="1"' + 
        ((active) ? '' : ' onclick="go(\'' + link + '\');" ' + 
         'onmouseover="doMouseOver(this);" ' + 
         'onmouseout="doMouseOut(this);"') + '/>' + 
        '<td class="' + itemClass + '22" nowrap="1"' + 
        ((active) ? '' : ' onclick="go(\'' + link + '\');" ' + 
         'onmouseover="doMouseOver(this);" ' + 
         'onmouseout="doMouseOut(this);"') + '>' + title + '</td>' + 
        '<td class="' + itemClass + '32" nowrap="1"' + 
        ((active) ? '' : ' onclick="go(\'' + link + '\');" ' + 
         'onmouseover="doMouseOver(this);" ' + 
         'onmouseout="doMouseOut(this);"') + '/>' + 
//      '<td class="toolbarGap" nowrap="1"/></tr>' + 
        '</table></td>');
   }
}

function doMouseOut(element) {
//	element.style.backgroundColor = '#92a285';
   element.style.cursor          = 'Auto';
}

function doMouseOver(element) {
//	element.style.backgroundColor = '#ffffc0';
   element.style.cursor          = 'Hand';
}

function doOnLoad() {
}

function go(url) {
   parent.location = url;
}

function objectOtherEvent(year,dateRange,marker,event) {
   var object = new Object();

   object.year      = year;
   object.dateRange = dateRange;
   object.marker    = marker;
   object.event     = event;

   return object;
}

function w(text) {
   document.write(text);
}

