$(document).ready(function(){
	$(".vtrim_healthtools_output").hide();
	$("#compute_heartrates").click(function(){
		var age = $("#vtrim_age").val();
		if (age.match(/^\d+$/)) {  
			
			var maxrate = 220 - age;
			var moderatelow = .5 * maxrate;
			moderatelow = moderatelow.toFixed(0);
			var moderatehigh = .6 * maxrate;
			moderatehigh = moderatehigh.toFixed(0);
			var maxfatlow = .6 * maxrate;
			maxfatlow = maxfatlow.toFixed(0);
			var maxfathigh = .7 * maxrate;
			maxfathigh = maxfathigh.toFixed(0);
			var aerobiclow = .7 * maxrate;
			aerobiclow = aerobiclow.toFixed(0);
			var aerobichigh = .8 * maxrate;
			aerobichigh = aerobichigh.toFixed(0);
		
			$("#vtrim_maxrate").val(maxrate);
			$("#vtrim_moderatelow").val(moderatelow);
			$("#vtrim_moderatehigh").val(moderatehigh);
			$("#vtrim_maxfatlow").val(maxfatlow);
			$("#vtrim_maxfathigh").val(maxfathigh);
			$("#vtrim_aerobiclow").val(aerobiclow);
			$("#vtrim_aerobichigh").val(aerobichigh);
			$(".vtrim_healthtools_output").hide();
		}else{
			$(".vtrim_healthtools_output").html('&nbsp;Please enter a valid age');
			$(".vtrim_healthtools_output").fadeIn(800);
		}
	});
});