#!/usr/bin/perl -w

$| = 1;  # turn off output buffering

sub picBlock 
{
   #my $filename = $_[0];
   my ($filename,$row,$col) = @_;

   return if ! defined($filename);


   my $color = 0xffffff - 0x041300 * $row - 0x101010 * $col;

   printf("<td bgcolor=%06x align=center>\n",$color);
   my $rootname = $filename;
   $rootname =~ s/_small.jpg$/.jpg/;  # delete _small for name
   my $alt = $rootname;
   $alt =~ s/.jpg$//;  # delete .jpg suffix
   $alt =~ s/_/ /g;  # convert underscores to spaces
   $alt =~ s/\+/ \& /g;  # convert + to andphersands with spaces
   print "<a href=$rootname>\n";
   print "<img src=$filename\n";
   print "alt=\"$alt\"></a>\n";
   print "<br>$alt\n";
   print "</td>";
}


my @files = `ls *small.jpg`;
chomp @files;  # remove all the trailing newlines
my $numRows = 0;

print "<table><tr><td width=590>";
print "<table>";
while (@files) {

   print "<tr>";
   picBlock($files[0],$numRows,0);
   picBlock($files[1],$numRows,1);
   picBlock($files[2],$numRows,2);
   print "</tr>\n";

   $numRows++;
   shift @files;
   shift @files;
   shift @files;
}
print "</table>\n";
print "</td></tr></table>\n";