// DAILY CALORIE NEED SCRIPT
function calcDCN (intWeight,intFeet,intInches,intAge,strGender) {

	// Gets Rate of Metabolism (BMR)
		// Step One: WeightSex
	var fltWM = intWeight * 6.2;
	var fltWW = intWeight * 4.4;
	
		// Step Two: Height, HeightSex
	var intHeight = intFeet * 12 + parseInt(intInches);
	var fltHM = intHeight * 12.7;
	var fltHW = intHeight * 4.7;
	
		// Step Three: AgeSex
	var fltAM = intAge * 6.8;
	var fltAW = intAge * 4.7;
	
		// Calculate: Basal Metabolic Rate
	var fltBMR;
	if (strGender == "male") {
		 fltBMR = ((fltWM + fltHM) - fltAM) + 66;
	} else {
		 fltBMR = ((fltWW + fltHW) - fltAW) + 655;
	}
	
	//  Gets Calories for Physical Activity, 
	//  (Energy for Digestion and Absorption), 
	//  and Total Energy Needs               
	var fltCPA = fltBMR;
	var fltTEN = fltBMR;
	
	// Write the result to the text box
	document.dcn.Result.value = parseInt(fltTEN);
	
}


// BMI SCRIPT
function mod(div,base) {
return Math.round(div - (Math.floor(div/base)*base));
}
function calcBmi(weight,htf,hti) {
var w = weight * 1;
var HeightFeetInt = htf * 1;
var HeightInchesInt = hti * 1;
HeightFeetConvert = HeightFeetInt * 12;
h = HeightFeetConvert + HeightInchesInt;
displaybmi = (Math.round((w * 703) / (h * h)));
var rvalue = true;
if ( (w <= 35) || (w >= 500)  || (h <= 48) || (h >= 120) ) {
alert ("Invalid data.  Please check and re-enter!");
rvalue = false;
}
if (rvalue) {
if (HeightInchesInt > 11) {
reminderinches = mod(HeightInchesInt,12);
document.bmi.hti.value = reminderinches;
document.bmi.htf.value = HeightFeetInt + 
((HeightInchesInt - reminderinches)/12);
document.bmi.answer.value = displaybmi;
}
if (displaybmi <19) 
document.bmi.comment.value = "Underweight";
if (displaybmi >=19 && displaybmi <=25) 
document.bmi.comment.value = "Desirable";
if (displaybmi >=26 && displaybmi <=29) 
document.bmi.comment.value = "prone to health risks";
if (displaybmi >=30 && displaybmi <=40) 
document.bmi.comment.value = "Obese";
if (displaybmi >40) 
document.bmi.comment.value = "Extremely obese";
document.bmi.answer.value = displaybmi; }
return rvalue;
}