// BMI Calculater
// -----------------------------------------------------------------

function Clear(form){
        form.w.value="";
        form.feet.value="";
        form.h.value="";
        form.body.value="";
}
function something(w,feet,h){
		var width, height, index;
        width=w*.45359237;
        height=feet*12;
        height=height-(-h);
        height=height*.0254;
        height=height*height;
        index=width/height;
        return index;
}
function check(form){
        if (form.w.value==null || form.w.value.length==0 || form.feet.value==null || form.feet.value.length==0 || form.h.value==null){
        alert("Please enter your height and weight.");
        return false;
}
else if (parseFloat(form.feet.value)<=0 ||
         parseFloat(form.feet.value)>=9 ||
         parseFloat(form.h.value)<0 ||
         parseFloat(form.h.value)>12 ||
         parseFloat(form.w.value)<=0 ||
         parseFloat(form.w.value)>=801){
        alert("Please recheck your height and weight values.");
        Clear(form);
        return false;
        }
        return true;
}
function comp(form){
	var your=0;
	if(check(form)){
        your=something(form.w.value,form.feet.value,form.h.value);
    }
	if(your>0){
		if(your<19){
    	    alert("This BMI falls below the range for most people.  Please recheck your entries, or, for an individualized assessment, see your physician.");
   		     form.body.value=your;
    	}else{
        	form.body.value=your;
    	}
    	return;
	}	
}