#!/usr/local/bin/perl -w

#This program creates an html file for browse plots

# DOES NOT YET WORK!!!!!!

$input_file = $ARGV[0];
#open (IN,"$input_file") || die "can't open input file";

$output_file = $input_file . ".html";
open (OUT,">$output_file") || die "can't create output file '$output_file'";


print OUT"<HTML>\n";
print OUT"<HEAD>\n";
print OUT"<TITLE>\n";
print OUT"ACE SEPICA Browse\n";
print OUT"</TITLE>\n";
print OUT"</HEAD>\n";
print OUT"<BODY TEXT=\"#FFFFFF\" BGCOLOR=\"#000000\" LINK=\"#00EE00\" VLINK=\"#EE0000\" ALINK=\"#0000FF\" BACKGROUND=\"../images/ace12.jpg\">\n";
print OUT"<A NAME=\"xxx\"></A>\n";
print OUT"<A HREF=\"brws_grphs.html\"><IMG SRC=\"../images/brws_grph_elemt_tn.gif\" ALT=\"Shaded Graphs\" BORDER=1  ALIGN=RIGHT></A>\n";
print OUT"<CENTER>\n";
print OUT"<FONT SIZE=+1><A HREF=\"uleis_brws_plts.html\">ULEIS</A></FONT>\n";
&add_wht_space(2);
print OUT"<FONT SIZE=+1><A HREF=\"epam_brws_plts.html\">EPAM</A></FONT>\n";
&add_wht_space(2);
print OUT"<FONT SIZE=+1><A HREF=\"sep_brws_plts.html\">SEPICA</A></FONT>\n";
&add_wht_space(2);
print OUT"<FONT SIZE=+1><A HREF=\"sis_brws_plts.html\">SIS</A></FONT>\n";
&add_wht_space(2);
print OUT"<FONT SIZE=+1><A HREF=\"cris_brws_plts.html\">CRIS</A></FONT>\n";
&add_wht_space(2);
print OUT"</CENTER>\n";
print OUT"<HR SIZE=4 WIDTH=\"100%\">\n<P>\n<CENTER>\n";
print OUT"<B><FONT SIZE=+2>xxx</FONT></B>\n";
print OUT"</CENTER>\n";
print OUT"<DIV align=right><A HREF=\"print_info.html\">Print Info</A></DIV>\n<HR SIZE=2 WIDTH=\"30%\">\n";

print OUT"\n<BLOCKQUOTE>\n";
print OUT"<FONT COLOR=\"#66FFFF\">\n";
$ii=0;
while (1){
  print"enter element. enter Q or q to quit.\n";
  $input = <STDIN>;
  if ($input =~ /q/i){
    last;
  }elsif ($input =~ /=/){
    $element[$ii] = $element[$ii-1];
    $abrev[$ii] = $abrev[$ii-1];

    print"enter beginning range\n";
    $start[$ii] = <STDIN>;
    print"enter ending range\n";
    $end[$ii] = <STDIN>;
  }else{
    $element[$ii] = $input;
    print"enter element abreviation.\n";
    $abrev[$ii] = <STDIN>;

    print"enter beginning range\n";
    $start[$ii] = <STDIN>;
    print"enter ending range\n";
    $end[$ii] = <STDIN>;
    chop($element[$ii]);
    chop($abrev[$ii]);
  }
  chop($start[$ii]);
  chop($end[$ii]);
  $ii++;
}
$jj=0;
while ( $jj < $ii){
  print "$element[$jj]  $abrev[$jj]\n";
  print "      $start[$jj] - $end[$jj]\n";

  $jj++;
}
print OUT"\n";
print OUT"\n";
print OUT"\n";
print OUT"\n";
print OUT"\n";
print OUT"\n";
print OUT"\n";




print OUT"</BODY>\n</HTML>\n";
close (OUT);
#close (IN);
print "\nFINI\n";

#----------- subroutine: add white space ----------------#
sub add_wht_space
{
	#put subroutine arguments into subroutine variables
  ($spaces) = @_;
  if ($spaces == 0){
    $spaces = 1;
  }

  for ($ii=0; $ii<$spaces; $ii++){
     print OUT" &nbsp; ";
  }
  print OUT"\n";
}
