function calculateRatio(waist, hips){
			var ratio = waist/hips;
			var ratio = ratio.toFixed(2);
			var results_string = 'With a waist circumference of '+waist+' inches '+
		         'and a hip circumference of '+hips+' inches your waist to hip '+
				 'ratio is '+ratio+'.';
			var male = 0;
			var female = 0;
			if($("#vtrim_male").is(":checked"))
				male = 1;
			if($("#vtrim_female").is(":checked"))
				female = 1;
			$("#vtrim_waisthipresults").hide();
			$("#vtrim_waisthipresults").html(results_string);
			$("#vtrim_waisthipresults").fadeIn(800);
			if ((ratio >= 1) && (male == 1)) {
				$("#vtrim_apple_male").hide();
				$("#vtrim_apple_male").fadeIn(800);
				$("#vtrim_pear_male").hide();
				$("#vtrim_apple_female").hide();
				$("#vtrim_pear_female").hide();
			}
			else if ((ratio < 1) && (male == 1)) {
				$("#vtrim_apple_male").hide();
				$("#vtrim_pear_male").hide();
				$("#vtrim_pear_male").fadeIn(800);
				$("#vtrim_apple_female").hide();
				$("#vtrim_pear_female").hide();
			}
			else if ((ratio >= .8) && (female == 1)) {
				$("#vtrim_apple_male").hide();
				$("#vtrim_pear_male").hide();
				$("#vtrim_apple_female").hide();
				$("#vtrim_apple_female").fadeIn(800);
				$("#vtrim_pear_female").hide();
			}
			else if ((ratio < .8) && (female == 1)){
				$("#vtrim_apple_male").hide();
				$("#vtrim_pear_male").hide();
				$("#vtrim_apple_female").hide();
				$("#vtrim_pear_female").hide();
				$("#vtrim_pear_female").fadeIn(800);
			}
			else{
				$("#vtrim_waisthipresults").html("Could not calculate.  Please try again.");
				$("#vtrim_apple_male").hide();
				$("#vtrim_pear_male").hide();
				$("#vtrim_apple_female").hide();
				$("#vtrim_pear_female").hide();
			}
}



$(document).ready(function(){
	$("#vtrim_waisthipresults").hide();
	$("#vtrim_apple_male").hide();
	$("#vtrim_pear_male").hide();
	$("#vtrim_apple_female").hide();
	$("#vtrim_pear_female").hide();
	$("#compute_waisthip").click(function(){

		var w = $("#vtrim_waist").val();
		var h = $("#vtrim_hips").val();
		
		//do some validation, then calculate Waist-Hip Ratio
		if((w.match(/^\d*\.?\d*$/)) && (!w.match(/^\.$/)) && (w.match(/.+/))
		  && (h.match(/^\d*\.?\d*$/)) && (!h.match(/^\.$/))  && (h.match(/.+/))){
			calculateRatio(w,h);
		}else{//if the validation fails...
			$("#vtrim_waisthipresults").hide();
			$("#vtrim_waisthipresults").fadeIn(800);
			$("#vtrim_waisthipresults").html("Could not calculate.  Please check your inputs and try again.");
			$("#vtrim_apple_male").hide();
			$("#vtrim_pear_male").hide();
			$("#vtrim_apple_female").hide();
			$("#vtrim_pear_female").hide();
		}
	});
});
