#!/usr/bin/perl 
use File::Basename;
# parse TVZ Schedule .csv and add features from articles pictures posters Photos setlists etc
# derived from splitter.pl
my $art_ind = "";
my $art_name = "";
my $set_ind = "";
my $set_name = "";
my $pos_ind = "";
my $pos_name = "";
my $gpic_ind = "";
my $gpic_name = "";
my $oth_ind = "";
my $oth_name = "";
my $end = "";
my $item = "";
my $oitem = "";
my $gitem = "";
my $gitemt = "";
my %date_done = "";
my $myline = "";
my %any = "";
my %sets = "";
my %arts = "";
my %artst = "";
my %pics = "";
my %picst = "";
my %poss = "";
my %posst = "";
my %gpics = "";
my %gpicst = "";
my %oth = "";
my %otht = "";
# exclusion list specified by Harold Eggers  FIXME need to program this in:
# clnpics/Townes.jpg
# clnpics/1990-xx-xx-Kevin_Eggers-TvZ-Steve_Mendel-Harold_Eggers_at_Fire_Station_Studio-San_Marcos-TX.*
# clngigs/1991-xx-xx-Kevin_Eggers-TvZ-Steve_Mendel_and_Harold_Eggers_at_the_Fire_Station_Studio-San*
# clnpics/1994-xx-xx-Late-TvZ_.*
# clnpost/1994-xx-xx-NoDeeperTour.*
# clngigs/1994-11-01-Bergen-Norway_2.*
# clngigs/1994-12-02-Townes_met_Rick_Danko_and_Harold_Eggers_in_Italy.*
# clngigs/1995-02-10_McCabes-Santa_Monica-CA.*
# clngigs/1995-11-29_Loft-Berlin-Germany_with_Luc_Wouters.*
# clnpics/1996-xx-xx-TvZ_with_Stephan_and_Peggy_Nolan-Massachusetts.*
# clnpics/1996-xx-xx-Frankfurt-Germany.*
# clnpics/1996-xx-xx-Wolfgang_Pracht_and_TvZ.*
#while ($#ARGV >= 0) {
#my $file = shift(@ARGV);
my $mainfile = "./TvZ -Timeline 2015-03-31b.csv";
#my $articles = "TvZ articles";
#my $postures = "TvZ pictures";
#my $gpictures = "TvZ Photos made @ Gigs";
#my $articles =  "articles";
my $articles =  "clnarts";
#my $postures =  "pictures";
my $pictures =  "clnpics";
my $gpictures = "clngigs";
#my $posters =   "posters";
my $posters =   "clnpost";
my $setlists =  "clnset";
#my $others =    "others";
my $others =     "clnoth";
my $twidth = 250;
my $pwidth = 250;
#print "file: $file\n";
#my ($base,$dir,$ext) = fileparse($file,'\..*');

my $count = "01";


my $contents = "./tvz60s70s.html";
# prepare table of contents file
open(CONT, "> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Townes Van Zandt Concert Appearances and Timeline</TITLE>
   <META NAME="AUTHOR" CONTENT="Len Coop">
   <META NAME="GENERATOR" CONTENT="VI">
   <META NAME="KEYWORDS" CONTENT="Tour Schedule, Appearance Schedule, Live in Concert">
</HEAD>
<BODY>
<H2>Townes Van Zandt Timeline & Appearance Schedule 1940s-1970s</H2>
<A HREF="clnpics/the_1950ties.jpg"><IMG SRC="clnpics/the_1950ties.t.jpg" width=200></A>
<A HREF="clnpics/Townes_archive_Photo_4.jpg"><IMG SRC="clnpics/Townes_archive_Photo_4.t.jpg" width=200></A>
<A HREF="clnpics/Townes_with_Cindy_and_Bidy_Taylor.jpg"><IMG SRC="clnpics/Townes_with_Cindy_and_Bidy_Taylor.t.jpg" width=240></A>
<H3>with selected setlists, photos, posters, articles, and links</H3>
<H4>Version 4/11/15 by Hans & Len with assistance from Patrick</H4>
<H4>See also <A HREF=http://www.townesvanzandt20yearshfe.com/timeline/>Harold Eggers' 20 years with Townes Timeline</A></H4>
<H4>Jump to Townes in the <A HREF=tvz80s.html>1980s</A> or <A HREF=tvz90s.html>1990s</A>. Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>

<TABLE><TR>
<TD BGCOLOR="FFFFFF"><B>EVENT TYPE: </B></TD>
<TD BGCOLOR="#D4DDC0"><B> P=Performance </B></TD>
<TD BGCOLOR="#F3E2AS"><B> LE=Life event </B></TD>
<TD BGCOLOR="#C4CCC0"><B> O=Record releases & other career events</B></TD>
</TR></TABLE>

<TABLE BORDER=0>
<TR>
<TD style="width:10px"><B>Year</B></TD>
<TD style="width:10px"><B>Mon</B></TD>
<TD style="width:10px"><B>Day(s)</B></TD>
<TD style="width:10px"><B>Ty pe</B></TD>
<TD><B>Location</B></TD>
<TD><B>City</B></TD>
<TD><B>State /Coun- try</B></TD>
<TD><B>Notes</B></TD>
<TD><B>Sources</B></TD>
<TD><B>Other source info</B></TD>
<TD><B></B></TD>
<TD><B>Cert.</B></TD>
<TD><B>Addit. notes</B></TD></TR>
EOF
close CONT;

my $contents = "./tvz80s.html";
# prepare table of contents file
open(CONT, "> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Townes Van Zandt Concert Appearances and Timeline</TITLE>
   <META NAME="AUTHOR" CONTENT="Len Coop">
   <META NAME="GENERATOR" CONTENT="VI">
   <META NAME="KEYWORDS" CONTENT="Tour Schedule, Appearance Schedule, Live in Concert">
</HEAD>
<BODY>
<H2>Townes Van Zandt Timeline & Appearance Schedule 1980s</H2>
<A HREF="clnpics/Townes_and_Mickey_White.jpg"><IMG SRC="clnpics/Townes_and_Mickey_White.t.jpg" width=200></A>
<A HREF="clnpics/Townes_and_Mickey_White-Rare_Picture-Mickey_at_Piano.jpg"><IMG SRC="clnpics/Townes_and_Mickey_White-Rare_Picture-Mickey_at_Piano.t.jpg" width=200></A>
<H3>with selected setlists, photos, posters, articles, and links</H3>
<H4>Version 4/11/15 by Hans & Len with assistance from Patrick</H4>
<H4>Jump to Townes in the <A HREF=tvz60s70s.html>1940s-70s</A> or <A HREF=tvz90s.html>1990s</A>.  Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
<TABLE><TR>
<TD BGCOLOR="FFFFFF"><B>EVENT TYPE: </B></TD>
<TD BGCOLOR="#D4DDC0"><B> P=Performance </B></TD>
<TD BGCOLOR="#F3E2AS"><B> LE=Life event </B></TD>
<TD BGCOLOR="#C4CCC0"><B> O=Record releases & other career events</B></TD>
</TR></TABLE>

<TABLE BORDER=0>
<TR>
<TD style="width:10px"><B>Year</B></TD>
<TD style="width:10px"><B>Mon</B></TD>
<TD style="width:10px"><B>Day(s)</B></TD>
<TD style="width:10px"><B>Ty pe</B></TD>
<TD><B>Location</B></TD>
<TD><B>City</B></TD>
<TD><B>State /Coun- try</B></TD>
<TD><B>Notes</B></TD>
<TD><B>Sources</B></TD>
<TD><B>Other source info</B></TD>
<TD><B></B></TD>
<TD><B>Cert.</B></TD>
<TD><B>Addit. notes</B></TD></TR>
EOF
close CONT;

my $contents = "./tvz90s.html";
# prepare table of contents file
open(CONT, "> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Townes Van Zandt Concert Appearances and Timeline</TITLE>
   <META NAME="AUTHOR" CONTENT="Len Coop">
   <META NAME="GENERATOR" CONTENT="VI">
   <META NAME="KEYWORDS" CONTENT="Tour Schedule, Appearance Schedule, Live in Concert">
</HEAD>
<BODY>
<H2>Townes Van Zandt Timeline & Appearance Schedule 1990s</H2>

<A HREF="clnpics/TvZ_his_Hobby-Sailing.jpg"><IMG SRC="clnpics/TvZ_his_Hobby-Sailing.t.jpg" width=240></A>
<A HREF="clnpics/1996-xx-xx-One_of_Townes_latest_photos.jpg"><IMG SRC="clnpics/1996-xx-xx-One_of_Townes_latest_photos.t.jpg" width=240></A>

<H3>with selected setlists, photos, posters, articles, and links</H3>
<H4>Version 4/11/15 by Hans & Len with assistance from Patrick</H4>
<H4>Jump to Townes in the <A HREF=tvz60s70s.html>1940s-70s</A> or <A HREF=tvz80s.html>1980s</A>.  Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
<TABLE><TR>
<TD BGCOLOR="FFFFFF"><B>EVENT TYPE: </B></TD>
<TD BGCOLOR="#D4DDC0"><B> P=Performance </B></TD>
<TD BGCOLOR="#F3E2AS"><B> LE=Life event </B></TD>
<TD BGCOLOR="#C4CCC0"><B> O=Record releases & other career events</B></TD>
</TR></TABLE>

<TABLE BORDER=0>
<TR>
<TD style="width:10px"><B>Year</B></TD>
<TD style="width:10px"><B>Mon</B></TD>
<TD style="width:10px"><B>Day(s)</B></TD>
<TD style="width:10px"><B>Ty pe</B></TD>
<TD><B>Location</B></TD>
<TD><B>City</B></TD>
<TD><B>State /Coun- try</B></TD>
<TD><B>Notes</B></TD>
<TD><B>Sources</B></TD>
<TD><B>Other source info</B></TD>
<TD><B></B></TD>
<TD><B>Cert.</B></TD>
<TD><B>Addit. notes</B></TD></TR>
EOF
close CONT;

# prepare table of contents file
my $contents = "./tvzmisc.html";
open(CONT, "> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Townes Van Zandt Timeline & Appearances</TITLE>
   <META NAME="AUTHOR" CONTENT="Len Coop">
   <META NAME="GENERATOR" CONTENT="VI">
   <META NAME="KEYWORDS" CONTENT="Tour Schedule, Appearance Schedule, Live in Concert">
</HEAD>
<BODY>
<H2>Townes Van Zandt Timeline & Appearance Schedule Misc.<B>with selected setlists, photos, posters, articles, and links</H2>
<H4>Version 4/11/15 by Hans & Len with assistance from Patrick</H4>
<H4>Jump to <A HREF=tvz60s70s.html>1940s-70s</A> or <A HREF=tvz80s.html>1980s</A></H4>
<H4>Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
<TABLE BORDER=0>
<TR>
<TD><B>Year</B></TD>
<TD><B>Mon</B></TD>
<TD><B>Day(s)</B></TD>
<TD><B>Location</B></TD>
<TD><B>City</B></TD>
<TD><B>State/Country</B></TD>
<TD><B>Notes</B></TD>
<TD><B>Sources</B></TD>
<TD><B>Other source info</B></TD>
<TD><B>Links</B></TD>
<TD><B>Certainty</B></TD>
<TD><B>Addit. notes</B></TD></TR>
EOF
close CONT;




# fill hash from text file
opendir(ADIR, "$articles") || die("cannot open $articles");
foreach $item (readdir(ADIR)) {
  #print "$item\n";
  next unless $item =~ /txt|htm|pdf|gif|png|jpg/i;
  ($art_ind,$art_name,$end) = $item =~ /(\d+-\d+-\d+)(.*)(\.\w+)/;
  $itemt = $art_ind . $art_name . ".t" . ".jpg" if $end =~/gif|png|jpg/;
  #next if ($art_ind =~ /199|198/);
  $any{$art_ind} ++;
  $arts{$art_ind} = $item;
  $artst{$art_ind} = $itemt if $end =~ /gif|png|jpg/;
#  print CONT "$item: $art_ind : $art_name : $end\n";
}
close(ADIR);

# fill hash from text file
opendir(SDIR, "$setlists") || die("cannot open $setlists");
foreach $item (readdir(SDIR)) {
  #print "$item\n";
  next unless $item =~ /txt|doc|jpg/i;
  ($set_i1,$set_i2,$set_i3,$set_name,$set_end) = $item =~ /(\d+)-(\d+|xx)-(\d+|xx)(.*)(\.txt|\.doc|\.docx|\.jpg)/i;
  $set_ind = $set_i1 . "-" . $set_i2 . "-" . $set_i3;
  #$setemt = $set_ind . $set_name . ".t" . $set_end;
  #($set_ind,$set_name,$end) = $item =~ /(\d+-\d+-\d+)(.*)(\.\w+)/;
  #next if ($art_ind =~ /199|198/);
  $sets{$set_ind} = $item;
  $any{$set_ind} ++;
  #print "$item:$set_ind:$set_name :$set_end\n";
}
close(SDIR);
#exit;

# fill hash from text file
opendir(ODIR, "$posters") || die("cannot open $posters");
foreach $oitem (readdir(ODIR)) {
  next if $oitem =~ /\.t\./;
  next unless $oitem =~ /jpg|png|gif/i;
  ($pos_i1,$pos_i2,$pos_i3,$pos_name,$pos_end) = $oitem =~ /(\d+)-(\d+|xx)-(\d+|xx)(.*)(\.jpg|\.png|\.gif)/i;
  $pos_ind = $pos_i1 . "-" . $pos_i2 . "-" . $pos_i3;
  #$oitemt = $pos_ind . $pos_name . ".t" . $pos_end;
  $oitemt = $pos_ind . $pos_name . ".t" . ".jpg";
if ($poss{$pos_ind}) { 
   $any{$pos_ind} ++;
   $pos_ind = $pos_ind . "2";
     if ($poss{$pos_ind}) { 
      $any{$pos_ind} ++;
      $pos_ind = $pos_ind . "3"; 
   }
     if ($poss{$pos_ind}) { 
      $any{$pos_ind} ++;
      $pos_ind = $pos_ind . "4"; 
   }
     if ($poss{$pos_ind}) { 
      $any{$pos_ind} ++;
      $pos_ind = $pos_ind . "5"; 
   }
}
  $poss{$pos_ind} = $oitem;
  $any{$pos_ind} ++;
  $posst{$pos_ind} = $oitemt;
  print "$oitem index: $pos_ind name: $pos_name \n";
}
close(ODIR);


# fill hash from text file
opendir(PDIR, "$pictures") || die("cannot open $pictures");
foreach $pitem (readdir(PDIR)) {
  next if $pitem =~ /\.t\./;
  next unless $pitem =~ /jpg|png|gif/i;
  ($pic_i1,$pic_i2,$pic_i3,$pic_name,$pic_end) = $pitem =~ /(\d+)-(\d+|xx)-(\d+|xx)(.*)(\.jpg|\.png|\.gif)/i;
  $pic_ind = $pic_i1 . "-" . $pic_i2 . "-" . $pic_i3;
  #$pitemt = $pic_ind . $pic_name . ".t" . $pic_end;
  $pitemt = $pic_ind . $pic_name . ".t" . ".jpg";
if ($pics{$pic_ind}) { 
   $any{$pic_ind} ++;
   $pic_ind = $pic_ind . "2";
     if ($pics{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "3"; 
   }
     if ($pics{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "4"; 
   }
     if ($pics{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "5"; 
   }
}
  $pics{$pic_ind} = $pitem;
  $any{$pic_ind} ++;
  $picst{$pic_ind} = $pitemt;
  #print "$pitem index: $pic_ind name: $pic_name \n";
}
close(PDIR);

# fill hash from text file
opendir(ODIR, "$others") || die("cannot open $others");
foreach $item (readdir(ODIR)) {
  next if $item =~ /\.t\./;
  next unless $item =~ /jpg|png|gif/i;
  ($pic_i1,$pic_i2,$pic_i3,$pic_name,$pic_end) = $item =~ /(\d+)-(\d+|xx)-(\d+|xx)(.*)(\.jpg|\.png|\.gif)/i;
  $pic_ind = $pic_i1 . "-" . $pic_i2 . "-" . $pic_i3;
  #$pitemt = $pic_ind . $pic_name . ".t" . $pic_end;
  $itemt = $pic_ind . $pic_name . ".t" . ".jpg";
if ($oth{$pic_ind}) { 
   $any{$pic_ind} ++;
   $pic_ind = $pic_ind . "2";
     if ($oth{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "3"; 
   }
     if ($oth{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "4"; 
   }
     if ($oth{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "5"; 
   }
}
  $oth{$pic_ind} = $item;
  $otht{$pic_ind} = $itemt;
  #print "$item index: $pic_ind name: $pic_name \n";
}
close(ODIR);

# fill hash from text file
opendir(GDIR, "$gpictures") || die("cannot open $gpictures");
foreach $item (readdir(GDIR)) {
  next if $item =~ /\.t\./;
  next unless $item =~ /jpg|png|gif/i;
  ($pic_i1,$pic_i2,$pic_i3,$pic_name,$pic_end) = $item =~ /(\d+)-(\d+|xx)-(\d+|xx)(.*)(\.jpg|\.png|\.gif)/i;
  $pic_ind = $pic_i1 . "-" . $pic_i2 . "-" . $pic_i3;
  $itemt = $pic_ind . $pic_name . ".t" . ".jpg";
if ($gpics{$pic_ind}) { 
   $any{$pic_ind} ++;
   $pic_ind = $pic_ind . "2";
     if ($gpics{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "3"; 
   }
     if ($gpics{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "4"; 
   }
     if ($gpics{$pic_ind}) { 
      $any{$pic_ind} ++;
      $pic_ind = $pic_ind . "5"; 
   }
}
  $gpics{$pic_ind} = $item;
  $gpicst{$pic_ind} = $itemt;
  #print "index: $gpic_ind name: $gpic_name end: $gpic_end thumb: $gitemt\n" if $gpic_ind =~ /1973/;
}
close(GDIR);
my $row_count;
my $linecount = 0;
#exit;
# fill hash with MAIN labels and section text (db) filenames from text file
open(MDB,"<$mainfile") || die "cannot open $mainfile";
while (<MDB>) {
  $linecount++;
  if ($row_count) {
       $row_phase=0;
       $bgcolor = '#D4DDC0';
   } else {
       $row_count=1;
       $bgcolor = '#FFFFFF';
   }
  chomp $_;
  #@Md = split(/,/,$_, 9999);
# $_ =~ s/\|\|\|\|\|\|\|\|\|\|\|/<HR>/; 
  next if ($_ =~ /^\s+$/);
  next if $linecount == 1;
  @Md = split(/\|/,$_, 9999);
   $yr   = $Md[0];
   $mon1 = $Md[1];
   $day1 = $Md[2];
   $type = $Md[3];
if ($type eq "O") {
       $bgcolor = '#C4CCC0';
}
elsif ($type eq "LE") {
       $bgcolor = '#F3E2AS';
}
   $loc  = $Md[4];
   $city = $Md[5];
   $anotes=$Md[6];
#next if ($date =~ /199|198/);
#if ($mon1 == "spring/summer") { $mon1 = "spring or summer"; }
$mon = sprintf("%02d",$mon1);
$days = sprintf("%02d",$day1);
if ($mon == "00") { $mon = "xx"; }
print "orig:   $mon1 $day1 $yr REV: $mon $days $_\n" if $yr =~ /1969/;
if ($days == "00") { $days = "xx"; }
#print "reform: $mon $days $yr\n" if $yr =~ /197/;
my $date = $yr . "-" . $mon . "-" . $days;
my $dateb = $yr . "-" . $mon . "-" . $days . "2";
my $datec = $yr . "-" . $mon . "-" . $days . "23";
my $dated = $yr . "-" . $mon . "-" . $days . "234";
my $datee = $yr . "-" . $mon . "-" . $days . "2345";
if ($days =~ /../) {
#print "$_ article found: $arts{$date} \n" ;

$myline = $_;
$myline =~ s/^year/<b>year/;
$myline =~ s/spring\/summer/spring or summer/;
$myline =~ s|8/9/10/11|8/9 /10/11|;
$myline =~ s|23/24/25/26|23/24 /25/26|;
$myline =~ s|1/2/3/4/5/6/7/8/9/10/11/12/13|1/2/3/4 /5/6/7/8 /9/10/11 /12/13|;
$myline =~ s|5/6/7/8/9/10/11/12|5/6/7/8 /9/10 /11/12|;
$myline =~ s|5/6/7/8/9/10|5/6/7/8 /9/10|;
$myline =~ s|22/23/24/25|22/23 /24/25|;
$myline =~ s|26/27/28/29|26/27 /28/29|;
$myline =~ s|27/28/29|27 /28/29|;
$myline =~ s|19/20/21/22|19/20 /21/22|;
$myline =~ s|19/20/21|19/20 /21|;
$myline =~ s|Washington/Georgetown|Wash DC /Georgetown|;
$myline =~ s|Roslyn/Long Island|Roslyn /Long Island|;
$myline =~ s|(North) San Antonio|N. San Antonio|;
$myline =~ s|Millerville/Lancaster|Millerville /Lancaster|;
$myline =~ s|Los Angeles/Hollywood|Los Angeles /Hollywood|;
$myline =~ s|March-|Mar |;
$myline =~ s|June-|Jun |;
$myline =~ s|North.Island/UK|North Island/UK|;
$myline =~ s|/UK| /UK|;
$myline =~ s|middle/late|middle /late|;
$myline =~ s|1963/1964|1963 /1964|;
$myline =~ s/notes$/notes<\/b>/;
$myline =~ s/\|\|\|\|\|\|\|\|\|\|\|/<TR><TD COLSPAN=13><HR COLOR=green><\/TD><\/TR>/; 
$myline =~ s/\|/<\/TD><TD>/g;
$myline =~ s/^/<TR BGCOLOR=$bgcolor><TD>/;
$myline =~ s/$/<\/TD><\/TR>/;
print STDERR "year:$yr ";

close CONT;
if ($yr =~ /194|195|196|197/) {
  $contents = "./tvz60s70s.html";
}
elsif ($yr =~ /198/) {
  $contents = "./tvz80s.html";
}
elsif ($yr =~ /199/) {
  $contents = "./tvz90s.html";
}
else { # leave the same
# $contents = "./tvzmisc.html";
}
print STDERR "$contents \n";
open(CONT, ">> $contents") or die "cant open $contents: $!";

#print CONT "$_\n";
print CONT "$myline\n";

# check and print features if 1st time date match 
unless (defined $date_done{$date}) {
next unless (defined $any{$date}); 
#print CONT "<TR><TD COLSPAN=12>found:$any{$date} items</TD></TR>";
print CONT "<TR><TD COLSPAN=13>";
  #insert articles that may be pictures with thumbnails or just .txt or .html etc
  if (-f "$articles/$artst{$date}") {
    print CONT " article(s): <A HREF=\"$articles/$arts{$date}\" target=\"_articles\"><IMG SRC=\"$articles/$artst{$date}\" width=$twidth></A>";
    }
  elsif (-f "$articles/$arts{$date}") {
     my $displ = $arts{$date};
     $displ =~ s/_/ /g;
     print CONT "article(s): <A HREF=\"$articles/$arts{$date}\" target=\"_articles\">$displ</A>";
    }
  #print CONT "article(s): <A HREF=\"$articles/$arts{$date}\" target=\"_articles\">$arts{$date}</A>" if -f "$articles/$arts{$date}";
#  print CONT " setlist: <A HREF=\"$setlists/$sets{$date}\" target=\"_setlists\">$sets{$date}</A>\n" if -f "$setlists/$sets{$date}";
if (-f "$setlists/$sets{$date}") {
   my $displ = $sets{$date};
   $displ =~ s/_/ /g;
   print CONT " setlist: <A HREF=\"$setlists/$sets{$date}\" target=\"_setlists\">$displ</A>\n" 
}
  # add pictures
  print CONT " pic(s): <A HREF=\"$pictures/$pics{$date}\" target=\"_pictures\"><IMG SRC=\"$pictures/$picst{$date}\" width=$twidth></A>" if -f "$pictures/$pics{$date}";
  if (-f "$pictures/$pics{$dateb}") {
    print CONT "2: <A HREF=\"$pictures/$pics{$dateb}\" target=\"_pictures\"><IMG SRC=\"$pictures/$picst{$dateb}\" width=$twidth></A>";
  }
  if (-f "$pictures/$pics{$datec}") {
    print CONT "3: <A HREF=\"$pictures/$pics{$datec}\" target=\"_pictures\"><IMG SRC=\"$pictures/$picst{$datec}\" width=$twidth></A>";
  }
  if (-f "$pictures/$pics{$dated}") {
    print CONT "4: <A HREF=\"$pictures/$pics{$dated}\" target=\"_pictures\"><IMG SRC=\"$pictures/$picst{$dated}\" width=$twidth></A>";
  }
  if (-f "$pictures/$pics{$datee}") {
    print CONT "5: <A HREF=\"$pictures/$pics{$datee}\" target=\"_pictures\"><IMG SRC=\"$pictures/$picst{$datee}\" width=$twidth></A>";
  }


  # add gig pictures
  print CONT " gig pic(s): <A HREF=\"$gpictures/$gpics{$date}\" target=\"_pictures\"><IMG SRC=\"$gpictures/$gpicst{$date}\" width=$twidth></A>" if -f "$gpictures/$gpics{$date}";

  if (-f "$gpictures/$gpics{$dateb}") {
    print CONT "2: <A HREF=\"$gpictures/$gpics{$dateb}\" target=\"_pictures\"><IMG SRC=\"$gpictures/$gpicst{$dateb}\" width=$twidth></A>";
  }
  if (-f "$gpictures/$gpics{$datec}") {
    print CONT "3: <A HREF=\"$gpictures/$gpics{$datec}\" target=\"_pictures\"><IMG SRC=\"$gpictures/$gpicst{$datec}\" width=$twidth></A>";
  }
  if (-f "$gpictures/$gpics{$dated}") {
    print CONT "4: <A HREF=\"$gpictures/$gpics{$dated}\" target=\"_pictures\"><IMG SRC=\"$gpictures/$gpicst{$dated}\" width=$twidth></A>";
  }
  if (-f "$gpictures/$gpics{$datee}") {
    print CONT "5: <A HREF=\"$gpictures/$gpics{$datee}\" target=\"_pictures\"><IMG SRC=\"$gpictures/$gpicst{$datee}\" width=$twidth></A>";
  }


  # add gig posters
    print CONT "\nposter/ad.: <A HREF=\"$posters/$poss{$date}\" target=\"_pictures\"><IMG SRC=\"$posters/$posst{$date}\" width=$pwidth></A>" if -f "$posters/$poss{$date}";

  if (-f "$posters/$poss{$dateb}") {
    print CONT "2: <A HREF=\"$posters/$poss{$dateb}\" target=\"_pictures\"><IMG SRC=\"$posters/$posst{$dateb}\" width=$pwidth></A>";
  }
  if (-f "$posters/$poss{$datec}") {
    print CONT "3: <A HREF=\"$posters/$poss{$datec}\" target=\"_pictures\"><IMG SRC=\"$posters/$posst{$datec}\" width=$pwidth></A>";
  }
  if (-f "$posters/$poss{$dated}") {
    print CONT "4: <A HREF=\"$posters/$poss{$dated}\" target=\"_pictures\"><IMG SRC=\"$posters/$posst{$dated}\" width=$pwidth></A>";
  }
  if (-f "$posters/$poss{$datee}") {
    print CONT "5: <A HREF=\"$posters/$poss{$datee}\" target=\"_pictures\"><IMG SRC=\"$posters/$posst{$datee}\" width=$pwidth></A>";
  }


# add other content
  print CONT " other: <A HREF=\"$others/$oth{$date}\" target=\"_pictures\"><IMG SRC=\"$others/$otht{$date}\" width=$twidth></A>" if -f "$others/$oth{$date}";

  if (-f "$others/$oth{$dateb}") {
    print CONT "2: <A HREF=\"$others/$oth{$dateb}\" target=\"_pictures\"><IMG SRC=\"$others/$otht{$dateb}\" width=$twidth></A>";
  }
  if (-f "$others/$oth{$datec}") {
    print CONT "3: <A HREF=\"$others/$oth{$datec}\" target=\"_pictures\"><IMG SRC=\"$others/$otht{$datec}\" width=$twidth></A>";
  }
  if (-f "$others/$oth{$dated}") {
    print CONT "4: <A HREF=\"$others/$oth{$dated}\" target=\"_pictures\"><IMG SRC=\"$others/$otht{$dated}\" width=$twidth></A>";
  }
  if (-f "$others/$oth{$datee}") {
    print CONT "5: <A HREF=\"$others/$oth{$datee}\" target=\"_pictures\"><IMG SRC=\"$others/$otht{$datee}\" width=$twidth></A>";
  }

#print CONT "$any{$date} items<HR WIDTH=900 COLOR=grey></TD></TR>";
#  }

print CONT "$any{$date} items<HR WIDTH=900 COLOR=grey></TD></TR>";
$date_done{$date} = 1; # OK mark this date as done

}

print CONT "\n"; 

}
else {
print CONT "$_\n";
}
#close CONT;
} # this is main loop


my $contents = "./tvz60s70s.html";
open(CONT, ">> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
</TABLE>
<H4>Jump to Townes in the <A HREF=tvz80s.html>1980s</A> or <A HREF=tvz90s.html>1990s</A></H4>
<H4>Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
</body>
</html>
EOF
close(CONT);

my $contents = "./tvz80s.html";
open(CONT, ">> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
</TABLE>
<H4>Jump to Townes in the <A HREF=tvz60s70s.html>1940s-70s</A> or <A HREF=tvz90s.html>1990s</A></H4>
<H4>Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
</body>
</html>
EOF
close(CONT);

my $contents = "./tvz90s.html";
open(CONT, ">> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
</TABLE>
<H4>Jump to Townes in the <A HREF=tvz60s70s.html>1940s-70s</A> or <A HREF=tvz80s.html>1980s</A></H4>
<H4>Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
</body>
</html>
EOF
close(CONT);

my $contents = "./tvzmisc.html";
open(CONT, ">> $contents") or die "cant open $contents: $!";
print CONT <<EOF;
</TABLE>
<H4>Jump to Townes in the <A HREF=tvz60s70s.html>1940s-70s</A> or <A HREF=tvz90s.html>1990s</A></H4>
<H4>Back to <A HREF=/coopl/tvzindex.html>Blue Sky Home Page</A></H4>
</body>
</html>
EOF
close(CONT);

close(MDB);

