#!/bin/perl
# pics.pl

use strict;

use CGI qw(:standard);
use myHTML;

my $b_home    = my_button_home;
my $b_help    = my_button_help;
my $b_mail    = my_button_mail;
my $b_voting  = my_button_voting;
my $b_empfehl = my_button_empfehlung;
my $temp      = my_tmp_path;

my @abc = ('A','B','C','D','E','F','G','H','I','J','K','L','M',
           'N','O','P','Q','R','S','T','U','V','W','X','Y','Z');

#print header();

my $data = my_dat_path;

my $cno=param('cno');
# Zaehler lesen ...
my $count;
open COUNTER, "<${data}count";
while (<COUNTER>) {
	$count=$_;
}
close COUNTER;
# ... um eins erhöhen ...
$count++ unless($cno);
# ... und neuen Stand schreiben
open COUNTER, ">${data}count";
print COUNTER "$count";
close COUNTER;


ins_dirs;

p2 "<html>",
	"<head>",
	"<title>Bildergallerie</title>",
	"<style type='text/css'>",
	"select { font-size:10pt }",
	"td { font-size:10pt }",
	"input { font:10pt }",
	"a { font-size:14pt }",
	"visit { font-size:8pt }",
	"</style>",

	"<script type='text/javascript'>",
	"<!--",

	"function ZweiFrames(URI1,F1,URI2,F2) {",
	"	Frame1=eval('parent.'+F1);",
	"	Frame2=eval('parent.'+F2);",
	"	Frame1.location.href = URI1;",
	"	Frame2.location.href = URI2;",
	"}",

	"function bildtausch(BUCHST,FILE) {",
	"	bild = new Image();",
	"	bild.src = FILE;",
	"	//document.images[BUCHST].src = bild.src; //pic ist der Name des IMG-Tag im oben Frame",
	"}",

	"//-->",
	"</script>",
	"</head>",
	"<body marginwidth='5' marginheight='0' topmargin='3' leftmargin='5'>";



#p " <p align='center'>";

p2 	"  <table border='0' cellspacing='0' cellpadding='0' width='100%'>",
	"   <tr>",
	"    <td width='120' align='left'>",
	"     <a href='pics_e.pl' target='pics'><img alt='Home' border='0' width='50' src='$b_home'></a>",
	"    </td>",
	"    <td align='center'>";

foreach my $buchst (sort @abc) {
	my $found=0;
	foreach my $girl (sort keys %dirs) {
		if ($girl =~ /^$buchst/) {
			my $directory = $dirs{"$girl"};
			if (opendir DH, $directory) {
				unless (-e "$directory/content") { # Bei jedem ersten Ordner eines Anfangsbuchstaben
									 # wird eine content datei erstellt. so kann das pic
									 # of day aus wenigstens einer kleinen anzahl verzeichnissen
									 # ausgewählt werden
					my_create_content ("$directory");
				}
				if ($found==0) {
					my $buchst2="../pics/" . $buchst . "_sel.jpg";
					p2 "     <a href='pics.pl?let=$buchst' onclick=\"bildtausch('$buchst','$buchst2')\" target='pics'><img name='$buchst' border='0' src='../pics/$buchst.gif'></a>";
				}
				$found=1;
			}
			closedir DH;
		}
	}
}

p2 	"    </td>",
	"    <td width='120' align='right'>",
	"     <a href='helpme.pl' target='helpme'><img alt='Hilfe' border='0' width='50' alt='Home' src='$b_help'></a>",
	"    </td>",
	"   </tr>",
	"   <tr>",
	"    <td align='center'>";
	
p "     <font size=2pt>$count visits</font>";

p2 "    </td>",
   "    <td align='center'>",
   "     <a href='mailto:webmaster\@bildergallerie.de'><img alt='Schreib mir' border='0' src='$b_mail'></a>",
   "     <a href='voting.pl?value=0' onclick=\"window.open(this.href,'new','width=400,height=400,left=0,top=0'); return false\"><img alt='Voting' border='0' src='$b_voting'></a>",
   "     <a href='tellfriend.pl?action=form' onclick=\"window.open(this.href,'tell','width=500,height=200,left=0,top=0'); return false\"><img alt='Weitersagen' border='0' src='$b_empfehl'></a>",
   "    </td>",
   "   </tr>",
   "  </table>";

#p2 	" </p>",
p2	"</body>",
	"</html>";
