<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate the results from the Harvard step test -->
<!-- Required by: havard.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function vo2maxcalculate()

{
var sex = document.vo2max.sex.options[document.vo2max.sex.selectedIndex].value;
var p1 = eval(document.vo2max.p1.value);
var p2 = eval(document.vo2max.p2.value);
var p3 = eval(document.vo2max.p3.value);

dif=30000/(p1+p2+p3);
document.vo2max.p4.value = nt2dp(dif,0);
document.vo2max.status.value = 'Poor';

if (sex == "Male")
 {
	if (dif>=55) document.vo2max.status.value = 'Below Average';
	if (dif>=65) document.vo2max.status.value = 'Average';
	if (dif>=80) document.vo2max.status.value = 'Above Average';
	if (dif> 90) document.vo2max.status.value = 'Excellent';
 }
else
 {
	if (dif>=50) document.vo2max.status.value = 'Below Average';
	if (dif>=61) document.vo2max.status.value = 'Average';
	if (dif>=76) document.vo2max.status.value = 'Above Average';
	if (dif> 86) document.vo2max.status.value = 'Excellent';
 }

}
 
function vo2clear()

{
  document.vo2max.status.value = "";
  document.vo2max.p4.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);
}
