#!/usr/local/bin/perl5

if ($ENV{QUERY_STRING}=~ /name=(Sounds|Cannons|Bodies|Donalds)/) {
   $search= $1;
} else {
  print("Location: index.cgi\n\n");
  exit(0);
}
$new= $ENV{QUERY_STRING}=~ /newjoin/;

if ($search eq "Sounds") {
    if ($new) {
	$desc= "Welcome to the Giant Sucking Sounds!";
    } else {
	$desc="Now here's the deal:";
    }
} elsif ($search eq "Cannons") {
    if ($new) {
	$desc= "Welcome to the Loose Cannons!";
    } else {
	$desc="Don't you dare tell us to shut up!";
    }
} elsif ($search eq "Bodies") {
    if ($new) {
	$desc= "Welcome to the Bodies!";
    } else {
	$desc="What're you lookin' at?";
    }
} elsif ($search eq "Donalds") {
    if ($new) {
	$desc= "Welcome to the Donalds!";
    } else {
	$desc="We've already put our down payment on the White House.";
   }
}

open(POP, "people");

$count= 1;
$list= "";

while (<POP>) {
    ($name, $email, $effort, $team, $img, $haiku)= split(/\#\#\#/);
    if ($team eq $search) {
	$haiku=~ s!///!<br>!g;
	$list.= "<tr>\n<td align=center>";
	if ($img ne "") {
	    $list.= "<a href=\"$img\"><img src=\"$img\" height=70 border=0></a>";
	} else {
	    $list.= "<img src=\"images/unknown.jpg\" width=70 height=70>";
	}
	$list.= "</td>\n";
	$list.= "<td><font size=+1><a href=\"mailto:$email\">$name</a></font></td>\n";
	$list.="<td>$haiku</td>";
	$list.="</tr>\n";
	$count++;
    }
}

$podium= $count*75-160;
$podium= 0 if ($podium<0);

print <<EOF;
Content-type: text/html

<html>
<head>
<title>Campaign Roster</title>
</head>
<body bgcolor=#ffffff>
<font face="Comic Sans MS">
<table cellspacing=5 border=0>
<tr><td rowspan=$count><img src=images/$search.gif width=122 height=171><br><img src=images/podcol.gif width=122 height=$podium><br><img src=images/podbot.gif width=122 height=5></td>
<td colspan=3><font size=+2><b>$desc</b></font></td></tr>
$list
<tr><td></td><td></td>
<td>
<a href=index.cgi><img src=images/homesm.jpg width=50 height=50 border=0></a>
</td></tr>
</table>
</font>
</body>
</html>
EOF
    ;
