#!/usr/bin/perl -w

use strict;

sub Top
{
    my ( $Opts, $Dirs ) = @_[0..1];

    my $rh = $Opts->{'raw_head'};

    if( defined( $Opts->{'css'} ) )
    {
        if( ref( $Opts->{'css'} ) ne 'ARRAY' ) 
        { $Opts->{'css'} = [ $Opts->{'css'} ]; }

        foreach my $css ( @{$Opts->{'css'}} )
        {
            $Opts->{'raw_head'} .=
                "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css\">\n";
        }
    }

    Head( $Opts );
    $Opts->{'raw_head'} = $rh;

    print "<body>\n";

    print "<table  border=0 width=\"100%\" ".
        "cellpadding=0 cellspacing=0><tr>\n";
    print "<td><b class=\"h1\">$Opts->{'title'}</b>\n";
    defined( $Opts->{ 'back' } ) and
        print "<td align=\"right\"><a href=\"$Opts->{ 'back' }\" " .
            "target = \"_parent\"><img border = 0 src=\"style/up.gif\"></a>\n";
    print "</table>\n";


#    print "  <center><h1>$Opts->{'title'}</h1></center>\n";

#    defined( $Opts->{ 'back' } ) and
#        print "  <p><a href=\"$Opts->{ 'back' }\" " .
#            "target = \"_parent\">[&lt;--]</a><p>\n";

    for( my $o = 0; $o < $#{$Dirs}; $o += 2 )
    {
        print "    <a href=\"" . HrefDir( $Opts, $Dirs, $o ) . 
            "\" target=\"mdsdir\">$Dirs->[$o]</a><br>\n";
    }

#      if( $Opts->{'offline'} )
#      {
#          for( my $o = 0; $o < $#{$Dirs}; $o += 2 )
#          {
#              print "    <a href=\"$Dirs->[$o]/index.html\" ".
#              "target=\"mdsdir\">$Dirs->[$o]</a><br>\n";
#          }
#      }
#      else
#      {
#          for( my $o = 0; $o < $#{$Dirs}; $o += 2 )
#          {
#              print "    <a href=\"$Opts->{'script'}?dir+" . $o/2 ."\" ".
#                  "target=\"mdsdir\">$Dirs->[$o]</a><br>\n";
#          }
#      }

    print "</body>\n</html>\n";
}

1;
