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


#
# html header
#

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

chdir("$ENV{SERVER_SOLVERS}/$TYPE");

print "<HTML>\n";

# Title of Form

chop($TITLE = `cat TITLE`);
print "<HEAD>\n";
print "<BASE HREF = \"$BASE_HREF\/\">\n";
print "<TITLE> $TITLE  Sample Submissions </TITLE>\n";
print "<META name=\"description\" 
       content=\"$SERVER_NAME Server: $TITLE Sample Submissions Form\">\n";
print "<META name=\"keywords\" 
       content=\"$TITLE, $SERVER_NAME Server, optimization, 
       algorithms, software, problem solving environments\">\n";
print "</HEAD>\n";
print "<BODY $BACKGROUND >\n";
print  "<A HREF=\"\"><IMG align=left border=0 SRC=\"images/globe_small.jpg\" alt=\"NEOS Server Home\"></A>\n";
print "<P><P><CENTER>\n<H1>Sample Submissions<p>$TITLE</H1>\n</CENTER>\n";
print "<br clear=left>\n";
print "<br><hr><br>\n";

#
# Read in config file and generate entries
#

print "<FORM METHOD=\"POST\" ACTION=\"$POST/$TYPE/nph-solver-sample.cgi\">\n";

if (-s "trial_config") {
  print "Select one of the following problems to submit to $TITLE.  The job results will be displayed on your browser.  The tokens to delimit files as shown in the sample submissions are inserted automatically when using the Web or Submission Tool interfaces.";
  print "<ul>\n";
  open(handle, "trial_config");
  $TABLE = 0;
  $FLAG = 1; 
  print "<TABLE  border=0>\n";
  while (<handle>) {
    next unless (/\S+/);
    if (/<COLUMNS (\d+)>/i) {
      $TABLE = 1;
      print "<TABLE BORDER>\n";
      print "<TR>";
      $columns = $1;
      for ($i=0;$i<$columns;$i++) {
        chomp($title = <handle>);
        print "<TH>$title</TH>";
      }
      print "</TR>\n";
    } elsif ($TABLE) {
      chomp;
      print "<TR><TD align=center>$_</TD>\n";
      for ($i=1;$i<$columns;$i++) {
        chomp($URL = <handle>);
	if ($URL =~ /<NULL>/i) {
          print "<TD> </TD>\n";
	} elsif ($FLAG) {
          print "<TD align=center><INPUT TYPE=radio NAME=field.1 VALUE=\"$URL\" CHECKED></TD>\n";
	  $FLAG = 0;
        } else {
          print "<TD align=center><INPUT TYPE=radio NAME=field.1 VALUE=\"$URL\"></TD>\n";
	}
      }
      print "</TR>\n";
    } else {
      chomp($URL = <handle>);
      if ($FLAG) {
        print "<TR><TD><INPUT TYPE=radio NAME=field.1 VALUE=\"$URL\" CHECKED>\n";
	$FLAG = 0;
      } else {
        print "<TR><TD><INPUT TYPE=radio NAME=field.1 VALUE=\"$URL\">\n";
      }
      print "$_</TD></TR>\n";
    }
  }
  if($TABLE)
  {
      print "</TABLE>\n";
  } 
  print "</TABLE>\n";
  close(handle);
  print "</ul>\n";
  print "<hr><P>\n";
  print "Enter your e-mail address if you would like a copy of the 
  sample submission and job results mailed to you.<P>";
  print "<center>\n";
  print "<table cols=2><tr><td colspan=2 align=center>";
  print "e-mail address:<BR> <INPUT TEXT NAME=field.0 size=36\"><P></td>\n</tr><tr><td align=right>";
  print "<INPUT TYPE=\"submit\" VALUE=\"Submit to $SERVER_NAME\">";  
  print "</td><td align=left>";
  print "<INPUT TYPE=\"reset\" VALUE=\"Clear this Form\">\n";  
  print "</td></tr></table>\n";
  print "</center>\n";
} else {
  print "<center>\n";
  print "<IMG vspace=10 SRC=\"images/construction2.gif\">\n";
  print "<P>$TITLE is still under construction.";
  print "</center>\n";
}

print "<hr>\n";
print "<center><a href = \"\" ><img src=\"images/neos_home.jpg\" border=0 alt=\"$SERVER_NAME Server Home\" hspace=40></a>\n<br>\n";
print "<a href=\"solvers/$TYPE/solver-comment.html\">\n";
print "<img border=0 src=images/comments.jpg></a>\n";
print "</center><p>\n";

#
# end html
#

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

