function isInteger(s){var i;for (i = 0; i < s.length; i++){var c = s.charAt(i);if (!isDigit(c)) return false;}return true;}function isDigit(c){return ((c >= "0") && (c <= "9"))}function checkhw(hf,w){if (hf == "") {alert("You have not filled in the height field.");return false;}else{if(!isInteger(hf)) {alert("Please enter valid height.");return false;}}



if (w == "") {alert("You have not filled in the weight field.");return false;}else{if(!isInteger(w)) {alert("Please enter valid weight.");return false;}}return true;}function calBMI(){var gender=document.getElementById("_ctl0_PlaceHolderMain_cboBMIGender").value;var hf=document.getElementById("htf").value;
var hi=document.getElementById("hti").value;

if (hi == "") {alert("You have not filled in the height field.");return false;}else{if(!isInteger(hi)) {alert("Please enter valid height.");return false;}}



document.getElementById('bmiHtin').value = hi;
var w=document.getElementById("wt").value;
document.getElementById('bmiWt').value = w;

if(!checkhw(hf,w)){return false;}
else{if(!isInteger(hi)) {hi = 0;}
var height=((hf*12) + (hi*1))*0.025;
var hsq=height*height;
var bmi=Math.round((w/hsq)*100)/100;



if(bmi<=18.5){hval="UNDERWEIGHT";
desc="Talk to your doctor to see if you are at an increased risk and if you should increase weight. ";
}
if(bmi>18.5&bmi<22.9)
{
hval="NORMAL";
desc="Talk to your doctor to see if you are at an increased risk and if you should increase or decrease weight. ";
}
if(bmi>=23&bmi<24.9)
{hval="OVERWEIGHT";
desc="For people who are considered overweight (BMI greater than 23) and have two or more risk factors, the guidelines recommend weight loss. ";
}
if(bmi>=25)
{hval="OBESE";
desc="People who are obese have a greater chance of developing high blood pressure, type 2 diabetes & heart disease.";
}


document.getElementById('result').innerHTML="<h5 style='margin:10px 0px;padding:0px 0px 38px 0px;'>You are "+hval+", your BMI is <span style='color:#127cac'>"+bmi+"</span>";


//document.getElementById('descrip').innerHTML=desc;

document.getElementById('maindiv').style.display= 'none';
document.getElementById('trresult').style.display= 'block';

return false;
}}
function actualfun()
{
document.getElementById('maindiv').style.display= 'block';
document.getElementById('trresult').style.display= 'none';

document.getElementById('htf').value= '';
document.getElementById('hti').value= '';
document.getElementById('wt').value= '';

}
    
    function clickButton(e, buttonid){
    
var bt = document.getElementById(buttonid);
if (typeof bt == 'object'){
if(navigator.appName.indexOf("Netscape")>(-1)){
if (e.keyCode == 13){
bt.click();
return false;
}
}
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
if (event.keyCode == 13){
bt.click();
return false;
}
}
}
}
    
