<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate distances for the long jump  -->
<!-- Required by: longjump\index.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function ljcal()
{
  //for more details see The Coach Issue 10 page 33

  var time = document.lj.time.value;
  var sex = document.lj.sex.options[document.lj.sex.selectedIndex].value;
  var adist = document.lj.adist.value;

  speed = 10/time;
    
  if (sex == "Male")
    {
      dist = (speed * 0.95) - 2.23;
      // standard deviation of 0.31 on predicted distance
      sd = 0.31;
    }
  else
    {
       dist = (speed * 0.99) - 2.81;
       // standard deviation of 0.24 on predicted distance
       sd = 0.24;
    }
  diff = Math.abs(dist-adist);

  if (diff>sd)
    {
      if (adist>dist)
        {
          //distance achieved above (predicted + standard deviation)

          document.lj.anal.value = "Increase approach speed";
        }
      else
        {
          //distance achieved below (predicted - standard deviation)

          document.lj.anal.value = "Decrease approach speed";
        }
    }
  else
    {
      document.lj.anal.value = "Approach speed is fine";
    }

  document.lj.dist.value = nt2dp(dist,2);
}

function ljclear()

{
  document.lj.dist.value = "";
  document.lj.anal.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);
}