#!/usr/bin/perl

print "Content-Type: text/html\n\n";
$dir = "images/draft/lots";
if(!opendir(DIR,$dir)) {
	print "Couldnt open $dir!<br>\n";
	exit(1);
}
@files = readdir(DIR);
print "<table width=640>\n";
$col = 0;
foreach $file (@files) {
	next unless($file =~ /^[A-Za-z0-9]+\.jpg$/i);
	if(!($col % 4)) {
		print "<tr>\n";
	}
	$th = $file;
	$th =~ s/\.(jpg)/_th.$1/i;
	print "<td><a href=\"$dir/$file\"><img src=\"$dir/th/$th\"></a></td>\n";
	$col++;
	if(!($col % 4)) {
		print "</tr>\n";
	}
}
print "</table>\n";