<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate vo2max from non exercise data  -->
<!-- Required by: vo2maxnd.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function initial()
{
  q = new Array(4);

  for(i = 0; i < 4; i++)
  q[i] = 0;  
}
 
function check(form)
{
  sex = document.vo2.sex.options[document.vo2.sex.selectedIndex].value;

  weight = document.vo2.weight.value;
  height = document.vo2.height.value;
  bmi = weight / (height*height);
  
  vo2m = 44.895 + (7.042 * sex)-(0.823*bmi)+(0.688*q[1])+(0.738*((q[2]*1.0)+(q[3]*1.0)));
  
  document.vo2.vo2m.value = nt2dp(vo2m,2);
}

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);
}

initial();