function w(s)
{
  document.write(s);
}

function buildPanoDesc(themeName, title, subtitle, panos)
{
  var s = '';
  s += '   <tr> ';
  s += '      <td width="1%"><a href="' + themeName + '/pano1/index.htm"><img src="' + themeName + '/images/theme.jpg" border="0"></a></td>';
  s += '      <td valign="top"> ';
  s += buildTOC(title, subtitle, panos, themeName);
  s += '      </td>';
  s += '    </tr>';
  return s;
}

function buildTOC(title, subtitle, panos, dir)
{
  var s = '';
  var fn = '';

  s += '<div align="center">';
  s += '<strong>' + title + '</strong><br>';
  s += '<font size="-2"><strong>' + subtitle + '</strong></font> ';
  s += '<table width="100%" border="0" cellspacing="0" cellpadding="1">';

  var nrows = Math.floor((panos.length + 1) / 2);

  for (i=0; i<nrows; i++)
  {
    s += '<tr>';

// first column
    s += '<td width="1%">';

    s += '<a href="';

      fn = '';
      if (dir.length>0) fn += dir + '/'
      else              fn += '../';
      fn += panos[i][1] + '/index.htm';

    s += fn;

    s += '"><img src="';
    if (dir.length==0) s += '../../'
    s += 'images/icons/yellow.gif" width="7" height="7" border="0"></a></td>';

    s += '<td width="50%"><font size="-2"><a href="';
    s += fn;
    s += '">' + panos[i][0] + '</a></font></td>';

// second column

// check to see if this is a blank entry
    if (panos[nrows+i])
    {
      s += '<td width="1%">';
      s += '<a href="';

        fn = '';
        if (dir.length>0) fn += dir + '/'
        else              fn += '../';

        fn += panos[nrows+i][1] + '/index.htm';

      s += fn;

      s += '"><img src="';
      if (dir.length==0) s += '../../';
      s += 'images/icons/yellow.gif" width="7" height="7" border="0"></a></td>';

      s += '<td width="50%"><font size="-2"><a href="';
      s += fn;
      s += '">' + panos[nrows+i][0] + '</a></font></td>';
    }
    else
    {
      s += '<td width="1%"><font size="-2">&nbsp;</font></td>';
      s += '<td width="50%"><font size="-2">&nbsp;</font></td>';
    }

    s += '</tr>';
  }

  s += '</table></div>';
  return s;
}

function buildPano(title, subtitle, 
                   panoname, panowidth, panoheight, panocenter, pixdeg, 
                   fpname, fpwidth, fpheight, fpx, fpy, linksname, spotsname, view,
                   notice, linktext, URL)
{
  var s= '';
  s += '<table border="0" align="center" cellpadding="0" cellspacing="0">';
  s += '  <tr> ';
  s += '    <td><div align="center"><font size=-2 face="Verdana, Arial, Helvetica, sans-serif">';
  s += '<APPLET name=cpad codeBase="../../" height=15 width=76 code=cpad.class>';
  s += '<PARAM NAME="back" VALUE="../../images/icons/vcrback.gif">';
  s += '<PARAM NAME="over" VALUE="../../images/icons/vcrover.gif">';
  s += '<PARAM NAME="reg0" VALUE="r=0,0,13,15">';
  s += '<PARAM NAME="reg1" VALUE="r=17,0,9,15">';
  s += '<PARAM NAME="reg2" VALUE="r=30,0,16,15">';
  s += '<PARAM NAME="reg3" VALUE="r=51,0,9,15">';
  s += '<PARAM NAME="reg4" VALUE="r=63,0,13,15">';
  s += '<PARAM NAME="cmd0" VALUE="pmvr.auto=-20x5">';
  s += '<PARAM NAME="cmd1" VALUE="pmvr.auto=-20">';
  s += '<PARAM NAME="cmd2" VALUE="pmvr.auto=0">';
  s += '<PARAM NAME="cmd3" VALUE="pmvr.auto=20">';
  s += '<PARAM NAME="cmd4" VALUE="pmvr.auto=20x5">';
  s += '</APPLET>';
  s += '<BR>';
  s += '     Left Mouse Hold and Drag in either pane to move panorama.';
  s += '        <a href=../../doc/controls.htm>Click</a> for full explanation of controls.</font>';
  s += '<BR>';
  s += '</div></td>';
  s += '  </tr>';
  s += '  <tr> ';
  s += '    <td> <div align="center">';
  s += '        <applet name="pmvr" codebase="../../" code="pmvr.class" width=' + panowidth + ' height=' + panoheight + '>';
  s += '          <param name="image" value="' + panoname + '">';
  s += '          <param name="view" value="' + view + '">';
  s += '          <param name="center" value="' + panocenter + '">';
  s += '          <param name="auto" value="20">';
  s += '          <param name="delay" value="3000000">';
  s += '          <param name="pixdeg" value="' + pixdeg + '">';
  s += '        </applet>';
  s += '        <applet name="FloorPlan" codebase="../../" code="FloorPlan.class" width=' + fpwidth + ' height=' + fpheight + '>';
  s += '          <param name="image" value="' + fpname + '">';
  s += '          <param name="x" value="' + fpx + '">';
  s += '          <param name="y" value="' + fpy + '">';
  s += '          <param name="links" value="' + linksname + '">';
  s += '          <param name="spots" value="' + spotsname + '">';
  s += '        </applet>';
  s += '      </div></td>';
  s += '  </tr>';
  s += '  <tr> ';
  s += '    <td><div align="center"><font face="Verdana, Arial, Helvetica, sans-serif">' + title;
  if (subtitle.length>0) s += ', ' + subtitle;
  s += '        <BR><font size=-2>' + notice + '<BR><a href="' + URL + '">' + linktext + '</a></font</font></div></td>';
  s += '  </tr>';
  s += '</table>';
  return(s);
}

function buildPage(bgpattern, title, subtitle, 
                   panoname, panowidth, panoheight, panocenter, pixdeg, 
                   fpname, fpwidth, fpheight, fpx, fpy, linksname, spotsname,
                   panos, dir,
                   view, notice, linktext, URL)
{
  var s = '';
  switch (buildPage.arguments.length)
  {
    case 17:
      view = 360;
    case 18:
      notice = 'Copyright © 2004 by Harry Forsdick';
    case 19:
      linktext = 'return to guide';
    case 20:
      URL = '../../index.htm';
  }

  s += '<html>';
  s += '<head>';
  s += '<title>' + title;
  if (subtitle.length>0) s += ', ' + subtitle;
  s += '</title>';

  s += '<style type="text/css">';
  s += '<!--';
  s += 'body, p, td {';
  s += '	font-family: Verdana, Arial, Helvetica, sans-serif;';
  s += '	font-size: 10pt;';
  s += '}';

  s += 'table {';
  s += '    border-collapse: collapse;';
  s += '	bordercolor: "#000000";';
  s += '	bordercolorlight:"#000000";';
  s += '	bordercolordark: "#000000";';
  s += '}';

  s += '-->';
  s += '</style>';

  s += '</head>';
  s += '<body link="#0000FF" vlink="#0000FF" alink="#FF0000" background="' + bgpattern + '">';
  s += '<p align="center"><font size="+2" face="Verdana, Arial, Helvetica, sans-serif">' + title + '<br>';
  s += '<font size="+1">' + subtitle + '</font> </font></p>';

  s += buildPano(title, subtitle,
                 panoname, panowidth, panoheight, panocenter, pixdeg, 
                 fpname, fpwidth, fpheight, fpx, fpy, linksname, spotsname, view,
                 notice, linktext, URL);

  s += '<BR><TABLE width=300 cellspacing=0 cellpadding=1 align=center border=1><TR><TD>';
  s += buildTOC(title, subtitle, panos, dir);
  s += '</TD></TR></TABLE>';

  s += '</body>';
  s += '</html>';
  w(s);
}