#!/usr/bin/perl
print "Content-type: text/html\n\n";
@pics=();@dirs=();
$mydir = $ENV{QUERY_STRING};
if ($mydir=="../" || $mydir=="/" || $mydir==".."){$mydir=="./";}
$numrow=4;
if ($mydir=~/\+num=/) {($mydir,$numrow)=split(/\+num=/,$mydir);}

if ($mydir=~s/showTile=//) {
$mydir=~s/\+/\./;
print "<html><title>Tile Test</title><body background='$mydir'>";
if ($mydir=~/ljust/ || $mydir=~/framed/) {print "<table border='0' width='100%'>
<tr><td width='137'></td><td width='*'>";}
print "<h2 align='left'>" . substr($mydir,0,-4) . "</h2><p>";
unless ($mydir=~/ljust/ || $mydir=~/framed/) {print "<img src='$mydir'>";}
print "<p><big><big>";
@colors=('black','white','red','blue','navy','green','yellow','orange','purple');
for $each_color (@colors) {
my $mycol=ucfirst($each_color);
print "<font color='$mycol'>$mycol Text | <b> Bold Text</b><p></font>";
}
print "</big><hr><p>Right Click anywhere on this page and choose \"Save background as...\" to save the picture to your hard-drive for use with <a href='http://www.litesite.com' target='_new'>LiteSite</a>, Web Pages, or such.<p align='center'>
<a href='$ENV{HTTP_REFERER}'>Return to last page.</a> | 
<a href='http://weber.u.washington.edu/~inspire/'>Return to Inspire.</a></big>";
if ($mydir=~/ljust/ || $mydir=~/framed/) {print "</td></tr></table>";}
print "</body></html>";exit;}

#open the directory
opendir PICDIR, $mydir or print "<html><body>Failed to open directory - $!";
@myfiles = grep !/^\./, readdir PICDIR; #should strip the ./ and ../ 
# and any .* files or directories from the list
closedir PICDIR;

   foreach $each_var (@myfiles) {
if (-d "$ENV{QUERY_STRING}$each_var") {push(@dirs,$each_var);}
elsif ($each_var=~/\.gif|\.jpg|\.GIF|\.JPG|\.BMP|\.bmp/) {push(@pics,$each_var);}
#elsif (-d "desktopbg/$each_var" && $each_var ne 'thmbs') {push(@dirs,$each_var);}
# || $each_var=~/\.html/

#print $each_var . "=" . $dir . "\;\n";
#key is pic_name value is dir - as long as it is not a directory
}#end foreach

#make the page
sort @pics;sort @dirs;
$rowthrough=1;
$num=0;

print "<html><title>Inspire's Image Collection</title><body background='../images/backgrounds/tile/grey-fiber.jpg'>\n<h2 align=center>Inspire's Image Collection</h2><p align='left'>";

unless (scalar(@dirs)==0) {
print "<hr width=50%><p><table border='1'><tr><td><table border=4 bgcolor='#FFFFFF'><tr><td><big><a href='$ENV{HTTP_REFERER}'>Back</a></td></tr></table><td><big>Categories: </big></b>";
 for $each_dir (@dirs){print "<td><table border=4 bgcolor='#FFFFFF'><tr><td><big><a href='dirbrowse.cgi?$ENV{QUERY_STRING}$each_dir";
if ($each_dir=~/tile/) {print "+num=3";}
print "'>" . ucfirst($each_dir) . "</a></td></tr></table></td>";
 }
print "</tr></table><p>";}
print "<table border=1><tr>";
for $each_var (@pics) {
unless ($num==3 && ($rowthrough==1 || $rowthrough==2)) {
my ($file,$thmbext)=split (/\./,$each_var);
print "<td>";
print "<a href='dirbrowse.cgi?showTile=$ENV{QUERY_STRING}$file+$thmbext' target='_top'><img src='" . $mydir . "/" . $each_var . "' alt='" . $each_var . " (~2k)' align='middle' border='0'><br><strong>" . $each_var . "</strong></a><p></td>";
} 
if ($num==3 && $rowthrough==1) {
print "<script language=\"javascript\">
<!-- //Hide from old browsers
browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion);
var addr;
if (browser_name == \"Netscape\" && browser_version >= 4.0) { roll = 'true'; }
else if (browser_name == \"Microsoft Internet Explorer\" && browser_version >= 4.0) { roll = 'true'; }
else { roll = 'false'; }

function msover(name,type) { if (roll == 'true') {
if (type != \".gif\") type = \".jpg\"; 
addr = document.images[name].src;
addr = addr.substr(0,addr.length-4); addr = addr + \"2\" + type;
document.images[name].src = addr;
 } }

function msout(name, type) { if (roll == 'true') {
if (type != \".gif\") type = \".jpg\"; 
// substring one char shorter....
addr = document.images[name].src;
addr = addr.substr(0,addr.length-5);addr = addr + type;
document.images[name].src = addr;
 } }
// Reveal -->
</script>
<td align='center' rowspan='2'>
<img src=\"../images/Menu/tot_top.jpg\" width=\"164\"
height=\"38\"><br>
<a href=\"../index.html\"
onmouseover=\"msover('home'); window.status='Go to the beginning of beginnings.';return;\"
onmouseout=\"msout('home');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tot_home.jpg\" alt=\"Home\" border=\"0\" width=\"164\" height=\"33\"
name=\"home\"></a><br>
<a href=\"../philosophy/index.html\"
onmouseover=\"msover('philo'); window.status='Enter or begin a philosophical discussion';return;\"
onmouseout=\"msout('philo');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tot_philo.jpg\" alt=\"Philosophy\" border=\"0\" width=\"164\" height=\"39\"
name=\"philo\"></a><br>
<a href=\"../quotes.html\"
onmouseover=\"msover('quotes'); window.status='The best words spoken by mankind are remembered';return true;\"
onmouseout=\"msout('quotes');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tot_quot.jpg\" alt=\"Quotes\" border=\"0\" width=\"164\" height=\"32\"
name=\"quotes\"></a><br>
<a href=\"../poems/index.html\"
onmouseover=\"msover('poems'); window.status='Poetry selections and read&amp;share other visitors';return true;\"
onmouseout=\"msout('poems');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tot_poems.jpg\" alt=\"Poems\" border=\"0\" width=\"164\" height=\"38\"
name=\"poems\"></a><br>
<a href=\"../index.html\"
onmouseover=\"window.status='Go to the base images page.';return true;\"
onmouseout=\"window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tul_imag_top.jpg\" alt=\"Images:\" border=\"0\" width=\"164\" height=\"23\"></a><br>
<a href=\"../desktopbg/luis.html\"
onmouseover=\"msover('ima_luis'); window.status='Desktop backgrounds  .Very...intriguing.';return true;\"
onmouseout=\"msout('ima_luis');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tul_imag_luis.jpg\" alt=\"* Desktop Backgorunds\" border=\"0\" width=\"164\"
height=\"14\" name=\"ima_luis\"></a><br>
<a href=\"../pictures/best.html\"
onmouseover=\"msover('ima_best'); window.status='Best photographs from my collection.';return true;\"
onmouseout=\"msout('ima_best');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tul_imag_best.jpg\" alt=\"* Best\" border=\"0\" width=\"164\" height=\"13\"
name=\"ima_best\"></a><br>
<a href=\"../pictures/uw.html\"
onmouseover=\"msover('ima_uw'); window.status='Photographs from around the U. Washington area.';return true;\"
onmouseout=\"msout('ima_uw');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tul_imag_uw.jpg\" alt=\"* U Wash.\" border=\"0\" width=\"164\" height=\"15\"
name=\"ima_uw\"></a><br>
<a href=\"../pictures/italy.html\"
onmouseover=\"msover('ima_italy'); window.status='Pictures from Italy (beautiful Country!).';return true;\"
onmouseout=\"msout('ima_italy');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tul_imag_italy.jpg\" alt=\"* Italy\" border=\"0\" width=\"164\" height=\"14\"
name=\"ima_italy\"></a><br>
<a href=\"../pictures/search.html\"
onmouseover=\"msover('ima_search'); window.status='Search the descriptions and titles of all images on this site.';return true;\"
onmouseout=\"msout('ima_search');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tul_imag_search.jpg\" alt=\"* Search!\" border=\"0\" width=\"164\"
height=\"24\" name=\"ima_search\"></a><br>
<a href=\"../humor.html\"
onmouseover=\"msover('humor'); window.status='Funny Stuff!';return true;\"
onmouseout=\"msout('humor');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tot_humor.jpg\" alt=\"Humor\" border=\"0\" width=\"164\" height=\"38\"
name=\"humor\"></a><br>
<a href=\"../index.html\"
onmouseover=\"msover('links'); window.status='Links to other interesting and useful places.';return true;\"
onmouseout=\"msout('links');window.status='Welcome to Inspire';return true;\"><img
src=\"../images/Menu/tot_links.jpg\" alt=\"Links\" border=\"0\" width=\"164\" height=\"39\"
name=\"links\"></a><br>
<img src=\"../images/Menu/tot_bottom.jpg\" width=\"164\" height=\"28\"></td>";
}

$num++;if ($num==$numrow || $mydir=~/ljust/ || $mydir=~/framed/) {print "</tr><tr>";$rowthrough++;$num=0;};
}; #  close for loop
print "</table><p><div align=right>Images are believed to be digital freeware, if you own them and do not want them on here, please <a href='mailto:fantasy_dreaming\@yahoo.com'>let me know</a> and I will be happy to remove them asap.<br>Many images are my favorites from <a href='http://www.windyweb.com/design/'>Windy's Fashionable Designs</a>, visit their site for more information.";
print "<script language='javascript'>
<!-- //hiding
//predeclare mouseover images for rolling browsers - do at end of page so text loads first
browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion); 
var addr;
if (browser_name == \"Netscape\" && browser_version >= 4.0) { roll = 'true'; }
else if (browser_name == \"Microsoft Internet Explorer\" && browser_version >= 4.0) { roll = 'true'; }
else { roll = 'false'; }

if (roll == 'true') {
a = new Array();b = new Array();for (i=0;i<4;i++) b[i]=new Image();b[0].src=\"../images/Menu/bigleaf_up2.gif\";b[1].src=\"../images/Menu/bigleaf_down2.gif\";b[2].src=\"../images/Menu/smleaf_up2.gif\";b[3].src=\"../images/Menu/smleaf_down2.gif\";
for (i=0;i<12;i++) a[i] = new Image();

a[0].src = '../images/Menu/tot_home2.jpg';
a[1].src = '../images/Menu/tot_philo2.jpg';
a[2].src = '../images/Menu/tot_quot2.jpg';
a[3].src = '../images/Menu/tot_poems2.jpg';
a[4].src = '../images/Menu/tot_imag2.jpg';
a[5].src = '../images/Menu/tot_humor2.jpg';
a[6].src = '../images/Menu/tot_links2.jpg';

a[7].src = '../images/Menu/tul_imag_luis2.jpg';
a[8].src = '../images/Menu/tul_imag_best2.jpg';
a[9].src = '../images/Menu/tul_imag_uw2.jpg';
a[10].src = '../images/Menu/tul_imag_italy2.jpg';
a[11].src = '../images/Menu/tul_imag_search2.jpg';
}
//-->
</script></body></html>";