function bmi_cal(lbs, ins)
{
	var f = document.forms.formBmi;
	var weight = f.weight.value*1;
	var weight_u = f.weight_u.options[f.weight_u.selectedIndex].value;
	var height_feet = f.height_feet.options[f.height_feet.selectedIndex].value;
	var height_inch = f.height_inch.options[f.height_inch.selectedIndex].value;
	var height = f.height.value*1;
	var height_u = f.height_u.options[f.height_u.selectedIndex].value;
	var err = '';
	if(!weight || (weight<50 || weight>600)) { err += 'Weight value is missing or invalid.'+"\n"; }
	if(height) {
		if(!hbmi(height)) { err += 'Height must be a number.'+"\n"; }
		if(height_feet || f.height_inch.selectedIndex>0) { err += 'Please choose only one method for height (ft+in, OR inches/cm).'; }
	} else {
		if(!hbmi(height_feet) || f.height_inch.selectedIndex==0) { err += 'Height value is missing or invalid.'; }
	}
	if(err) { alert(err); return false; }
	if(weight_u=='kg') { weight *= 2.20462262; }
	if(height) {
		if(height_u=='cm') { height *= 0.393700787; }
	} else {
		height = (height_feet*12) + (1*height_inch);
	}
	var bmi = Math.round( (weight/(height*height))*703*10 )/10;
	var txt = '';
	if(bmi<18.5) { txt = '. <br/><br/>Your BMI reading is considered <strong>Underweight</strong> and may increase your risk for illness and disease compared to those in the normal BMI range (18.5-25). We recommend making an appointment with your health care provider.<br/><br/>Remember, BMI is not an indicator of your health or body fat, but is generally a good guide to determine your health risk and if you have a healthy height-to-weight ratio. However, some individuals may not be accurately represented by this number or reading. You should always consult with your health care provider.'; }
	else if(bmi>=18.5 && bmi<24.9) { txt = '.  <br/><br/>Your BMI reading is considered <strong>Normal</strong>. Keep up the good work! Continue regular follow up with your health care provider.<br/><br/>Remember, BMI is not an indicator of your health or body fat, but is generally a good guide to determine your health risk and if you have a healthy height-to-weight ratio. However, some individuals may not be accurately represented by this number or reading. You should always consult with your health care provider.'; }
	else if(bmi>=24.9 && bmi<29.9) { txt = '. <br/><br/> Your BMI reading is considered <strong>Overweight</strong>, which puts you at higher risk for health issues such as heart disease, diabetes, high blood pressure, gallstones and osteoarthritis. Medically Managed Weight Loss may be the right choice to help you develop lifestyle and diet changes that result in long-term success.<br/><br/> Contact TEAM:Bariatrics today to learn about PositiveLite.<br/><br/>Remember, BMI is not an indicator of your health or body fat, but is generally a good guide to determine your health risk and if you have a healthy height-to-weight ratio. However, some individuals may not be accurately represented by this number or reading. You should always consult with your health care provider.'; }
	else if(bmi>=29.9 && bmi<34.9) { txt = '. <br/><br/> Your BMI reading is considered <strong>Obese</strong>, which puts you at risk for serious health issues such as diabetes, high blood pressure, gallstones, osteoarthritis and especially heart disease. You are also at higher risk for some types of cancer and even death. Medically Managed Weight Loss may be the best solution to help you develop lifestyle and diet changes that reverse the scales and restore your health.<br/><br/> Contact TEAM:Bariatrics today to learn about PositiveLite.<br/><br/>Remember, BMI is not an indicator of your health or body fat, but is generally a good guide to determine your health risk and if you have a healthy height-to-weight ratio. However, some individuals may not be accurately represented by this number or reading. You should always consult with your health care provider.'; }
	else if(bmi>=34.9 && bmi<39.9) { txt = '. <br/><br/>Your BMI reading is considered <strong>Severely Obese</strong>, which puts you at risk for at least 30 serious health issues such as diabetes, high blood pressure, gallstones, osteoarthritis and especially heart disease. You are also at higher risk for some types of cancer and even death. A healthy wellness and activity level is within reach through TEAM:Bariatrics surgical or medically managed weight loss programs. <br/><br/>Sign up to attend a free life-changing seminar to discover the right path for you.<br/><br/>Remember, BMI is not an indicator of your health or body fat, but is generally a good guide to determine your health risk and if you have a healthy height-to-weight ratio. However, some individuals may not be accurately represented by this number or reading. You should always consult with your health care provider.'; }
	else { txt = '. <br/><br/>Your BMI reading is considered <strong>Morbidly Obese</strong>, which puts you at risk for at least 30 serious health issues such as diabetes, high blood pressure, gallstones, osteoarthritis and especially heart disease. You are also at higher risk for some types of cancer and even death. A healthy wellness and activity level is within reach through TEAM:Bariatrics surgical weight loss options. <br/><br/>Sign up to attend a free life-changing seminar to discover the right path for you.<br/><br/>Remember, BMI is not an indicator of your health or body fat, but is generally a good guide to determine your health risk and if you have a healthy height-to-weight ratio. However, some individuals may not be accurately represented by this number or reading. You should always consult with your health care provider.'; }
	txt = 'Your estimated BMI is '+bmi+''+txt+'';
	document.getElementById('response').innerHTML = txt;
}
function hbmi(n)
{
	if( isNaN(n) || n==null || n.length==0 ) { return false; }
	n=n+"";
	if( n.search(/\s+/)!=-1 ) { return false; }
	return true;
}
if( document.layers && !document.getElementById ) {
	document.write( 'Sorry, to view the BMI calculator you must use a newer browser.<p />');
} else {
if(typeof(calculation)=='undefined') { var calculation = 1; }
document.write(
'<form style="margin:0px" name="formBmi" onsubmit="bmi_cal();return false;">',
'<div align="left" style="font-family:arial,helvetica,sans-serif;font-size:12px;">',
'<b style="font-family:arial,helvetica,sans-serif;color:#000000">',
'<span style="font-size:15px;">'+(calculation==1?'BMI Calculator':'BMI Calculator')+'</span><br />',
'</b></div>',
'<div align="left" style="font-family:arial,helvetica,sans-serif;font-size:12px;border-top:1px solid #cdcdcd;">',
'Weight: <input type="text" name="weight" value="" size="2" style="width:40px;margin-top:3px;" />&nbsp;',
'<select name="weight_u" style="margin-top:10px;">',
	'<option value="lbs">lbs</option>',
	'<option value="kg">kg</option>',
'</select><br />',
'Height: <select name="height_feet" style="margin-top:10px;">',
	'<option value=""></option>',
	'<option value="4">4\'</option>',
	'<option value="5">5\'</option>',
	'<option value="6">6\'</option>',
	'<option value="7">7\'</option>',
'</select>',
'<select name="height_inch" style="margin-top:10px;">',
	'<option value=""></option>',
	'<option value="0">0"</option>',
	'<option value="1">1"</option>',
	'<option value="2">2"</option>',
	'<option value="3">3"</option>',
	'<option value="4">4"</option>',
	'<option value="5">5"</option>',
	'<option value="6">6"</option>',
	'<option value="7">7"</option>',
	'<option value="8">8"</option>',
	'<option value="9">9"</option>',
	'<option value="10">10"</option>',
	'<option value="11">11"</option>',
	'<option value="12">12"</option>',
'</select>',
' Or <input type="text" name="height" value="" size="2" style="width:35px;margin-top:2px;" />&nbsp;',
'<select name="height_u" style="margin-top:2px;">',
	'<option value="cm">cm</option>',
	'<option value="in">in.</option>',
'</select>',
'</div>',
'<div align="left"><input type="button" style="width:100px;margin-top:10px;" name="" value="Calculate BMI" onclick="bmi_cal()" /></div><br/>',
'<div align="left" style="width:306px;"><div id="response" style="border:1px dotted #888888;padding:10px;margin-top:7px;background-color:#ffffff;font-family:arial,helvetica,sans-serif;font-size:12px;color:#000000;font-style:color:#339ae2">Results:</div></div><br/>',
'</form>'
);
}
