function ClearForm (form){form.weight.value="";form.waist.value="";form.bodyfat.value="";}
function VerifyForm(form){
var Correct=true;if (form.weight.value==null||form.weight.value.length==0 ||
form.waist.value==null||form.waist.value.length==0){alert ("\nPlease fill in all of the form elements");Correct=false;}
else{var TestWeight;var TestWaist;TestWeight=parseFloat(form.weight.value);TestWaist=parseFloat(form.waist.value);if (isNaN (TestWeight)){alert("\nMake sure to enter the weight\nas a number.");Correct=false;form.weight.value="";}
if (isNaN (TestWaist)){alert("\nMake sure to enter the waist size\nas a number.");Correct=false;form.waist.value="";}
if (TestWeight <=0){alert("\nCome on.  Enter a real weight.");Correct=false;form.weight.value="";}
if (TestWaist <=0){alert("\nCome on.  Enter a real waist size.");Correct=false;form.waist.value="";}}
if (Correct){
var BF;var BFPercent;if (form.gender[0].checked){BF=-98.42+4.15*TestWaist - .082*TestWeight;}
else{BF=-76.76+(4.15*TestWaist)- (.082*TestWeight);}
BFPercent=BF / TestWeight;BFPercent=BFPercent * 100;BFPercent=Math.round(BFPercent);form.bodyfat.value=BFPercent+"%";}}
function FigureBMI(){if (document.bmi.inches.value==null||document.bmi.inches.value==0 ||
document.bmi.pounds.value==null||document.bmi.pounds.value==0){alert ("\nPlease fill in all of the form elements");}
else{meters=document.bmi.inches.value*0.0254;kilograms=document.bmi.pounds.value*0.4535924;Square=meters * meters;document.bmi.calcval.value=Math.round(kilograms/Square);}}
function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}
function myCon(){var FromVal, ToVal, FromName, ToName, val1, val2, Factor;val1=document.MainForm.amount.value;val2=val1
val1=parseFloat(val1);if (isNaN(val1))val1=1;document.MainForm.amount.value=val1;FromVal=document.MainForm.from[document.MainForm.from.selectedIndex].value;ToVal=document.MainForm.to[document.MainForm.to.selectedIndex].value;FromName=document.MainForm.from.options[document.MainForm.from.selectedIndex].text;ToName=document.MainForm.to.options[document.MainForm.to.selectedIndex].text;Factor=eval("("+FromVal+")/("+ToVal+")");val1 *=Factor;val1=Math.round(val1 *10000000)/10000000;document.MainForm.answer.value=val2+" "+FromName+"="+val1+" "+ToName;}
function calc_hr(){level=document.form1.level.value;val=220-document.form1.age.value;if (document.form1.level[0].checked){val1=val * .4;val2=val * .5;}
if (document.form1.level[1].checked){val1=val * .5;val2=val * .6;}
if (document.form1.level[2].checked){val1=val * .6;val2=val * .8;}
if (document.form1.level[3].checked){val1=val * .7;val2=val * .9;}
document.form1.target1.value=Math.round(val1);document.form1.target2.value=Math.round(val2);}
function computeBMR(form){form.BMRMale.value=Math.round(66.473+((form.weight.value / 2.2 )* 13.751)+(5.0033 * form.height.value * 2.54)- (6.55 * form.age.value));form.BMRFemale.value=Math.round(665.51+((form.weight.value / 2.2 )* 9.463)+(1.8496 * form.height.value * 2.54)- (4.6756 * form.age.value));}
function clearBMR(form){form.age.value="";form.weight.value="";form.height.value="";form.BMRMale.value="";form.BMRFemale.value="";}
function Owt(){var pounds=document.form.pounds.value;var feet=document.form.feet.value;var inches=document.form.inches.value;var waist=document.form.waist.value;var Correct=true;if (document.form.pounds.value==null||document.form.pounds.value.length==0){alert ("\nPlease enter your weight");Correct=false;}
if (document.form.feet.value==null||document.form.feet.value.length==0||
document.form.inches.value==null||document.form.inches.value.lenght==0){alert ("\nPlease enter height - both feet and inches");Correct=false;}
if (document.form.waist.value==null||document.form.waist.value.length==0){alert ("\nPlease enter waist measurement");Correct=false;}
if (Correct){if(document.form.gender[0].checked)
factor=98.42;else factor=76.76;TotalInches=eval(feet*12)+eval(inches);Meters=TotalInches/39.36;Square=Meters * Meters;bfp=((4.15*waist)-factor-0.082*pounds)/pounds;if(document.form.gender[0].checked)
bmiweight=Square*23*2.2;else 
bmiweight=Square*24*2.2;if(document.form.activity[1].checked)
bmiweight=bmiweight-2;else if(document.form.activity[2].checked)
bmiweight=bmiweight-5;else 
bmiweight=bmiweight;if(document.form.age[0].checked)
bmiweight=bmiweight-5;else if(document.form.age[1].checked)
bmiweight=bmiweight;else bmiweight=bmiweight+5;if(document.form.faddiet[0].checked)
bmiweight=bmiweight+5;else bmiweight=bmiweight;if(document.form.gender[0].checked){document.form.goalweight.value=Math.round(bmiweight);document.form.overweight.value=Math.round(pounds-bmiweight);document.form.excessfat.value=Math.round(pounds*(bfp-0.08));}
else{document.form.goalweight.value=Math.round(bmiweight);if ( Math.round(pounds-bmiweight)> 0 ){document.form.overweight.value=Math.round(pounds-bmiweight);document.form.excessfat.value=Math.round(pounds*(bfp-0.13));}
else{document.form.overweight.value=0;document.form.excessfat.value=0;}}}}
function ClearOwtForm(){document.form.pounds.value="";document.form.feet.value="";document.form.inches.value="";document.form.waist.value="";document.form.goalweight.value="";document.form.overweight.value="";document.form.excessfat.value="";}
function CalcCalForm(){if (form.mins.value==null||form.mins.value.length==0 ||
form.weight.value==null||form.weight.value.length==0){alert ("\nPlease fill in all of the form elements");}
else{factor=document.form.exercise[document.form.exercise.selectedIndex].value;form.total.value=Math.round(factor * form.weight.value * form.mins.value);}}
function ClearCalForm(form){form.mins.value="";form.weight.value="";}
function CalcDCI(){if (document.form.inches.value==null||document.form.inches.value.length==0 ||
document.form.pounds.value==null||document.form.pounds.value.length==0 ||
document.form.years.value==null   ||document.form.years.value.length==0){alert ("\nPlease fill in all of the form elements");return;}
var inches=document.form.inches.value;var pounds=document.form.pounds.value;var years=document.form.years.value;var factor=document.form.exercise[document.form.exercise.selectedIndex].value;if (document.form.gender[0].checked){weight=66+(13.7 * (pounds / 2.2));height=5 * (inches * 2.54);age=6.8 * years;document.form.result.value=(Math.round(weight+height - age)* factor);}
else{weight=655+(9.6 * (pounds / 2.2));height=1.7 * (inches * 2.54);age=4.7 * years;document.form.result.value=(Math.round(weight+height - age)* factor);}}
function ClearDCI(){document.form.inches.value="";document.form.pounds.value="";document.form.years.value="";document.form.result.value="";}
