#/usr/local/bin/perl
die "usage: $0 webpagename ..\n" unless @ARGV;
$|=1;
$base_href="https://atmos.nmsu.edu/planetary_datasets";
$now=`date`;
 chomp($now);
 foreach $item(@ARGV){

   print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">
   <html>
   <head>
     <title>$item</title>
     <base href=\"$base_href/$item\">
     <meta http-equiv=\"Pragma\" content=\"no-cache\">
     <meta name=\"Creation date\" content=\"Feb 7th, 2002\">
     <meta name=\"Last update\" content=\"$now\">
     <meta name=\"Author\" content=\"\">
     <meta name=\"keywords\" content=\"Saturn, Neptune, Uranus, zonal winds, graph\">
     <meta http-equiv=\"Content-Type\" content=\"text/html\">
   </head>
   <body bgcolor=\"white\" text=\"#00000\" link=\"#007050\" vlink=\"#000080\" alink=\"maroon\">
   <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
   <td width=\"180\" align=\"left\" valign=\"top\" bgcolor=\"blue\">
    <span style=\"font-size:12.0pt;font-family:&quot;Arial&quot;;mso-fareast-font-family:&quot;Times New Roman&quot;;mso-ansi-language:EN-US;mso-fareast-language: EN-US;mso-bidi-language:AR-SA\">

   </span><p align=\"center\"><font color=\"white\">
   <!--<a href=\"../planetary_datasets/logo.jpg\"><img src=\"../planetary_datasets/logo.jpg\" v:shapes=\"_x0000_i1025\" width=\"215\" height=\"115\"></a>-->
   <a href=\"../planetary_datasets/main.html\" color=\"white\"> <strong>
<font face\"Times New Roman\" color=\"white\">Planetary Atmosphere's Datasets</font></strong></a></p>

   <hr noshade align=\"center\" size=\"5\">
   <hr noshade align=\"center\" size=\"3\" width=\"70%\">";

open(README, "perl generatebar.pl |") or die "Can't open $!\n";

while(<README>){
 $line .= $_;
 if($line ne ''){
 print $line;}
 $line = '';

}

close(README);
print "
<br>
    <br>

    </font></td>

    <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td valign=\"top\"><h1><font face=\"arial\" size=\"5\"><i>";
    $line = `more sourceinfo.txt | grep $item`;
    if($line ne '') {
       @ar = split(";", $line);
    }
    else{ 
          $line = `more sourceinfo.txt | grep default`;
          if($line ne '') {
            @ar = split(";", $line);
          }#close if
       
        }#close else
    print "<center>$ar[1]</center></i></font></h1>
    <br>
    <blockquote>
    <b>Source:</b> $ar[2], $ar[3],
    $ar[4], $ar[5], 
    $ar[6], $ar[7].</blockquote>
    <br>
    <center>
    <img src=\"../planetary_datasets/$ar[8]\" alt=\"graph\">
    <br> 

    
   <!--<a href=\"../planetary_datasets/$ar[8]\" align=\"left\">download
    graph as jpeg $ar[9] (right-click and select save link as)</a>--> 
    Download graph as jpeg $ar[9]
    <p>
    <FORM
ACTION=\"https://atmos.nmsu.edu/cgi-bin/downloadjpg?$ar[8]\"
method=\"POST\">
    <INPUT TYPE=\"submit\" VALUE=\"download\">
    </FORM>
    <a href=\"../planetary_datasets/$ar[10]\" align=\"left\">Download
    graph as post script file $ar[11]</a>
    <h3 ><bold> EXAMPLE STRUCTURE OF TEXT FILE <bold></h3>
    \n<table align=center cellpadding=4>\n";
    
    open(README, "< $ar[12]") or die "Can't open $!\n";
$i=0;
$line = '';

while(<README>){
 if($i < 12){    #print only the first 12 lines of file
   $line .= $_;
   @words = split(/\s{2,}/ ,$line);
   print "<tr>\n";
   foreach $word(@words){
     print "<td>$word</td>"; 
   }
   print "</tr>"; 
 }
 else{last;}
 $i++;
 $line = '';
}

close(README);
print "</table>
<!--<a href=\"../planetary_datasets/$ar[12]\">download file as text $ar[13] (right-click and select save link as)</a>
-->
<br>
Download file as text $ar[13] 
<FORM
ACTION=\"https://atmos.nmsu.edu/cgi-bin/downloadfile?$ar[12]\"
method=\"POST\">

<INPUT TYPE=\"submit\" VALUE=\"download\">

</center>
</td>
</table>
</body>
</html>";

} #close foreach

 
