#!/usr/local/bin/perl 
my $INCLUDE_HEADER=($ENV{'DOCUMENT_ROOT'}||"/home/httpd/html");
require "/home/sites/site3/lokad/header1.inc";
print "International Axis and Allies Players Association Playerpool</i></H1>
</center>";
use CGI;
$q=new  CGI;
$parent=$q->param('parent');
print "<BR>
	<A HREF=/cgi-local/axis/players.cgi>
		Join / leave the playerpool</A><br><br>";
print "<H3>Current RANK = $parent</H3><br>";
print "Click on the rank of Members in the Playerpool you wish to see<br><BR>";
if ($parent eq "All"){$qParent = "%";}
else {
if ($parent eq ""){$qParent ="%";}
else {$qParent = $parent;}} 
print "Ranks ";
@ranks=('GEN****','GEN***','GEN**','GEN*','MAJ','COL','CPT','LT','MSGT','SGT','CPL','PVT','ROOKIE');
for ($i=0; $i < 14; $i++){
   printf(" <A href=\"/cgi-local/axis/Playerpool.cgi?parent=%s\"> %s </a> \n",@ranks[$i],@ranks[$i]);
}
print "<br><br><p>Note the players on the top are the one that have latest changed their player info and therefore the most likely to accept a challenge.<br><br>";
$query="select alias, emailaddress, rank, gamespl, gameswon, gamelost, playerpool, poolspeed, poolcomment  
       from players where rank like '$qParent' and playerpool = 'Y' and inactive <> 'Y' and pooldate is NOT NULL order by poolspeed, pooldate DESC, alias"; 
@speed[1] = "Cheeth";
@speed[3] = "Hound";
@speed[2] = "Wolf"; 
die "prepare\n" unless ($cursor = $dbh->prepare($query)); $cursor->execute;
print "<center><table><td>Alias <td>Speed <td>Rank<td>Record<td>Challenge<td>Comment<tr>";
while(@row = $cursor->fetchrow){
      $row[8]=~ s/NULL//g;
      $record=$row[4]."-".$row[5];
#  print("<img src=/images/folder.gif align=middle>");
printf("<td><A HREF=mailto:\"%s\"> %s</a>  <td> <b>%s</b><td> %s <td> %s <td><A HREF=\"/cgi-local/axis/Gamestart.cgi?opponent=%s&rank=%s\">Challenge<td>%s<tr>\n",
		@row[1],@row[0], @speed[@row[7]], @row[2], $record,@row[0],$parent,$row[8]);
} 
print "</table>";
print "<BR><BR>
	<A HREF=/cgi-local/axis/index.html>
		<IMG src=/images/back.gif></A>"; 
exit(0);
