function cal_bmi(lbs, ins)
{
   h2 = ins * ins;
   bmi = lbs/h2 * 703
   f_bmi = Math.floor(bmi);
   diff  = bmi - f_bmi;
   diff = diff * 10;
   diff = Math.round(diff);


   if (diff == 10)    // Need to bump up the whole thing instead
   {
      f_bmi += 1;
      diff   = 0;
   }
   bmi = f_bmi + "." + diff;
   return bmi;
}
function doBmi(){
   var f = self.document.forms[0];

   w = f.weight.value;
   v = f.height_feet.value;
   u = f.height_inches.value;

   // Format values for the BMI calculation

   if (!chkw(u))
   {
     var ii = 0;
     f.height_inches.value = 0;
   } else
   {
     var it = f.height_inches.value*1;
     var ii = parseInt(it);
    }

   var fi = parseInt(f.height_feet.value * 12);
   var i =  parseInt(f.height_feet.value * 12) + f.height_inches.value*1.0;  

   if (!chkw(v))
   {
     alert("Please enter a number for your height.");
     f.height_feet.focus();
     return;
   }
   if (!chkw(w))
   {
     alert("Please enter a number for your weight.");
     f.wt.focus();
     return;
   }

   // Perform the calculation

   f.bmi.value = cal_bmi(w, i);
   f.bmi.focus();
}

function chkw(w){
   if (isNaN(parseInt(w))){
      return false;
   } else if (w < 0){
  return false;
  }
  else{
  return true;
  }
}
