<!-- //
function calculateBMI() {

  if (!validInt(document.getElementById('weight'))) {
    alert('Please type in the correct weight');
  }
  if (!validInt(document.getElementById('height'))) {
    alert('Please type in the correct height');
  }
  
  if (validInt(document.getElementById('height')) && validInt(document.getElementById('weight'))) { 
    var height = document.getElementById('height').value;
    var weight = document.getElementById('weight').value;
    
    var bmi = (weight / (height * height) * 10000);
  
    var reponse = "";
    if (bmi <= 20) {
      response = "You are underweight, consider seeing your GP for advice.";
    } 
    else if ((bmi > 20) && (bmi <= 25)) {
      response = "You have a normal BMI.";
    }
    else if ((bmi > 25) && (bmi <= 30)) {
      response = "You are overweight, consider seeing your GP for advice.";
    } 
    else if ((bmi > 30) && (bmi <= 35)) {
      response = "You may be a candidate for a laparoscopic adjustable gastric band, particularly if you have obesity related health problems and have tried other weight loss methods and you are motivated for success.";
    }
    else if ((bmi > 35) && (bmi <= 40)) {
      response = "You maybe a candidate for obesity sugery if you have obesity related health problems.";
    }
    else if (bmi > 40) {
      response = "You maybe a candidate for obesity sugery.";
    }
    alert("Your BMI is " + bmi.toFixed(2) + "\n" + response + "");
  }
}

function validInt(inputElement) {
  if (inputElement.value != "" && !isNaN(inputElement.value)) {
    return true;
  }
  else {
    return false;
  }
}

// -->