{include_php file="shared_handle:getProfile"}

<form name="calculateBMIForm" 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="{$user->initialWeight}"></td>
		</tr>
			<td align="right"><b>Height in inches</b></td>
			<td><input type="text" class="textInput" name="height"></td>
			<!-- <b>Weight in lbs:</b> <input type="text" class="textInput" name="weightlbs" > <a href="javascript://document.joinCompForm.submit();" class="button">Join</a><br /> -->
		<tr>
		  <td align="right"></td>
		  <td><a href="javascript:calculateBMI();" class="button">Submit</a></td>
		</tr>
	</table>
</form>

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

function calculateBMI()
{
	var weight = document.calculateBMIForm.weightlbs.value;
	var height = document.calculateBMIForm.height.value;
	
	var meters = height / 39.37;
	var kilograms = weight / 2.2;
	
	var metersSquared = Math.pow(meters, 2);
	var bmi = kilograms / (meters^2);

	alert("BMI: " + bmi);
}

{/literal}
</script>