<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->

<!-- Function:  Calculate the results from the Bleep test -->

<!-- Required by: beep.htm -->

<!-- Copyright Brian Mackenzie 2004 -->


function vo2maxcalculate()

{
  tot = new Array(1,8,16,24,33,42,52,62,73,84,95,107,119,132,145,158,172,186,201,216,232,248,264);
  var shut = eval(document.vo2max.shut.value);
  var lev = eval(document.vo2max.lev.value);

  //check level not>22

  if (lev>22)
    {
      lev=22;
    }

  //check level >0

  if (lev <1)
    {
      lev = 1;
    }

  //determine total number of shuttles

  t = tot[lev-1] + shut;

  //calculate vo2 max

  vo2= 18.043461 + (0.3689295 * t) +(-0.000349 * t * t);
  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);
}