function showwaisttohipratio()
{
	var fwaist, fhip, bsex;
	var frmwthratio;
	frmwthratio = document.getElementById("frmwthratio");

	fwaist = document.getElementById("txtwaist");
	fhip = document.getElementById("txthip");
	
	if (fwaist.value)
	{
		if(isNaN(fwaist.value))
		{
			alert("Please enter your waist measurement (cm).");
			fwaist.focus;
		}
		else
		{
			if (fhip.value)
			{
				if(isNaN(fhip.value))
				{
					alert("Please enter your hip measurement (cm).");
					fhip.focus;
				}
				else
				{
					bsex = findcheckedvalue(frmwthratio.radsex);

					calcwaisttohip(fwaist.value, fhip.value, bsex);
					window.open("RecordCalcResults.asp?ans=wthr&ans=" + fwaist.value + "&ans=" + fhip.value + "&ans=" + bsex, "", "width=50,height=50");
				}
			}
		}
	}
}

function hidewaisttohipratio()
{
	hideelem("divhealthy");
	hideelem("divseveral");	
}

function calcwaisttohip(fwaist, fhip, bsex)
{
	var fratio;

	fratio = parseFloat(fwaist)/parseFloat(fhip);
	
	hidewaisttohipratio();

	if (bsex == 'male')
	{
		if (fratio < 0.900)
		{
			showelem("divhealthy");
		}
		else
		{
			showelem("divseveral");
		}
		document.getElementById("idealwthr1").innerHTML = "0.9";
		document.getElementById("idealwthr2").innerHTML = "0.9";
	}
	else
	{
		if (fratio < 0.800)
		{
			showelem("divhealthy");
		}
		else
		{
			showelem("divseveral");
		}
		document.getElementById("idealwthr1").innerHTML = "0.8";
		document.getElementById("idealwthr2").innerHTML = "0.8";
	}

	document.getElementById("swthr1").innerHTML = "" + format(fratio, 2);
	document.getElementById("swthr2").innerHTML = "" + format(fratio, 2);
}
