function compute(){
   var f = document.form1;
   var a = parseInt(f.age.value);
   var w = parseInt(f.weight.value);
   var h = parseInt(f.height.value);
   var anum = 0;
   var bnum = 0.0;
   var cnum = 0;
   var dnum = 0.0;
   var enbr = 0.0;
   var fnum = 0.0;
   var tot = 0.0;
   if (!chkw(a)){
		alert("Please enter a number for your age.");
   }
   if (!chkw(w)){
   		alert("Please enter a number for your weight.");
	}
	if (!chkw(h)) {
		alert("Please enter a number for your height.");
	}
	if (f.gender[0].checked)
	{
		anum=864;
		bnum = a * 9.72;
		cnum = anum - bnum;
		dnum = w * 6.39;
		enbr = h * 12.77;
		fnum = dnum + enbr;
		if (f.activity[1].checked)
		{
			fnum *=  1.12;
		}
		else if (f.activity[2].checked)
		{
			fnum *= 1.27;
		}
		else if (f.activity[3].checked)
		{
			fnum *= 1.54;
		}
		tot = Math.round(fnum + cnum);
		alert ("Your total daily caloric maintenance level is " + tot + "calories.")
	} 
	else 
	{
		anum=387
		bnum = a * 7.31
		cnum = anum - bnum;
		dnum = w * 4.91;
		enbr = h * 16.78;
		fnum = dnum + enbr;
		if (f.activity[1].checked)
		{
			fnum *=  1.14;
		}
		else if (f.activity[2].checked)
		{
			fnum *= 1.27;
		}
		else if (f.activity[3].checked)
		{
			fnum *= 1.45;
		}
		tot = Math.round(fnum + cnum);
		alert ("Your total daily caloric maintenance level is " + tot + " calories.")
	}
	
	
}
function chkw(x){
   if (isNaN(parseInt(x))){
      return false;
   } else if (x < 0){
      return false;
   }
   else{
      return true;
   }
}
