#!/usr/bin/perl -w
#
# This script helps make html tables of pictures in the
# following format:
#     pic_1 pic_2 ... pic_nc
#     pic_nc+1 ...
#     .
#     .
#     .
#     pic_nr ...
#
#     where nc => number of columns in the table
#           nr => number or rows in the table
#           np => number of pictures available
#
#             thomas l. gibson  July 27, 2000
#

$IMAGES = '/home/ritlg/tlghtml/images/gamera_II/gamIIa-0'; # Location for graphics
$blank = "\&nbsp\;";   # non-breaking space for blank cells
$nr = 4;
$nc = 4;
$np = 14;

print ("Input the name of the output file\n");
$file_out = <STDIN>;
chomp($file_out);

# Check to see if output file exists---if so, unlink it
if (-e "$file_out") {
  unlink ("$file_out");
}

open (OUT, ">>$file_out") || die "Could'nt open output file: $! \n";

# Print out the standard html header stuff
print OUT<<HEADER;
<!Doctype HTML Public>
<html>
<head>
  <title>T.L. Gibson's friends and family Page 18 (August 2001 in Colorado
Springs)</title>
</head>
<body bgcolor=\"#FFFFFF\">
<p>
<div align=\"center\">
  <h2>A Photo Album of Friends and Family---Page 18</h2>
  \&nbsp\;<br>
  <font size=\"+1\">Garden of the Gods, Seven Falls, and Zoo in Colorado
Springs---August 2001
  </font>
</div>
</p>
HEADER

# Print out the table
print OUT ("<p>\n");
print OUT ("<div align=\"center\">\n");
print OUT ("  <table border=\"2\">\n");

$count = 1;
for ($i = 1; $i <= $nr; $i++)
{
  print OUT ("    <tr align = \"center\">\n");
  for ($j = 1; $j <= $nc; $j++)
  {
    print OUT ("      <td>\n");
    if (($i == $nr) && ($count > $np))
    {
      print OUT ("      $blank\n");
    }
    else
    {
      if ($count > 9)
      {
        $anchor = $IMAGES.$count.".jpg";
      }
      else
      {
        $anchor = $IMAGES."0".$count.".jpg";
      }  
    print OUT ("      <a href=\"$anchor\">Pic $count</a>\n");
    }
    print OUT ("      </td>\n");
    $count++;
  }
  print OUT ("    </tr>\n");
}
print OUT ("  </table>\n");
print OUT ("</div>\n");
print OUT ("</p>\n");

print OUT ("<p>\n");
print OUT ("\&nbsp\;<br>\n");
print OUT ("<div align=\"center\">\n");
print OUT ("  <a href=\"./fp19.html\"><h3>Page 19</h3></a>\n");
print OUT ("</div>\n");
print OUT ("</p>\n");

# Print out the standard html closing stuff

print OUT<<TRAILER;
<hr>
<p>
<i>This page designed and maintained by</i>
<a href=\"mailto:thomas.gibson\@ttu.edu\">thomas.gibson\@ttu.edu</a>
<br>
</p>

<p>
<a href=\"../index.html\">
<img src=\"../images/button_return.gif\" alt=\"Return to Gibson Homepage\">
Return to Gibson Homepage</a>
</p>
</body>
</html>
TRAILER

close (OUT) || die "Couldn't close ouput file: $! \n";
