<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate training times for events  -->
<!-- Required by: 100m 200m 300m -->
<!-- Copyright Brian Mackenzie 2004 -->

function speedcalculate(pbdistance)
{
  var pb = document.speed.pb.value;
  var distance = document.speed.distance.value;
  var effort = document.speed.effort.value;

  if (pbdistance == 100)
    {
      t1 = (0.00875*pb * (distance-20))+ 0.3*pb;
      tm = t1 * ((200-effort) / 100);
    }

  else
    {
		if (distance<=100)
		{
			pb=pb/pbdistance * 100;
			t1=(0.00875*pb * (distance-20))+ 0.3*pb;
			tm = t1 * ((200-effort) / 100);
         }
		else
		{
            t1 = pb / pbdistance;
            tm = t1 * distance * ((200-effort) / 100);
		}
    }

  document.speed.timem.value = nt2dp(tm,2);
}

function valclear()
{
  document.speed.timem.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);
}