
function wh_ratio(){
	
	waist_val = stripAlphaChars($("waist").value);
	hip_val = stripAlphaChars($("hip").value);
	
	if(waist_val=="" || hip_val =="") return _no_values();
	
	if($("male").checked == true){
		gender = "male";
	}
	else{
		gender = "female";
	}
	
	ratio = (waist_val/hip_val); 
	
	_show_hip(Math.round(ratio*Math.pow(10,2))/Math.pow(10,2), gender);
	return false;
	
}

function toggle_units(unit_to_show){
	
	$("unit_waist").innerHTML = unit_to_show;
	$("unit_hip").innerHTML = unit_to_show;
	return true;

}



function _show_hip(ratio, gender){

	hide_div("error_block");
	hide_div("hip_div");
	
	ratio.parseFloat;
	
	start = "<p class=\"txt-medium\">Your waist-hip ratio  is <strong>" + ratio + "</strong></p>";
	end = "<p class=\"txt-small\">Always consult your doctor before you begin any diet or exercise programme.</p> \
<p class=\"txt-small\">Your waist-to-hip ratio on its own is not enough to assess whether your weight is within a healthy range for your height.  <a href=\"http://www.eidoactive.co.uk/healthy-weight/bmi-calculator\" title=\"BMI (Body Mass Index) calculator\">Click here to go to the BMI (Body Mass Index) calculator</a>.</p>";
	
	if(gender=="male"){
		
		if(ratio < 0.95){
			$("hip_div").className = "normal";
			result = "<p>You are at a <strong class=\"txt-medium\">low risk</strong>.<br/>Try to maintain a healthy diet and lifestyle.</p>";
			
		}
		else if(ratio >= 0.96  &&  ratio <= 1){
			$("hip_div").className = "overweight";
			result = "<p>You are at a <strong class=\"txt-medium\">moderate risk</strong>.<br/>Your health will benefit from a diet and exercise programme aimed at you losing weight from your middle.</p>";
		}
		else if(ratio > 1){
			$("hip_div").className = "obese";
			result = "<p>You are at a <strong class=\"txt-medium\">high risk</strong>.<br/>Your health will benefit from a diet and exercise programme aimed at you losing weight from your middle.</p>";
		}
	}
	else{
		
		if(ratio < 0.80){
			$("hip_div").className = "normal";
			result = "<p>You are at a <strong class=\"txt-medium\">low risk</strong>. Try to maintain a healthy diet and lifestyle.</p>"
		}
		else if(ratio >= 0.81  &&  ratio <= 0.85){
			$("hip_div").className = "overweight";
			result = "<p>You are at a <strong class=\"txt-medium\">moderate risk</strong>.<br/>Your health will benefit from a diet and exercise programme aimed at you losing weight from your middle.</p>";
		}
		else if(ratio > 0.85){
			$("hip_div").className = "obese";
			result = "<p>You are at a <strong class=\"txt-medium\">high risk</strong>.<br/>Your health will benefit from a diet and exercise programme aimed at you losing weight from your middle.</p>";
		}
		
	}
	
	$("hip_div").innerHTML = start + result + end;
	Effect.Appear("hip_div", {duration:0.3});
	return true;
	
}
