<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate training times for events  -->
<!-- Required by: 800m to 10k -->
<!-- Copyright Brian Mackenzie 2004 -->

function speedcalculate()
{
  var pbm = document.speed.pbm.value;
  var pbs = document.speed.pbs.value;
  var pbdistance = document.speed.pbdistance.value;
  var distance = document.speed.distance.value;
  var effort = document.speed.effort.options[document.speed.effort.selectedIndex].value;

  pb = pbm * 60 + (pbs * 1);

  t1 = pb / pbdistance;
  t2 = t1 * distance * ((200 - effort) / 100);

  tm = Math.floor(t2 / 60);
  ts = t2 - (60 * tm);

  document.speed.timem.value = nt2dp(tm,0);
  document.speed.times.value = nt2dp(ts,1);
}

function valclear()
{
  document.speed.timem.value = "";
  document.speed.times.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);
}