#!/usr/bin/perl
#
#Copyright (C) 2003: Christian A. Bråthe
#For: Christian A. Bråthe, Jan Steinar Kvilesjø, Lars Martin Dobbe
#Minor change 2007 by Erling Strand
#

use CGI qw(:standard :escapeHTML);
 
print "Content-type: text/html\n\n";
 
#START
 
$pictureName = param("picName");
$comingFrom = param("from");
 
sub create_html_top
{
    print "<html>";
    print "<head>";
    print "<title>E.L.F.O Received picture: 
$pictureName</title>";
    print "<meta http-equiv=\"Content-Type\" content=\"text/html; 
charset=iso-8859-1\">";
    print "<link href=\"stylesheet.css\" rel=\"stylesheet\" 
type=\"text/css\">";
    print "</head>";
 
    print "<body BGCOLOR=\"#E8F6FA\">";
}

sub create_header_table
{ 
    print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    print "<tr>"; 
    print "<td width=\"57%\" class=\"header\"><b>Hessdalen AMS.<br>E.L.F.O. Picture.</b>  
</td>"; 
    print "<td width=\"43%\" class=\"header\" align=\"right\">www.hessdalen.org</td>";
    print "</tr>"; 
    print "<tr>"; 
    print "<td height=\"20\"></td>";
    print "</tr>";   
    print "</table>";
}

sub picture_table
{
    ($rest1, $rest2, $rest3, $rest4, $rest5) = split("/",$pictureName,5);
    ($hour, $minute, $second) = split("_",$rest5,4);
    ($hourly) = split(" ",$hour,2);
   if ($hourly <10) {$hourly = "0".$hourly};
    ($minutt) = split(" ",$minute,2);
   if ($minutt <10) {$minutt = "0".$minutt};
 
    ($secondly) = split(" ",$second,2);
   if ($secondly <10) {$secondly = "0".$secondly};

   ($dag, $maned, $bar) = split("_",$comingFrom,3);
   if ($dag <10) {$dag = "0".$dag};

   if ($maned <10) {$maned = "0".$maned};

 


   print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
    print "<tr>"; 
    print "<td width=\"50%\">Picture location/name: $pictureName</td>";
    print "<td>&nbsp;</td>";
    print "</tr>";
    print "<tr><td><hr></td><td>&nbsp;</td></tr>";
    print "<tr>"; 
    print "<td><img src=\"$pictureName\"></img></td>";
    
 
   print "<td valign=\"top\">";
   print "This picture is from $dag-$maned-$bar <i>(date-month-year)</i><br>"; 
   print "at $hourly : $minutt : $secondly <i>(hour : minute : second)</i><p>";
  
 print "The X-axis show the frequency. The Y-axis show the time.</td>";
     print "</tr>";
    print "</table>";

}    

sub create_footer_table
{
    print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    print "<tr>";
    print "<td height=\"20\" colspan=\"2\"></td>"; 
    print "</tr>"; 
    print "<tr><td colspan=\"2\"><hr></td></tr>";
    print "<tr>"; 
    print "<td width=\"73%\" class=\"footer\"><i>Created 2003: Christian A. Br&aring;the, Jan 
Steinar Kvilesj&oslash; and ";
    print "Lars Martin Dobbe</i></td>";
    print "<td width=\"27%\" class=\"footer\" align=\"right\"><a ";
    print "href=\"showDir1.cgi?dirName=$comingFrom\">Back to the file index</a></td>";
    print "</tr>"; 
    print "</table>";
}


create_html_top();
create_header_table();
picture_table();
create_footer_table();
