{include_php file="shared_handle:getProfile"}

Note: You must have Javascript enabled to use these calculators.
<br/>
<hr>
<form name="BMIForm" method="post" style="margin:4px;">
	Calculate your Body Mass Index (BMI) by filling out the information below and clicking "Submit"<br /><br />
	<table cellspacing="2" cellpadding="2" border="0">
		<tr>
			<td align="right"><b>Weight in lbs</b></td>
		  	<td><input type="text" class="textInput" name="weightlbs" value="{$userProfile.initialWeight}"></td>
		</tr>
		<tr>
			<td align="right"><b>Height in inches</b></td>
			<td><input type="text" class="textInput" name="height" value="{$userProfile.height}"></td>
		</tr>
		<tr>
		  	<td align="right"></td>
		  	<td><a href="javascript:calculateBMI();" class="button">Submit</a></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><textarea name="BMIText" cols="45" rows="4" disabled="disabled"></textarea></td>
		</tr>
	</table>
</form>
<hr>

<form name="HeartRangeForm" method="post" style="margin:4px;">
	Calculate your ideal heart rate range by filling out the information below and clicking "Submit"<br /><br />
	<table cellspacing="2" cellpadding="2" border="0">
		<tr>
			<td align="right"><b>Age</b></td>
		  	<td><input type="text" class="textInput" name="age" value="{$userProfile.age}"></td>
		</tr>
		<tr>
		  	<td align="right"></td>
		  	<td><a href="javascript:calculateHeartRange();" class="button">Submit</a></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><textarea name="HeartRangeText" cols="45" rows="4" disabled="disabled"></textarea></td>
		</tr>
	</table>
</form>
<hr>

<form name="TargetWeightForm" method="post" style="margin:4px;">
	Calculate your target weight by filling out the information below and clicking "Submit"<br /><br />
	<table cellspacing="2" cellpadding="2" border="0">
		<tr>
			<td align="right"><b>Percent Body Fat</b></td>
		  	<td><input type="text" class="textInput" name="percentBodyFat" value=""></td>
		</tr>
		<tr>
			<td align="right"><b>Current Weight</b></td>
			<td><input type="text" class="textInput" name="weight" value="{$userProfile.initialWeight}"></td>
		</tr>
		<tr>
			<td align="right"><b>Desired Percent Body Fat</b></td>
			<td><input type="text" class="textInput" name="desiredBodyFat" value=""></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><a href="javascript:calculateTargetWeight();" class="button">Submit</a></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><textarea name="TargetWeightText" cols="45" rows="15" disabled="disabled"></textarea></td>
		</tr>
	</table>
	<br/>
	Percentage of body fat falls into the following ranges:<br/>
	Acceptable percentage for decreased health risk for men is less than 25%<br/>
	Acceptable percentage for decreased health risk for women is less than 32%<br/>
	Acceptable percentage for optimal fitness performance for men is less than 15%<br/>
	Acceptable percentage for optimal fitness performance for women is less than 23%<br/>
	<br/>
</form>
<hr>

<form name="HipWaistForm" method="post" style="margin:4px;">
	Calculate your Hip-to-Waist ratio by filling out the information below and clicking "Submit".<br />
	If you bend to the side, the place where your stomach creases is where you should measure your waist. Measure your hips around the largest part of your buttocks.<br />
	<table cellspacing="2" cellpadding="2" border="0">
		<tr>
			<td align="right"><b>Your waist circumference in inches</b></td>
		  	<td><input type="text" class="textInput" name="waist" value=""></td>
		</tr>
		<tr>
			<td align="right"><b>Your hip circumference in inches</b></td>
			<td><input type="text" class="textInput" name="hip" value=""></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><a href="javascript:calculateHipWaistRatio();" class="button">Submit</a></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><textarea name="HipWaistText" cols="45" rows="4" disabled="disabled"></textarea></td>
		</tr>
	</table>
	<br/>
	For men:<br/>
	The ideal ratio is less than .85.<br/>
	The desireable ratio is .85 - .94.<br/>
	You are at risk at .95+<br/>
	<br/>
	For women:<br/>
	The ideal ratio is less than .75.<br/>
	The desireable ratio is .75 - .79.<br/>
	You are at risk at .8+<br/>
	<br/>
	<br/>
</form>
<hr>

<form name="CalorieForm" method="post" style="margin:4px;">
	Calculate the number of calories you need at rest and how many calories you have to cut out to lose a certain amount of weight by filling out the information below and clicking "Submit".<br />
	<table cellspacing="2" cellpadding="2" border="0">
		<tr>
			<td align="right"><b>Weight in lbs</b></td>
		  	<td><input type="text" class="textInput" name="weightlbs" value="{$userProfile.initialWeight}"></td>
		</tr>
		<tr>
			<td align="right"><b>Height in inches</b></td>
			<td><input type="text" class="textInput" name="height" value="{$userProfile.height}"></td>
		</tr>
		<tr>
			<td align="right"><b>Age</b></td>
		  	<td><input type="text" class="textInput" name="age" value="{$userProfile.age}"></td>
		</tr>
		<tr>
			<td align="right"><b>Pounds to lose</b></td>
		  	<td><input type="text" class="textInput" name="poundsToLose" value=""></td>
		</tr>
		<tr>
			<td align="right"><b>Time frame to lose them in days</b></td>
		  	<td><input type="text" class="textInput" name="days" value=""></td>
		</tr>
		<tr>
			<td align="right"><b>Male</b></td>
			<td><input type="radio" name="gender" value="male"></td>
			<td align="right"><b>Female</b></td>
			<td><input type="radio" name="gender" value="female"></td>
		<tr>
			<td align="right"></td>
			<td><a href="javascript:calculateCalories();" class="button">Submit</a></td>
		</tr>
		<tr>
			<td align="right"></td>
			<td><textarea name="CalorieText" cols="75" rows="15" disabled="disabled"></textarea></td>
		</tr>
	</table>
	<br/>
</form>
<hr>

<script language="JavaScript" type="text/javascript">
{literal}

function calculateBMI()
{
	var weight = document.BMIForm.weightlbs.value;
	var height = document.BMIForm.height.value;

	if (height == 0)
	{
		alert("You must enter a valid height!");
		return;
	}

	if (weight == 0)
	{
		alert("You must enter a valid weight!");
	}

	var meters = height / 39.37;
	var kilograms = weight / 2.2;

	var metersSquared = Math.pow(meters, 2);
	
	var bmi = kilograms / metersSquared;

	document.BMIForm.BMIText.value = "Your Body Mass Index is " + bmi;
}

function calculateHeartRange()
{
	var age = document.HeartRangeForm.age.value;

	if (age == 0)
	{
		alert("You must enter a valid age!");
		return;
	}

	var maxHeartRange = 220 - age;

	var targetLow = .6 * maxHeartRange;
	var targetHigh = .9 * maxHeartRange;

	document.HeartRangeForm.HeartRangeText.value = "Healthy Heart Range is " + Math.round(targetLow) + " - " + Math.round(targetHigh);
}

function calculateTargetWeight()
{
	var percentBodyFat = document.TargetWeightForm.percentBodyFat.value;
	var weight = document.TargetWeightForm.weight.value;
	var desiredBodyFat = document.TargetWeightForm.desiredBodyFat.value;

	if (percentBodyFat == 0)
	{
		alert("You must enter a valid Percent Body Fat");
		return;
	}

	if (weight == 0)
	{
		alert("You must enter a valid weight!");
		return;
	}

	if (desiredBodyFat == 0)
	{
		alert("You must enter a valid Desired Body Fat!");
		return;
	}

	var currentFatWeight = (percentBodyFat / 100) * weight;
	var currentLeanBodyWeight = weight - currentFatWeight;
	var targetWeight = currentLeanBodyWeight / (1 - (desiredBodyFat / 100));
	var poundsToLose = weight - targetWeight;

	var outputString = "Current Fat Weight is " + Math.round(currentFatWeight) + " lbs." +
						"\nCurrent Lean Body Weight is " + Math.round(currentLeanBodyWeight) + " lbs." +
						"\nTarget Weight should be " + Math.round(targetWeight) + " lbs." +
						"\n\nYou need to lose " + Math.round(poundsToLose) + " lbs to reach the target weight.";

	document.TargetWeightForm.TargetWeightText.value = outputString;
}

function calculateHipWaistRatio()
{
	var waist = document.HipWaistForm.waist.value;
	var hip = document.HipWaistForm.hip.value;

	if (waist == 0)
	{
		alert("You must enter a valid waist size!");
		return;
	}

	if (hip == 0)
	{
		alert("You must enter a valid hip size!");
		return;
	}

	var ratio = waist / hip;

	document.HipWaistForm.HipWaistText.value = "Your hip-to-waist ratio is " + ratio + ".";
}

function calculateCalories()
{
	var SEDENTARY = 1.1;
	var LIGHT = 1.2;
	var MODERATE = 1.3;
	var ACTIVE = 1.4;

	var weight = document.CalorieForm.weightlbs.value;
	var height = document.CalorieForm.height.value;
	var age = document.CalorieForm.age.value;
	var poundsToLose = document.CalorieForm.poundsToLose.value;
	var days = document.CalorieForm.days.value;

	if (document.CalorieForm.gender[0].checked == true)
	{
		value = 5;
	}
	else if (document.CalorieForm.gender[1].checked == true)
	{
		value = -161;
	}
	else
	{
		alert("You must enter in a gender!");
		return;
	}

	if (weight == 0)
	{
		alert("You must enter a valid weight!");
		return;
	}

	if (height == 0)
	{
		alert("You must enter a valid height!");
		return;
	}

	if (age == 0)
	{
		alert("You must enter a valid age!");
		return;
	}

	if (poundsToLose == 0)
	{
		alert("You must enter a valid entry for how many pounds to lose!");
		return;
	}

	if (days == 0)
	{
		alert("You must enter a valid entry for how many days to lose the pounds in!");
		return;
	}

	var centimeters = (height / 39.37) * 100;
	var kilograms = weight / 2.2;

	var restingEnergyE = 0;

	restingEnergyE = (value + (10 * kilograms) + (6.25 * centimeters) - (5 * age));
	var caloriesToLose = poundsToLose * 3500;
	var caloriesPerDay = caloriesToLose / days;

	var outputString = "The amount of calories you need at rest per activity level:\n\nSedentary: " + Math.round((restingEnergyE * SEDENTARY)) + 
					   "\nLight: " + Math.round((restingEnergyE * LIGHT)) +
					   "\nModerate: " + Math.round((restingEnergyE * MODERATE)) +
					   "\nActive: " + Math.round((restingEnergyE * ACTIVE)) + 
					   "\n\nYou need to trim " + Math.round(caloriesPerDay) + " calories per day to lose " + poundsToLose + " lbs in " + days + " days.";

	document.CalorieForm.CalorieText.value = outputString;
}

{/literal}
</script>