 function Fmt(x) { 
var v
if(x>=0) { v=''+(x+0.0005) } else { v=''+(x-0.0005) }
return v.substring(0,v.indexOf('.')+2) 
}

function compute(form) {

if((document.bmi.weight.value==null)||(document.bmi.weight.value=="")||(isNaN(document.bmi.weight.value))){
alert('Please enter the weight.');

return false;
}


if((document.bmi.height.value==null)||(document.bmi.height.value=="")||(isNaN(document.bmi.height.value))){
alert('Please enter the height.');

return false;
}

if (document.bmi.kg[0].checked) {var weightm=(1*document.bmi.weight.value)};
if (document.bmi.kg[1].checked) {var weightm=(1*document.bmi.weight.value)/2.2} ;
if (document.bmi.cent[0].checked) {var heightm=(1*document.bmi.height.value)*.01};
if (document.bmi.cent[1].checked) {var heightm=(1*document.bmi.height.value)*0.0254} ;


document.bmi.bmi.value= Fmt(weightm/(heightm*heightm));

}
