#!/bin/perl
open (LIST, "liste.txt") or die "dett gjekk ikkje";	
$count=0;
open (LIST2, ">liste2.txt");	
while (<LIST>)
{
    $linje = $_; 
    $linje =~ /^([^\.].*)\./;
    print LIST2 "$1\n";
}
close (LIST);
close (LIST2);
open (LISTE, "liste2.txt");
$teller=0;
while ($line = <LISTE>)
{
    $teller++;
    $tellerfram = $teller+1;
    $tellertilbake = $teller-1;
    chop($line);
    $filnavn = $line . ".html";
    $bildenavn = $line . ".jpg";
    $tittel = $line;
    if ($tellerfram < 10)
    {
	$fram = "img000" . $tellerfram . ".html";
    }
    elsif ($tellerfram < 100)
    {
	$fram = "img00" . $tellerfram . ".html";	
    }
    else
    {
	$fram = "img0" . $tellerfram . ".html";    
    }
    if ($tellertilbake < 10)
    {
	$tilbake = "img000" . $tellertilbake . ".html";
    }
    elsif ($tellertilbake < 100)
    {
	$tilbake = "img00" . $tellertilbake . ".html";	
    }
    else
    {
	$tilbake = "img0" . $tellertilbake . ".html";    
    }
    print "$fram\n";
    print "$tilbake\n";
    open (NYFIL, ">$filnavn");
    print NYFIL "<html>\n";
    print NYFIL "<head>\n";
    print NYFIL "<title>\n";
    print NYFIL "$tittel\n";
    print NYFIL "</title>\n";
    print NYFIL "</head>\n";
    print NYFIL "<body bgcolor=\"#ffffff\">\n";
    print NYFIL "<table width=528 border=0 cellpadding=5>\n";
    print NYFIL "<tr valign=\"top\">\n";
    print NYFIL "<td align=\"left\">\n";
    print NYFIL "<a href=\"../../\"><img src=\"/sys/almashriq-levant-small.gif\" border=0></a>\n";
    print NYFIL "</td>\n";
    print NYFIL "<td align=\"right\">\n";
    print NYFIL "<font size=\"-1\">[<a href=\"$tilbake\">Prev</a>] [<a href=\"index.html\">Main</a>] [<a href=\"$fram\">Next</a>]</font>\n";
    print NYFIL "</td>\n";
    print NYFIL "</tr>\n";
    print NYFIL "</table>\n";
    print NYFIL "<br>\n";
    print NYFIL "<table width=528>\n";
    print NYFIL "<tr><td align=\"left\">\n";
    print NYFIL "<a href=\"index.html\"><img src=\"$bildenavn\" border=0></a>\n";
    print NYFIL "<font size=-2> \&copy;Borre Ludvigsen, 1995</font>\n";
    print NYFIL "</td></tr>\n";
    print NYFIL "</table>\n";
    print NYFIL "<table width=528>\n";
    print NYFIL "<tr><td align=\"center\">\n";
#Her legges bildeteksten inn
    open (BILDELISTE, "bildetitler.txt");
    while ($bildeline = <BILDELISTE>)
    {
	if ( $bildeline =~ /^$line\=(.*)/ )
	{
	    print "$1";
	    print NYFIL "$1";
	}
    }
    close (BILDELISTE);
    print NYFIL "<p>\n";
    print NYFIL "<a href=\"/\"><img src=\"/sys/almashriq-bottom-line.gif\" alt=\"----------------\" border=\"0\"></a>\n";
    print NYFIL "<p>\n";
    print NYFIL "<a href=\"/base/mailpage.html\">al\@mashriq</a>\n";
    print NYFIL "<p>\n";
    print NYFIL "<font size=-1>960604</font>\n";
    print NYFIL "</td></tr>\n";
    print NYFIL "</table>\n";
    print NYFIL "</body>\n";
    print NYFIL "</html>\n";
    close (NYFIL);
}
close (LISTE);
