<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate the results from the Rockport test -->
<!-- Required by: rockport.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function vo2maxcalculate()
{
  var weight = document.vo2max.weight.value;
  var age = document.vo2max.age.value;
  var mins = document.vo2max.mins.value;
  var secs = document.vo2max.secs.value;
  var units = document.vo2max.units.options[document.vo2max.units.selectedIndex].value
  var sex = document.vo2max.sex.options[document.vo2max.sex.selectedIndex].value
  var bpm = document.vo2max.bpm.value;

  //convert weight in kgs to lbs
  if (units=='kgs')
    {
      weight = weight * 2.205;
    }

  //convert mins/secs to mins and 100ths of mins
  tm = eval(mins);
  ts = eval(secs/60);
  time = tm + ts;

  //If male set mf =1 else set mf=0
  mf = 0;
  if (sex == 'Male')
    {
      mf = 1;
    } 

  var vo2 = 132.853-(0.0769*weight)-(0.3877*age)+(6.3150*mf)-(3.2649*time)-(0.1565*bpm);

  document.vo2max.vo2.value = nt2dp(vo2,2);
}

function vo2clear()
{
  document.vo2max.vo2.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);
}