function CaloricNeedsCalc() {
var height_feet = document.CaloricNeedsForm.HeightFeet.value;
var height_inches = document.CaloricNeedsForm.HeightInches.value;
var weight_lbs = document.CaloricNeedsForm.WeightLbs.value;
var years_of_age = document.CaloricNeedsForm.YearsAge.value;
var activity_index = document.CaloricNeedsForm.ActivityLevel.value;

if((!(CheckValues(weight_lbs))) || (!(CheckValues(years_of_age)))) {
	alert("Please enter numbers for both weight and age.");
	
} else {
	var total_inches = parseInt(height_feet * 12) + parseInt(height_inches);
	var centimeters = total_inches * 2.54;
	var kilograms = weight_lbs/2.2;

	if(document.CaloricNeedsForm.Gender[0].checked) {  // Female calculation values77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
		var adjust_weight = 655 + (9.6 * kilograms);
		var adjust_height = 1.7 * centimeters;
		var adjust_age = 4.7 * years_of_age;
		var minus = (kilograms - 2.27) * 9.6 + 655;
		var minu = (kilograms - 4.54) * 9.6 + 655;
		var min = (kilograms - 6.81) * 9.6 + 655;
		var mi = (kilograms - 9.08) * 9.6 + 655;
		var m = (kilograms - 11.35) * 9.6 + 655;
		var m1 = (kilograms - 13.62) * 9.6 + 655;
		var m2 = (kilograms - 15.89) * 9.6 + 655;
		var m3 = (kilograms - 18.16) * 9.6 + 655;
		var m4 = (kilograms - 20.45) * 9.6 + 655;
		var m5 = (kilograms - 22.73) * 9.6 + 655;

	} else {  // Male calculation values77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
		var adjust_weight = 66 + (13.7 * kilograms);
		var adjust_height = 5 * centimeters;
		var adjust_age = 6.8 * years_of_age;
		var minus = (kilograms - 2.27) * 13.7 + 66;
		var minu = (kilograms - 4.54) * 13.7 + 66;
		var min = (kilograms - 6.81) * 13.7 + 66;
		var mi = (kilograms - 9.08) * 13.7 + 66;
		var m = (kilograms - 11.35) * 13.7 + 66;
		var m1 = (kilograms - 13.62) * 13.7 + 66;
		var m2 = (kilograms - 15.89) * 13.7 + 66;
		var m3 = (kilograms - 18.16) * 13.7 + 66;
		var m4 = (kilograms - 20.45) * 13.7 + 66;
		var m5 = (kilograms - 22.73) * 13.7 + 66;
		}
	
	document.CaloricNeedsForm.Calories.value = Math.ceil((m4 + adjust_height - adjust_age) * activity_index)
	document.CaloricNeedsForm.b.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .85
	document.CaloricNeedsForm.a.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .75
    document.CaloricNeedsForm.d.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .85 / 5
	document.CaloricNeedsForm.c.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .75 / 5
	document.CaloricNeedsForm.z.value = Math.ceil((weight_lbs * 1))
	document.CaloricNeedsForm.y.value = Math.ceil((weight_lbs - 10))
    
    document.CaloricNeedsForm.j.value = Math.ceil((weight_lbs - 5))
    
	
	document.CaloricNeedsForm.lv.value = Math.ceil((minus + adjust_height - adjust_age) * activity_index) * .65
    document.CaloricNeedsForm.mv.value = Math.ceil((minus + adjust_height - adjust_age) * activity_index) * .85

    document.CaloricNeedsForm.qv.value = Math.ceil((minus + adjust_height - adjust_age) * activity_index) * .65 / 5
    document.CaloricNeedsForm.pv.value = Math.ceil((minus + adjust_height - adjust_age) * activity_index) * .85 / 5
      
    	document.CaloricNeedsForm.bb.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .85
	document.CaloricNeedsForm.aa.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .75

        	document.CaloricNeedsForm.lvv.value = Math.ceil((minus + adjust_height - adjust_age) * activity_index) * .65
    document.CaloricNeedsForm.mvv.value = Math.ceil((minus + adjust_height - adjust_age) * activity_index) * .85

            document.CaloricNeedsForm.dxx.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .85 / 3
	document.CaloricNeedsForm.cxx.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .65 / 3


   document.CaloricNeedsForm.dzz.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .85 / 4
	document.CaloricNeedsForm.czz.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .65 / 4

document.CaloricNeedsForm.bbb.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .85
	document.CaloricNeedsForm.aaa.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * .75

    document.CaloricNeedsForm.fin.value = Math.ceil((weight_lbs - 10))
	document.CaloricNeedsForm.jk.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index)/5


	}
}

<!-- This function accepts a string value and determines if it is a zero-length or null string, then checks for positive integer values. It returns a value of true or false. -->
function CheckValues(this_string) {
	var is_number = true;
	var string_length = this_string.length;
	if(string_length == 0) {
		is_number = false;
	} else {
		for(count = 0; count < string_length; count++) {
			if((this_string.charAt(count) < "0") || (this_string.charAt(count) > "9")) {
				is_number = false;
				break;
			}	
		}
	}
	return is_number;
}
