<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->

<!-- Function:  Calculate the results from the  400m control tests -->

<!-- Required by: con400.htm -->

<!-- Copyright Brian Mackenzie 2004 -->


function calculate()
{
  var time150 = document.stride.time150.value;
  var time300 = document.stride.time300.value;
  var time600 = document.stride.time600.value;

  r1=time300 - (2 * time150);
  r2=time600 - (2 * time300);
  t1=-11.54156+(1.1226216*time150)+(time150*time150*-0.015101);
  t2=-0.733763+(0.2408302*time300)+(time300*time300*0.0008366);

  document.stride.r1.value = nt2dp(r1,2);
  document.stride.r2.value = nt2dp(r2,2);
  document.stride.t1.value = nt2dp(t1,2);
  document.stride.t2.value = nt2dp(t2,2);
}

function valclear()
{
  document.stride.r1.value = "";
  document.stride.r2.value = "";
  document.stride.t1.value = "";
  document.stride.t2.value = "";
}

function predcalc()
{
  var t400 = document.pred.t400.value;

  p1=-0.131152+(0.3856481*t400)+(t400*t400*-0.000985);
  p2=-12.83117+(1.2204958*t400)+(t400*t400*-0.004695);
  p3=-31.48858+(2.818664*t400)+(t400*t400*-0.010923);

  document.pred.p150.value = nt2dp(p1,2);
  document.pred.p300.value = nt2dp(p2,2);
  document.pred.p600.value = nt2dp(p3,2);
}

function pclear()
{
  document.pred.p150.value = "";
  document.pred.p300.value = "";
  document.pred.p600.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);
}