function calcBMI(){

// Get Variables and validate to make sure they're numbers, 
// setting them to a value of 1 if they're not.

var weight = (isNaN(document.wcbubba.weight.value)) ? 1 : document.wcbubba.weight.value;

if (weight == 0) alert("Indtast et validt tal i feltet vægt.");

var height = (isNaN(document.wcbubba.height.value)) ? 1 : document.wcbubba.height.value;

if (height == 0) alert("Indtast et validt tal i feltet højde.");

// set multipliers based on whether metric or English units were selected

var wmult = (document.wcbubba.units.value == "pounds") ? 2.204 : 1;

// Turns inches/centimeters into meters

var hmult = (document.wcbubba.hunits.value == "inches") ? .0254 : .01;

// Do the calculation (weight in kg divided by the height in meters 
// times itself). The multiplication by 10 and then division by ten
// work in conjunction with Math.round() to round the value to one
// decimal place of precision.

var BMI = Math.round(((weight / wmult)/((height * hmult)*(height * hmult))) *10)/10;

// get the analysis - note this is for general purpose, there is a separate scale for
// Southeast Asian people and there may be more variants on the way

var result = "";
if(BMI < 18) result = "Undervægtig";
else if((BMI >=18)&&(BMI<=25)) result = "Normal vægt";
else if((BMI >=25.01)&&(BMI<=30)) result = "Overvægtig";
else if((BMI >=30.01)&&(BMI<=40)) result = "Fed";
else result = "Meget fed";

document.getElementById('results').innerHTML = "Dit Body Mass Index (BMI) er: " + BMI + ".<br><br>Det svare til kategorien " + result + ".";

}
