#!/usr/bin/perl -w
use CGI;
use strict;


my $query = new CGI;
my $CGI_params = CGI::new();

my $directory = $CGI_params->param("directory");
my $gallery = $CGI_params->param("gallery");
my $artist = $CGI_params->param("artist");
my $number = $CGI_params->param("number");
my $title = $CGI_params->param("title");

print $query->header;

open(FILE, "../toptemplate.html");
while (<FILE>){
	    print $_;
    }
close(FILE); 


print "\<H2\>\<B\>\<U\>$title\<\/U\>\<\/B\>\<\/H2\>";
print "\<TABLE width=600 border=0 cellspacing=2 cellpadding=0\>";
print "\<TR\>";

my $dirlist="/home/hossell/public_html/gallery/$directory/$gallery/$artist/$number/images";

opendir(DIR,"$dirlist") or die;
my @dir = readdir DIR;
closedir(DIR);
my $x = 0;
foreach my $file (@dir)
{
  if (! -d $file && $file ne 'tn')
  {
	$x = $x+1;
	print "\<TD\>\<A HREF=\"..\/$directory\/$gallery\/$artist\/$number\/images\/";
    	print $file;
	print "\" target=\"_new\"\>\<IMG SRC=\"..\/$directory\/$gallery\/$artist\/$number\/images\/tn\/";
	print $file;
	print "\" border=0\>\<\/A\>\<\/TD\>\n\r";
	if ($x==5)
	{
	  print "\<\/TR\>\<TR\>\n\r";
  	  $x=0;
	}
  }
}

open(FILE, "../bottomtemplate.html");
while (<FILE>){
  print $_;
}
close(FILE);		
