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 tanto para el peso como para 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) {  // male calculation values
		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;

	} else {  // feMale calculation values
		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;
		}
	
	
	document.CaloricNeedsForm.b.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) *  1.21
	document.CaloricNeedsForm.a.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1
    document.CaloricNeedsForm.d.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1.21 / 5
	document.CaloricNeedsForm.c.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1 / 5	 
    
   	document.CaloricNeedsForm.e.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) *  1.21
	document.CaloricNeedsForm.f.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1

	
document.CaloricNeedsForm.g.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1.21 / 3
	document.CaloricNeedsForm.h.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1 / 3
  
  document.CaloricNeedsForm.i.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1.21 / 4
	document.CaloricNeedsForm.j.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1 / 4
	
  document.CaloricNeedsForm.k.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1.21 / 6
	document.CaloricNeedsForm.l.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 1 / 6
	
		document.CaloricNeedsForm.m.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) *  1.21
	document.CaloricNeedsForm.n.value = Math.ceil((adjust_weight + adjust_height - adjust_age) * activity_index) * 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;
}
