var myBMI   = 0
var height  = 0
var htUnits = 0
var weight  = 0
var wtUnits = 0
function doBMIcalc() {
  var heightIn  = document.formBMI.height.value
  htUnits       = document.formBMI.heightUnits.selectedIndex
  weight        = document.formBMI.weight.value
  wtUnits       = document.formBMI.weightUnits.selectedIndex
  if (htUnits == 0) {
    var hyphen = heightIn.indexOf("-");
    if (hyphen == -1) hyphen = 1
    var feet   = 1*heightIn.substring(0,hyphen);
    var inches = 1*heightIn.substring(hyphen+1,5);
    height = 12*feet + inches;
    height = height * 0.0254 
  } else {
    if (htUnits == 1) {
      height = heightIn / 100
    }
  }
  if (wtUnits == 0) {
    weight = weight / 2.2056
  } else {
    if (wtUnits == 2) {
      weight = weight * 14 / 2.2056
    }
  }
  BMI = weight / (height * height)  
  return BMI; 
}

