#! /running/perl.pl4
$line=$ENV{QUERY_STRING};
$line=~s/\s//g;
print "Content-type: text/html \n\n";
print <<'EOF';
<head><title>Your VO2 MAX</title></head>
<LINK REL=StyleSheet HREF="style/style.css" TYPE="text/css" TITLE="8-bit Color Style" MEDIA="screen, print">
<BODY bgcolor="#FFCC33" text="#000000" link="#000000" vlink="#FF0000" alink="#FF0000">
<CENTER><img src="runnerswebcom20.jpg" alt="Runner's Web" height="25" width="176"></CENTER>
<center><h3>Your VO2 MAX</h3></center>
EOF

if (($mi,$km,$hr,$min,$sec)=
  $line=~/mi=(.*)&km=(.*)&hr=(.*)&min=(.*)&sec=(.*)/)
{
  $meters=$mi*1609.3 + $km*1000.0;
  $minutes=$hr*60.0 + $min + $sec/60.0;
  if ($meters<0.001) {$meters=0.001;}
  if ($minutes<1.0/60.0) {$minutes=1.0/60.0;}
  $v=$meters/$minutes;
  $vo2 = -4.60 + 0.182258*$v + 0.000104*$v*$v;
  $percent_max = 0.8 + 0.1894393*exp(-0.012778*$minutes)
      + 0.2989558*exp(-0.1932605*$minutes);
  $vo2max = $vo2/$percent_max;

  print "<dl>\n";
  printf("<dt>Distance<dd><ul><li>%1.3f miles<li>%1.3f km<li>%1.0f yds</ul>\n", 
    $meters/1609.3, $meters/1000.0, $meters/0.9144);
  printf("<dt>Time<dd> %d:%02d:%02d\n", int($minutes/60.0),
    int($minutes)%60, int($minutes*60.0)%60);
  printf("<dt>Velocity<dd><ul><li>%1.3f m/s\n<li>%1.3f MPH\n",
    $v/60.0, $v*60.0/1609.3);
  printf("<li>%d:%02d per mile\n", int(1609.3/$v), int(1609.3*60/$v)%60);
  printf("<li>%d:%02d per km\n", int(1000.0/$v), int(1000.0*60/$v)%60);
  printf("</ul><dt>VO2 at this pace<dd> %1.2f ml/kg/min (%1.1f%% of max)\n", 
    $vo2, $percent_max*100.0);
  printf("<dt>VO2 MAX<dd> %1.2f ml/kg/min\n", $vo2/$percent_max);

  print "</dl>
VO2 and percent_max based on \"Jack Daniels, Conditioning for
Distance Running - The Scientific Aspects\", Wiley & Sons, 1978.
The formulas used are:
<ul>
<li> Percent_max = 0.8 + 0.1894393 * e^(-0.012778 * t)
      + 0.2989558 * e^(-0.1932605 * t)
<li> VO2 = -4.60 + 0.182258 * v + 0.000104 * v^2
<li> VO2 MAX = VO2/percent_max
</ul>
where t is the race time in minutes, and v is race velocity in
meters per minute.
<p><pre>
Maximum Oxygen Update (Max VO2) values for selected groups
and individuals are as follows:
General Population, Female, Aged 20-29: 35-43 ml/kg/min
General Population, Male, Aged  20-29: 44-51
US College Track, Male:             57.4
College Students, Male:             44.6
Highest Recorded Female (Cross-Country Skier): 74
Highest Recorded Male (Cross-Country Skier):  94
<ul>
<li>Steve Prefontaine,US runner, 84.4
<li>Frank Shorter, US Olympic Marathon winner, 71.3
<li>Ingrid Kristiansen, ex-Marathon World Record Holder, 71.2
<li>Derek Clayton, Australian ex-Marathon World Record holder, 69.7
<li>Rosa Mota, Marathon runner, 67.2
<li>Jeff Galloway, US Runner, 73.0
<li>Paula Ivan, Russian Olympic 1500M Record Holder, 71.0
<li>Jarmila Krotochvilova,Czech Olympian 400M/800M winner, 72.8
<li>Greg LeMond, professional cyclist, 92.5
<li>Matt Carpenter, Pikes Peak marathon course record holder, 92
<li>Miguel Indurain, professional cyclist, 88
</ul></pre>
";
print <<'EOF';
<CENTER>
<TABLE VALIGN=BOTTOM ALIGN=CENTER>
<TR><TD align=center>
<A HREF="vo2.shtml">|VO2 Max Calculation Form|</A>
</TD></TR>
<TR><TD align=center>
<A HREF="top_widg.html">
|Widgets Index Page|</A>
</TD></TR>
<BR><BR><BR>
</TABLE>
</CENTER> 
EOF
}
else
{
  print "Error.  Be sure to put only numbers in each field\n";
}
