function bmiCalc()
{
	var err = 0;
	var height = (parseInt(document.bmiForm.feet.value) * 12) + parseInt(document.bmiForm.inches.value);
	var iweight = parseInt(document.bmiForm.weight.value);
	var lLowestWeight;
	var sLowestBmi = 18.5;
	var sHighBmi = 40;
	var sAlert;
	var h2 = height * height;
	var ibmi = (705 * iweight) / h2;
	
	if (isNaN(height) || isNaN(iweight))
	{
		alert("All fields must be filled in with a number.");
		err = 1;
	}
	
	ibmi = roundValue(ibmi, 1);
	lLowestWeight = ((sLowestBmi / 705) * h2);
	lLowestWeight = roundValue(lLowestWeight, 0);
	lHighestWeight = ((sHighBmi / 705) * h2);
	lHighestWeight = roundValue(lHighestWeight, 0);
	
	if (err == 0)

	{
		document.bmiForm.bmi.value = ibmi;

		if (iweight < lLowestWeight)
		{	
			sAlert = "To avoid increased health risk, the MDdiets program does not\n";
			sAlert += "encourage a weight below ";
			sAlert += lLowestWeight;
			sAlert += " lbs for an individual of this height.\n\n";
			sAlert += "See below for more information.\n\n";
			sAlert += "\t\tMDdiets Staff";
			alert(sAlert);
		}
		
		if (iweight > lHighestWeight)
		{	
			sAlert = "A BMI of 40 or higher is a severe health risk and may increase\n";
			sAlert += "the chances of contracting one or more weight related\n";
			sAlert += "diseases.\n\n";
			sAlert += "Join MDdiets and see how you can safely lower\n";
			sAlert += "your weight to ";
			sAlert += (iweight - 24);
			sAlert += " lbs in the first three months of the program.\n\n";
			sAlert += "\t\tMDdiets Staff";
			alert(sAlert);
		}
	}

	return false;
}

function roundValue(lValue_in, lDecimalPlaces_in)
{
	var lValue = lValue_in;
	var sDecimalPlacesMultiplier = "1";
	var lDecimalPlacesMultiplier = 0;
	var lLoopCount;
	
	for(lLoopCount = 0; lLoopCount < lDecimalPlaces_in; lLoopCount ++)
	{
		sDecimalPlacesMultiplier += "0";
	}
	
	lDecimalPlacesMultiplier = parseInt(sDecimalPlacesMultiplier);
	
	if (lDecimalPlacesMultiplier != 1)
		lValue = (lValue * lDecimalPlacesMultiplier);
		
	lValue = Math.round(lValue);
	
	if (lDecimalPlacesMultiplier != 1)
		lValue = (lValue / lDecimalPlacesMultiplier);
		
	return lValue;
}

function inchCheck()
{
	if (document.bmiForm.inches.value > 12)
	{
		alert("No more than 12 inches to the foot please.");
		document.bmiForm.inches.value = "";
	}

	if (document.bmiForm.inches.value == 12)
	{
		var newFeet = parseInt(document.bmiForm.feet.value) + 1;
		document.bmiForm.feet.value = newFeet;
		document.bmiForm.inches.value = 0;

		if (isNaN(newFeet))
		{
			alert("All fields must be filled in with a number.");
			document.bmiForm.feet.value = "";
			document.bmiForm.inches.value = "";
		}
	}
}

function falseSub()
{
	return false;
}