
function thumb_write()  {
  document.write('<TABLE CELLPADDING="0" CELLSPACING="0">');
  var sub = 0, labelNum = 0;
  var photoNameNum = "";
  document.write('<TR HEIGHT="0">');
  for(sub = 0; sub < 430; sub++)  {
    document.write('<TD HEIGHT="1" WIDTH="1">');
    document.write('</TD>');
  }
  document.write('</TR>');
  for(sub = 0; sub < document.captions.length;)  {
//The following sections build the rows of photos and captions according
//to a format indicator found on the photoSpecs file.
//FORMAT  1: 3 columns of 1-3 thumbs all 100 or less in height and width
//FORMAT  2: 1 thumb of 100 or less in height and width, centered
//FORMAT  3: 2 columns of 1 or 2 horizontal thumbs up to 175 wide each
//FORMAT  4: 1 horizontal thumb up to 175 wide, centered
//FORMAT  5: 3 columns of 1-3 thumbs, left column thumb is up to 155 wide, other 
//           two 100 or less in height and width
//FORMAT  6: 3 columns of 1-3 thumbs, center column thumb is up to 155 wide, other 
//           two 100 or less in height and width (routine not written yet)
//FORMAT  7: 3 columns of 1-3 thumbs, right column thumb is up to 155 wide, other 
//           two 100 or less in height and width (routine not written yet)
//FORMAT  8: no pictures, only one caption that spans the entire width (photo spec 
//           form must contain dummy entry corresponding to caption form entry)
//FORMAT  9: 2 columns of horizontal thumbs up to 175 wide, each numbered with 
//           number on the left of left column and rigth of right column, no 
//           captions (caption form must contain dummy entry)
//FORMAT 10: 1 thumb up to 175 wide, numbered on left, no captions (caption form
//           must contain dummy entry)

//This section handles two exception conditions
    if (sub == 3 && document.stateSpecs.abbrev.value == "nh")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="400" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      document.write('Views above tree line along the Mt. Washington Auto Road.');
      document.write('</FONT>');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="10">');
      document.write('</TD>');
      document.write('</TR>');
    }
    if (sub == 30 && document.stateSpecs.abbrev.value == "ca")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="400" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      document.write('<CENTER>The following nine photos comprise a 360-degree view from the Mt. Whitney summit.<BR> The photos are arranged in a clockwise order.<BR>Very roughly, photo 1 is facing south, 3 west, 6 north and 8 east.</CENTER>');
      document.write('</FONT>');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="10">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 1 rows
    if (document.photoSpecs[sub].value.slice(0,2) == "01")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      //reset sub to write the captions for the photos just written
      sub = sub - 2;
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="5">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 2 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "02")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="165">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      document.write('<TD COLSPAN="165">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="165">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      sub++;
      document.write('<TD COLSPAN="165">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="5">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 3 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "03")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      //reset sub to write the captions for the photos just written
      sub--;
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="5">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 4 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "04")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="127">');
      document.write('</TD>');
      document.write('<TD COLSPAN="176" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      document.write('<TD COLSPAN="127">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="127">');
      document.write('</TD>');
      document.write('<TD COLSPAN="176" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="127">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="5">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 5 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "05")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="155" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="10">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="bottom">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      //reset sub to write the captions for the photos just written
      sub = sub - 2;
      document.write('</TD>');
      document.write('<TD COLSPAN="155" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="10">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="50">');
      document.write('</TD>');
      document.write('<TD COLSPAN="100" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="5">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 8 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "08")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="400" ALIGN="center" VALIGN="top">');
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
      if (document.captions[sub] != null && document.captions[sub].value != "")  {
        document.write(document.captions[sub].value);
      }
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value.slice(13) != '')  {
        document.write('<BR><I>' + document.photoSpecs[sub].value.slice(13) + ' photo</I>');
      }
      document.write('</FONT>');
      document.write('</TD>');
      sub++;
      document.write('</TR>');
      document.write('<TR>');
      document.write('<TD COLSPAN="430" HEIGHT="10">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 9 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "09")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('<TD COLSPAN="15" ALIGN="right" VALIGN="top">');
      labelNum++;
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-1">');
      document.write('' + labelNum);
      document.write('</FONT>');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="top">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="20">');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="top">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="15" ALIGN="left" VALIGN="top">');
      labelNum++;
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-1">');
      document.write('' + labelNum);
      document.write('</FONT>');
      document.write('</TD>');
      document.write('<TD COLSPAN="15">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TD COLSPAN="430" HEIGHT="10">');
      document.write('</TD>');
      document.write('</TR>');
    }

//This section builds FORMAT 10 rows
    else if (document.photoSpecs[sub].value.slice(0,2) == "10")  { 
      document.write('<TR>');
      document.write('<TD COLSPAN="120">');
      document.write('</TD>');
      document.write('<TD COLSPAN="15" ALIGN="right" VALIGN="top">');
      labelNum++;
      document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-1">');
      document.write('' + labelNum);
      document.write('</FONT>');
      document.write('</TD>');
      document.write('<TD COLSPAN="175" ALIGN="center" VALIGN="top">');
      //make the photo number literal that is used in the photo name
      photoNameNum = padNumber(sub + 1, 3);
      if (document.photoSpecs[sub] != null && document.photoSpecs[sub].value != "")  {
        if (document.stateSpecs.page_type.value == "Photos")  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0" onLoad="statPopup(1); return true;"></A>');
        }
        else  {
          document.write('<A HREF="Javascript:photoClicked(\'' + photoNameNum + '\')" onMouseOver="statusMessage(viewerTest());return true;" onMouseOut="statusMessage(0);return true;"><IMG SRC="hpjpg/' + document.stateSpecs.abbrev.value + '/hp' + document.stateSpecs.abbrev.value + photoNameNum + 'tn.jpg" BORDER="0"></A>');
        }
      }
      document.write('</TD>');
      sub++;
      document.write('<TD COLSPAN="120">');
      document.write('</TD>');
      document.write('</TR>');
      document.write('<TD COLSPAN="430" HEIGHT="10">');
      document.write('</TD>');
      document.write('</TR>');
    }
    else  {
    //fail-safe code to avoid endless loop if invalid photo format spec
    sub++;
    }

  }
  document.write('</TABLE>');
  document.write('<FONT FACE="GillSans,Futura,Arial,Helvetica" SIZE="-2">');
  document.write('<P>');
  document.write('All photos by David Wickersham except where noted.');
  document.write('<P>');
  return true;
}