function drawGalleryIndex(psRoot, psTitle, psDesc, psURLPrefix, psPrefix, piCount, piStart, piSize, psNames, psIndexURL)
{
   drawRefGalleryIndex(psRoot, psTitle, psDesc, psURLPrefix, psPrefix, piCount, piStart, piSize, psNames, psIndexURL, null);
}

function drawRefGalleryIndex(psRoot, psTitle, psDesc, psURLPrefix, psPrefix, piCount, piStart, piSize, psNames, psIndexURL, psImgs)
{
   var i, iInd;

   document.write("<SPAN CLASS=\"SYNOPHEAD\">" + psTitle + "</SPAN>\n");
   document.write("<BLOCKQUOTE><SPAN CLASS=\"QUOTE\">\n");
   document.write(psDesc);
   document.write("</SPAN></BLOCKQUOTE><BR>\n");

   document.write("<P ALIGN=CENTER>\n");
   document.write("Page: ");
   for (i = 0; i < (piCount / piSize); i++)
   {
      if ((i + 1) % 11 == 0)
         document.write("<BR/>\n");
      document.write("<A HREF=\"" + psIndexURL + "?" + (i + 1) + "\" onMouseOver=\"javascript:this.style.textDecoration='underline'\" onMouseOut=\"javascript:this.style.textDecoration='none'\"><FONT onMouseOver=\"javascript:this.style.color='#CCCCCC'\" onMouseOut=\"javascript:this.style.color='#B07000'\"><B>[" + (i + 1) + "]</B></FONT></A> ");
   }
   document.write("</P>\n");

   document.write("<BR><TABLE WIDTH=100% ALIGN=CENTER>\n");
   document.write("<TR>\n");

   iInd = 0;
   for (i = piStart - 1; i < piCount && i < (piStart - 1) + piSize; i++)
   {
       if (iInd++ % 6 == 0)
       {
         document.write("</TR>\n");
         document.write("<TR HEIGHT=8><TD COLSPAN=6 NOWRAP></TD></TR>\n");
         document.write("<TR>\n");
       }

       if (psImgs != null)
         drawRefGalleryIndexLink(psRoot, psPrefix + psImgs[i], i, psURLPrefix, psPrefix, (i < psNames.length ? psNames[i] : ""));
       else
         drawGalleryIndexLink(psRoot, i, psURLPrefix, psPrefix, (i < psNames.length ? psNames[i] : ""));
   }

   document.write("</TR>\n");
   document.write("</TABLE>\n");
   document.write("<BR>\n");
}

function drawGalleryIndexLink(psRoot, piNum, psURLPrefix, psPrefix, psName)
{
    var sNum, iPad;

    sNum = (piNum + 1);
    iPad = 5 - sNum.toString().length;
    sNum = psPrefix;
    for (; iPad > 0; iPad--)
       sNum = sNum + "0";
    sNum = sNum + (piNum + 1);

   drawRefGalleryIndexLink(psRoot, sNum, piNum, psURLPrefix, psPrefix, psName);
}

function drawRefGalleryIndexLink(psRoot, psImg, piNum, psURLPrefix, psPrefix, psName)
{
    document.write("<TD VALIGN=TOP ALIGN=CENTER>");
    document.write("<A HREF=\"javascript:ShowGalleryImage('" + psRoot + "', '" + psURLPrefix + psImg + "');\"><IMG BORDER=1 WIDTH=96 SRC=\"" + psURLPrefix + "previews/" + psImg + ".jpg\"></A>");
    if (psName.length > 0)
    {
       document.write("<BR><A HREF=\"javascript:ShowGalleryImage('" + psRoot + "', '" + psURLPrefix + psImg + "');\" onMouseOver=\"javascript:this.style.textDecoration='underline'\" onMouseOut=\"javascript:this.style.textDecoration='none'\"><FONT SIZE=1 onMouseOver=\"javascript:this.style.color='#CCCCCC'\" onMouseOut=\"javascript:this.style.color='#B07000'\"><B>" + psName + "</B></FONT></A>");
    }
    document.write("</TD>\n");
}

function ShowGalleryImage(psRoot, psNum)
{
     window.open(psRoot + "showimage.html?" + escape("John and Aeryn Image") + ";" + psNum + ".jpg","","width=900,height=800,scrollbars");
}
