<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate times for 10k training  -->
<!-- Required by: tp10k.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function timecalculate()
{
  var secs = document.time.secs.value;
  var mins = document.time.mins.value;

  t10 = (mins*1) + (secs/60);

  //marathon time
  tmar = t10 * 4.76;
  mm = Math.floor(tmar);
  ms = (tmar - mm) * 60;
  temp = mm/60;
  mh = Math.floor(temp);
  mm = mm - (mh * 60);

  //5k time
  t5k = t10 * 0.48;
  m5 = Math.floor(t5k);
  s5 = (t5k - m5) * 60;

  //3k time
  t3k = t10 * 0.28;
  m3 = Math.floor(t3k);
  s3 = (t3k - m3) * 60;
  
  //1.5k time
  t15k = t10 * 0.13;
  m15 = Math.floor(t15k);
  s15 = (t15k - m15) * 60;

  document.time.mh.value = mh;
  document.time.mm.value = mm;
  document.time.ms.value = nt2dp(ms,0);
  document.time.m5.value = m5;
  document.time.s5.value = nt2dp(s5,0);
  document.time.m3.value = m3;
  document.time.s3.value = nt2dp(s3,0);
  document.time.m15.value = m15;
  document.time.s15.value = nt2dp(s15,0);
}

function valclear()
{
  document.time.mh.value = "";
  document.time.mm.value = "";
  document.time.ms.value = "";
  document.time.m5.value = "";
  document.time.s5.value = "";
  document.time.m3.value = "";
  document.time.s3.value = "";
  document.time.m15.value = "";
  document.time.s15.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);
}