<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2004 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate the results from the Medicine ball quadrathlon -->
<!-- Required by: medballquad.htm -->
<!-- Copyright Brian Mackenzie 2004 -->

function calculate()
{
v1 = new Array (0,3,4.5,6,7.5,9,10.5,12,13.5,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
v2 = new Array (0,2,3.25,4.5,5.75,7,8.25,9.5,10.75,12,13,14,15,16,16.75,17.5,18.25,19,19.75,20.5,21.25,22,22.75,23.5,24.25,25);
v3 = new Array (0,4.5,6,7.5,9,10.5,12,13.5,15,16.5,17.5,18.5,19.5,20.5,21.5,22.5,23.5,24.5,25.5,26.75,28,28.75,29.5,30.25,31,31.75);
v4 = new Array (0,2.75,4,5.25,6.5,7.75,9,10.25,11.5,12.75,14,15.25,16.5,17.75,18.5,19.25,20,20.75,21.5,22.25,23,23.75,24.5,25.25,26,26.75);

var d1 = eval(document.stride.d1.value);
var d2 = eval(document.stride.d2.value);
var d3 = eval(document.stride.d3.value);
var d4 = eval(document.stride.d4.value);

//Stand throw one - limit value
if (d1>31)
  {
    d1=31;
  }

//Stand throw two - limit value
if (d2>26)
  {
    d2=26;
  }

//3 Step throw one - limit value
if (d3>31.75)
  {
    d3=31.75;
  }

//3 Step throw two - limit value
if (d4>26.75)
  {
    d4=26.75;
  }

//Stand throw one - determine points
x=1;
while (d1>=v1[x])
  {
    x=x+1;
  }

t1=x-1;

//Stand throw two - determine points
x=1;
while (d2>=v2[x])
  {
    x=x+1;
  }

t2=x-1;

//3 Step throw one - determine points
x=1;
while (d3>=v3[x])
{
x=x+1;
}

t3=x-1;

//3 Step throw two - determine points
x=1;
while (d4>=v4[x])
  {
    x=x+1;
  }

t4=x-1;

//calculate total points

p1=t1+t2+t3+t4;

document.stride.p1.value = p1;

}

function valclear()
{
  document.stride.p1.value = "";
}