$TYPE  = "\U$ARGV[0]";
$type = "\L$TYPE";

$SERVER_HOME = $ENV{SERVER_HOME}; 
$SERVER_NAME = $ENV{SERVER_NAME};
$BASE_HREF   = $ENV{SERVER_WWW_URL}; 
$BACKGROUND  = $ENV{BACKGROUND};

chdir("$ENV{SERVER_SOLVERS}/$TYPE");
chop($TITLE = `cat TITLE`);

#
# section to determine whether a kestrel link
# on the solver web page is appropriate
# - not really necessary to world peace
#

if($ENV{"KESTREL_INSTALL"}) {
  $GROUP = "";
  if(open(IN, "GROUP")) {
    chomp($GROUP = <IN>);
    close IN;
  }
  $GROUP =~ s/\s//g;
  $ACCEPTS = "";
  if(open(IN, "ACCEPTS")) {
    chomp($ACCEPTS = <IN>);
    close IN;
  }
  $KESTREL_LINK = 0;
  if($GROUP =~ /\S/ and $ACCEPTS =~ /\S/) {
    @kestrels = glob("../KESTREL_*/GROUP");
    foreach $kgroup (@kestrels) {
      if($kgroup =~ m#KESTREL_(.+?):#) {
         $input = $1;
       } else {
         next;
       }
      if($ACCEPTS !~ /$input/i) {
        next;
      }
      $kestrelgroup = "";
      if(open(IN, "$kgroup")) {
        chomp($kestrelgroup = <IN>);
        close IN;
      }
      $kestrelgroup =~ s/\s//g;
      if($kestrelgroup eq $GROUP) {
        $KESTREL_LINK = 1;
        last;
      }
    }
  }
}

#
# html header
#

print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE> $SERVER_NAME Server: $TITLE</TITLE>\n";
print "<META name=\"description\" 
       content=\"$SERVER_NAME Server: $TITLE \">\n";
print "<META name=\"keywords\" 
       content=\"$TITLE, $SERVER_NAME Server, optimization,
       algorithms, software, problem solving environments\">\n";
print "<BASE HREF=\"$BASE_HREF\/\">\n";
print "</HEAD>\n";
print "<BODY $BACKGROUND >\n";
print "<table border=0 width=100% cellspacing=0 cellpadding=0>\n";
print "<tr><td></td><td width=100%></td><td></td>\n";
print "<tr valign=top><td align=left>\n";

# Icon and Title

print "<A href=\"\"><IMG border=0 SRC=\"images/globe_small.jpg\" alt=\"NEOS Server Home\" valign=top></a>\n";

print "</td><td align=right colspan=2>\n";

if (-f "about.url") {
  chop($ABOUT_URL = `cat about.url`);
  $ABOUT_URL =~ s/\s//g;
}

print "<table cellpadding=5 cellspacing=1 border=2>\n";
print "<tr align=left valign=top>\n<td>\n<h3>NEOS Interfaces to $TITLE</h3>\n";
print "\n";
print "<a href=\"solvers/$TYPE/solver-www.html\">\n";
print "<b>WWW Form</b></a>\n";

if(!($TYPE =~ m/^ADMIN/))
{ 
    print " &amp; <a href=\"solvers/$TYPE/solver-sample.html\"><b>Sample Submissions</b></a>\n";
}
 
print "<br>\n";
if ($ENV{SERVER_EMAIL_READY}) {
  print "<a href=\"solvers/$TYPE/solver-email.html\">\n";
  print "<b>E-mail</b></a>\n";
  print "\n<br>\n"; 
}
print "<a href=\"server-submit.html\">\n"; 
print "<b>Submission Tool</b></a>\n"; 

if($ENV{"KESTREL_INSTALL"}) {
  if($KESTREL_LINK==1) {
    print " or ";
    print "<a href=\"kestrel.html\">\n";
    print "<b>Kestrel Client</b></a>\n";
  }
}
print "</td></tr></table>\n</td>\n<tr valign=bottom>\n";

print "<td align=left colspan=2>\n<br><p>\n";
if (length($ABOUT_URL)){			   
    print"<a href=\"$ABOUT_URL\"><h1>$TITLE</h1></a>";
} else {
    print "<h1>$TITLE</h1>";
}
print "\n</td><td align=right>\n";
print "</td></tr></table>\n\n";
print "<br clear=all><p><br>\n";

if (-f "abstract") {
    $ABSTRACT = `cat abstract`;
} else {		      
  print "<center>\n";
  print "<IMG vspace=10 SRC=\"images/construction2.gif\">\n";
  print "<P>$TITLE is still under construction.";
  print "</center>\n";
  print "<br><br>"
}

print "$ABSTRACT\n";

print "<br clear=all>\n<p><hr><center>\n";
print "<a href=\"solvers/$TYPE/solver-comment.html\">";
print "<img border=0 src=images/comments.jpg alt=\"Comments\"></a>\n";
if(length($ABOUT_URL)){
    print "<br><a href=\"$ABOUT_URL\"><img border=0 src=\"images/background.jpg\" alt=\"Background Information\"></a>\n";
}       
print "<br><a href=\"\"><img border=0 hspace=40 src=\"images/neos_home.jpg\" alt=\"$ENV{SERVER_NAME} Server Home\"></a>\n";
print "</center><p>\n";

print "\n\n</BODY>\n";
print "</HTML>\n";


