<!--
function Key_Up(e) {

     if (document.all) {

         e = window.event;

     }

     

     var key;



     if (document.layers)

         key = e.which;

     if (document.all)

         key = e.keyCode;

			

     if (key == '013') {

         ShowBMI();

     }

        

}



document.onkeypress = Key_Up;	 

	function ShowBMI(){

		var feet = parseInt(document.forms[1].ft.value)

		var inches = parseInt(document.forms[1].inch.value)

  if (feet != 0 && feet != 1 && feet != 2 && feet != 3 && feet != 4 

							&& feet != 5 && feet != 6 && feet != 7 && feet != 8)

      {alert ("Please correct the feet field.");

		 return;}

  if (inches != 0 && inches != 1 && inches != 2 && inches != 3 && inches != 4 

							&& inches != 5 && inches != 6 && inches != 7 && inches != 8 && inches != 9 

        && inches != 10 && inches != 11 && inches != 12)

				{alert ("Please correct the inches field.");

				 return;}

		inches = (feet * 12)+ inches

		if (inches == 0) {

			alert("Please enter height in feet and inches.");

			return;

		}

		var meters = inches * 2.54 / 100 

	 

		var kg = document.forms[1].wt.value / 2.2



	 if (kg < 0 || kg > 455)

		{ alert ("Please correct the weight field.");

		  return;}





		var BMI = kg / (meters * meters)

	 BMI = (BMI * 100) + .5

  BMI = Math.floor(BMI)

		BMI = BMI / 100

		

      if (document.forms[1].gender[0].checked) {

         gender = "male";

      }

      else if (document.forms[1].gender[1].checked) {

         gender = "female";

      }

//  var gender = "male"

  var rf = document.forms[1].risk.value;

  if (gender == "male") {

     if (BMI < 20.7) {

        rf = "You are underweight. The lower the BMI the greater the risk. Try eating more.";

     }

     else if ((BMI > 20.7) && (BMI <=26.4)) {

        rf = "Well done! You have the ideal BMI and are at low risk.";

     }

     else if ((BMI > 26.4) && (BMI <= 27.8)) {

        rf = "You are marginally overweight and there is some risk to your wellbeing. Try not to eat too much junk food";

     }

     else if ((BMI > 27.8) && (BMI <= 31.1)) {

        rf = "You are overweight. There is a moderate risk to your health. Try eating healthier and getting more exercise";

     }

     else if ((BMI > 31.1) && (BMI <= 45.4)) {

        rf = "You are severe overweight. High risk. See a Dietician urgently.";

     }

     else if (BMI > 45.4) {

        rf = "You are extremely obese. Very high risk. See a Dietician urgently.";

     }

  }

  if (gender == "female") {

     if (BMI < 19.1) {

        rf = "You are underweight. The lower the BMI the greater the risk. Try eating more.";

     }

     else if ((BMI > 19.1) && (BMI <=25.8)) {

        rf = "You have the ideal BMI. Keep it that way by avoiding junk food.";

     }

     else if ((BMI > 25.8) && (BMI <= 27.3)) {

        rf = "You are marginally overweight. There is a slight risk to your health and you should consider losing weight.";

     }

     else if ((BMI > 27.3) && (BMI <= 32.2)) {

        rf = "Overweight. Moderate risk to your health. Try eating less junk food and exercising more.";

     }

     else if ((BMI > 32.2) && (BMI <= 44.8)) {

        rf = "Severe overweight, high risk. Try eating less junk food and exercising more.";

     }

     else if (BMI > 44.8) {

        rf = "Morbid obesity, very high risk. See a Dietician immediately.";

     }

  }

  document.forms[1].bmi.value = BMI

  document.forms[1].risk.value = rf



	}
-->

					
					
					
					
