<!-- Author: Brian Mackenzie -->
<!-- Date: 11th March 2006 -->
<!-- Version: 1.0 -->
<!-- Function:  Calculate waist to hip ratio -->
<!-- Required by: whrt.htm -->
<!-- Copyright Brian Mackenzie 2006 -->

function pcalculate()
{
  var waist = document.whrt.waist.value;
  var hip = document.whrt.hip.value;
  var gender = document.whrt.gender.options[document.whrt.gender.selectedIndex].value;

  waist = waist *1;
  hip = hip * 1;
  ratio = waist/hip;
  ass = "High";
  
  if (gender=="Male")
    {
      if (ratio<0.95) ass="Average"
	  if (ratio<0.90) ass="Good";
      if (ratio<0.85) ass="Excellent";
	}

  if (gender=="Female")
    {
      if (ratio<0.85) ass="Average"
	  if (ratio<0.80) ass="Good";
      if (ratio<0.75) ass="Excellent";
    }

  document.whrt.assess.value = ass;
  document.whrt.rat.value = nt2dp(ratio,2);
  
}

function pclear()
{
  document.whrt.assess.value = "";
  document.whrt.rat.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);
}

