#!/usr/bin/perl
print "Content-type: text/html\n\n";

print qq!<html><head><title>The Woburn Story---Results</title></head>
<body bgcolor="#FFFFFF">!;

open(FILE,"/auto/inetpub/wwwroot/evidence99/woburn/data/hydrono") or die "Couldn't open file for reading: $!";
$hydrono=int(<FILE>);
close(FILE);

open(FILE,"/auto/inetpub/wwwroot/evidence99/woburn/data/hydroyes") or die "Couldn't open file for reading: $!";
$hydroyes=int(<FILE>);
close(FILE);

open(FILE,"/auto/inetpub/wwwroot/evidence99/woburn/data/leukemiano") or die "Couldn't open file for reading: $!";
$leukemiano=int(<FILE>);
close(FILE);

open(FILE,"/auto/inetpub/wwwroot/evidence99/woburn/data/leukemiayes") or die "Couldn't open file for reading: $!";
$leukemiayes=int(<FILE>);
close(FILE);

open(FILE,"/auto/inetpub/wwwroot/evidence99/woburn/data/bothno") or die "Couldn't open file for reading: $!";
$bothno=int(<FILE>);
close(FILE);

open(FILE,"/auto/inetpub/wwwroot/evidence99/woburn/data/bothyes") or die "Couldn't open file for reading: $!";
$bothyes=int(<FILE>);
close(FILE);

$hydro=$hydroyes+$hydrono;
$both=$bothyes+$bothno;


if ($hydro > 0) {
    $avg_hydro = int(($hydroyes / $hydro)*100);
} else {
    $avg_hydro = 0;
}

if ($hydro > 0) {
    $avg_leukemia = int(($leukemiayes / $hydro)*100);
} else {
    $avg_leukemia = 0;
}

if ($both > 0) {
    $avg_both = int(($bothyes / $both)*100);
} else {
    $avg_both = 0;
}



print qq!<h1 align="center">Results</h1>
<p align="center"><font size="+2"><b>Percent of Juries Finding for the Plaintiffs</b></font></p>
<table width="50%" border="0" align="center">
  <tr> 
    <td width="63%">&nbsp;</td>
    <td width="37%">&nbsp;</td>
  </tr>
  <tr> 
    <td width="63%"><font size="+2"><u>Bifurcated Trial</u></font></td>
    <td width="37%"> 
      <div align="center"><font size="+2"><b>$avg_leukemia% </b><sup>a</sup></font></div>
    </td>
  </tr>
  <tr> 
    <td width="63%"><font size="+2"><u>Non-Bifurcated Trial</u></font></td>
    <td width="37%"> 
      <div align="center"><font size="+2"><b>$avg_both% </b><sup>b</sup></font></div>
    </td>
  </tr>
  <tr> 
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="2"> 
      <div align="left"> 
        <p><sup><b>a</b></sup> <font size="-2">When the trial was bifurcated, 
          $hydroyes of $hydro juries ($avg_hydro%) found that W.R. Grace polluted Wells G and H, and 
          $leukemiayes of those $hydro juries ($avg_leukemia%) found that Wells G and H caused leukemia 
          in Woburn.</font></p>
        <p><sup><b>b</b></sup> <font size="-2">When the trial was not bifurcated, 
          $bothyes of $both juries ($avg_both%) found that W.R. Grace caused leukemia in Woburn.</font></p>
      </div>
    </td>
  </tr>
</table>

<p align="right"><font size="+2"><a href="polyfurcation-for.html">Next</a></font></p>
</body>
</html>!;

sub dienice {
   ($msg) = @_;
   print "<h2>Error</h2>\n";
   print $msg;
   exit;
}

