function calc (form) {
var S, StandDev, PercRegress, Zscore
S=form.Sex.options[form.Sex.selectedIndex].value
  if (S == "Male") {
     form.PopulationAverage.value =
     Math.round(70.592*Math.pow(10,-0.010502*form.Age.value))
}
  if (S == "Female") {
     form.PopulationAverage.value =
     Math.round(58.657-1.48*form.Age.value+0.01*Math.pow(form.Age.value,2))
}
  if (S == "Male" && form.Repetitions.value<=form.PopulationAverage.value) {
     StandDev =
     179.35*Math.pow(form.Age.value,-0.69961)
}
  if (S == "Male" && form.Repetitions.value>form.PopulationAverage.value) {
     StandDev =
     14.5
}
  if (S == "Female" && form.Repetitions.value<=form.PopulationAverage.value) {
     StandDev =
     9.9889+0.34571*form.Age.value-0.0071429*Math.pow(form.Age.value,2)
}
  if (S == "Female" && form.Repetitions.value>form.PopulationAverage.value) {
     StandDev =
     150.83*Math.pow(form.Age.value,-0.53466)
}
Zscore = (form.Repetitions.value-form.PopulationAverage.value)/StandDev
PercRegress = 0.49402+0.44379*Math.abs(Zscore)-0.082675*Math.pow(Math.abs(Zscore),2)-0.021233*Math.pow(Math.abs(Zscore),3)+0.0060829*Math.pow(Math.abs(Zscore),4)
  if (Zscore > 0) {
     form.Score.value =
     Math.round(PercRegress*100)
}
  if (Zscore <= 0) {
     form.Score.value =
     Math.round((1-PercRegress)*100)
}
  if (Zscore >= 1) {
     form.Rating.value ="Excellent"
}
  if (Zscore < 1 && Zscore >= 0.5) {
     form.Rating.value ="Good"
}
  if (Zscore < 0.5 && Zscore >= -0.5) {
     form.Rating.value ="Average"
}
  if (Zscore < -0.5 && Zscore >= -1) {
     form.Rating.value ="Fair"
}
  if (Zscore < -1) {
     form.Rating.value ="Poor"
}
}
