<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate vo2max from a mile jog  -->
<!-- Required by: vo2mile.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function calculate()
{
  var gender = document.vo2.gender.options[document.vo2.gender.selectedIndex].value;
  var wtunits = document.vo2.wtunits.options[document.vo2.wtunits.selectedIndex].value;
  var weight = document.vo2.weight.value;
  var time = document.vo2.time.value;
  var bpm = document.vo2.bpm.value;

  if (wtunits == "pounds")
    {
      weight /= 2.205;
    }

  v1 = 100.5;

  if (gender == "male")
    {
      v1 = 108.844;
    }

  r1 = v1 - (0.1636*weight) - (1.438*time) - (0.1928*bpm);

  document.vo2.r1.value = nt2dp(r1,2);
}

function valclear()
{
  document.vo2.r1.value = "";
}

function nt2dp(num,dp)
{
<!-- rounds num to dp decimal places -->
  num=num*1+(0.55/Math.pow(10,dp));
  if (dp>0) dp=dp+1;
  b=Math.floor(num).toString().length+dp;
  return num.toString().substr(0,b);
}