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("Por favor introduzca numeros enteros para tanto el peso como la edad.");
	
} 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 values
		var adjust_weight = 655 + (9.6 * kilograms);
		var adjust_height = 1.7 * centimeters;
		var adjust_age = 4.7 * years_of_age;

	} else {  // Male calculation values
		var adjust_weight = 66 + (13.7 * kilograms);
		var adjust_height = 5 * centimeters;
		var adjust_age = 6.8 * years_of_age;
		}
	
	document.CaloricNeedsForm.Calories.value = Math.ceil((adjust_weight + 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) * .65
	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) * .65 / 5
	document.CaloricNeedsForm.g.value = Math.ceil((weight_lbs * .4))/5
	document.CaloricNeedsForm.h.value = Math.ceil((weight_lbs * .8))/5
	document.CaloricNeedsForm.v.value = Math.ceil((weight_lbs * 1))

	
	}
}

<!-- 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;
}
