<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Created by: Bob Mason :: http://www.omega-cottage.co.uk/WLS -->
<!-- Begin
function  calculateBMI() {
  var weight = eval(document.form.weight.value)
  var height = eval(document.form.height.value)
  var height2 = height / 100
  var BMI = weight  / (height2 * height2)
  document.form.BodyMassIndex.value=custRound(BMI,1);
}
function custRound(x,places) {
  return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}
// End -->

// Body Fat Calculator
// copyright 23rd April 2006, by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
function valButton(btn) {var cnt = -1;for (var i=btn.length-1; i > -1; i--) {   if (btn[i].checked) {cnt = i; i = -1;}}if (cnt > -1) return btn[cnt].value;else return null;}function stripBlanks(fld) {var result = "";var c = 0;for (i=0; i < fld.length; i++) {if (fld.charAt(i) != " " || c > 0) {result += fld.charAt(i);if (fld.charAt(i) != " ") c = result.length;}}return result.substr(0,c);}function maleFat(h,n,w) {return thou(495/(1.0324-0.19077*(Math.log(w-n)/Math.LN10)+0.15456*(Math.log(h)/Math.LN10))-450);}function femaleFat(h,n,w,r) {return thou(495/(1.29579-0.35004*(Math.log(w+r-n)/Math.LN10)+0.22100*(Math.log(h)/Math.LN10))-450);}function thou(n) {return Math.round(n*10)/10+'%';}function sex(thisform) {var s = valButton(thisform.s);thisform.r.disabled = (s != 'f');}function calc(thisform) {var s = valButton(thisform.s);if (s == null) {alert("Debes indicar tu sexo.");return false;}var d = valButton(thisform.d);if (d == null) {alert("Debes elegir centímetros o pulgadas.");return false;}d = Number(d);var h = stripBlanks(thisform.h.value);if (h == '') {alert("Debes indicar tu altura.");thisform.h.focus();return false;}if (h != Number(h) || (h = Number(h*d)) < 100 || h > 250) {alert("La altura parece incorrecta...");thisform.h.focus();return false;}var n = stripBlanks(thisform.n.value);if (n == '') {alert("Debes indicar la medida de tu cuello");thisform.n.focus();return false;}if (n != Number(n) || (n = Number(n*d)) < 20 || n > 60) {alert("La medida del cuello parece incorrecta...");thisform.n.focus();return false;}var w = stripBlanks(thisform.w.value);if (w == '') {alert("Debes indicar la medida de tu cintura.");thisform.w.focus();return false;}if (w != Number(w) || (w = Number(w*d)) < 30 || w > h) {alert("La medida de la cintura parece incorrecta...");thisform.w.focus();return false;}var r = 0;if (s == 'f') {r = stripBlanks(thisform.r.value);if (r == '') {alert("Debes indicar la medida de tu cadera.");thisform.r.focus();return false;}if (r != Number(r) || (r = Number(r*d)) < 40 || h > 200) {alert("La medida de la cadera parece incorrecta...");thisform.r.focus();return false;}}switch(s) {case 'm': thisform.f.value = maleFat(h,n,w); break; case 'f': thisform.f.value = femaleFat(h,n,w,r);}}

