 function rexcalc() {
 var x=0,y=0,z=0,a=0,b=0,c=0,d=0,e=0,mult=0;
 if ((document.calcform.iheightf.value==0)&&(document.calcform.iheighti.value==0))
 {}
 else
 { x=(Math.round(document.calcform.iheightf.value*12));
 y=(Math.round(document.calcform.iheighti.value*10)/10);
 z=x+y;
 document.calcform.height.value=(Math.round(z*2.54)/100);
 }
 if ((document.calcform.iweights.value==0)&&(document.calcform.iweightp.value==0))
 {}
 else { a=(Math.round(document.calcform.iweights.value*14));
 b=(Math.round(document.calcform.iweightp.value*10)/10);
 c=a+b;
 document.calcform.weight.value=(Math.round(c*45.359)/100);
 }
 if ((document.calcform.height.value==0)||(document.calcform.weight.value==0))
 {document.calcform.bmi.value="N/calc";
  document.calcform.adstat.value='';}
 else {
 document.calcform.bmi.value=(Math.round(10*document.calcform.weight.value/(document.calcform.height.value*document.calcform.height.value))/10);}
 document.calcform.moreadvice.value="";
 document.calcform.adstat.value="Statement applicable to adults only";
 if (document.calcform.bmi.value<20) {
   document.calcform.advice.value="This is underweight - is subject eating enough?";}
else {
 if (document.calcform.bmi.value<25) {
    document.calcform.advice.value="Weight within acceptable range for health";}
 else {
 if (document.calcform.bmi.value<30) {
    document.calcform.advice.value="Overweight, but health unlikely to suffer. Subject should not get any fatter!";}
 else {
  if (document.calcform.bmi.value>=30) {
    document.calcform.advice.value="Very overweight - health may suffer if subject does not lose weight";
    document.calcform.moreadvice.value="For this height: weight should be ideally no more than ";
	d=(Math.round(document.calcform.height.value*100)/100);
	e=(Math.round(249*d*d)/10);
	document.calcform.moreadvice.value=document.calcform.moreadvice.value+e+"kg";}
  else
	{document.calcform.advice.value="";}
 }}}}
 function rexclear() {
 document.calcform.height.value='';
 document.calcform.weight.value='';
 document.calcform.iheightf.value='';
 document.calcform.iheighti.value='';
 document.calcform.iweights.value='';
 document.calcform.iweightp.value='';
 document.calcform.bmi.value='';
 document.calcform.advice.value="";
 document.calcform.moreadvice.value="";
 document.calcform.adstat.value="";
 x=0;
 y=0;
 z=0;
 a=0;
 b=0;
 c=0;
 document.calcform.height.focus();
 }
 function bmrcalc() {
  var x=0,y=0,z=0,a=0,b=0,c=0,d=0,e=0;
  a=(Math.round(document.calcform.iweights.value*14));
  b=(Math.round(document.calcform.iweightp.value*10)/10);
  c=a+b;
  if ((document.calcform.iweights.value>0)||(document.calcform.iweightp.value>0))
  {document.calcform.weight.value=(Math.round(c*45.359)/100);}
  if (document.calcform.weight.value<0.1)
  {document.calcform.bmr.value='n/calc';
   document.calcform.enjday.value='n/calc';
   document.calcform.encalday.value='n/calc';
   document.calcform.advice.value='Weight missing!';}
  else {
  if  (document.calcform.sex[0].checked)
 {if (document.calcform.age.value<10)
 {document.calcform.bmr.value='n/calc';
 document.calcform.bmrcal.value='n/calc';
 document.calcform.enjday.value='n/calc';
 document.calcform.encalday.value='n/calc';
 document.calcform.advice.value='BMR not calculated for subjects <10 years';}
 else
 {document.calcform.advice.value='';
 if (document.calcform.age.value<18)
 {document.calcform.bmr.value=(Math.round((0.074*document.calcform.weight.value+2.754)*100)/100);}
 else
 {if (document.calcform.age.value<30)
 {document.calcform.bmr.value=(Math.round((0.063*document.calcform.weight.value+2.896)*100)/100);}
 else
 {if (document.calcform.age.value<60)
 {document.calcform.bmr.value=(Math.round((0.048*document.calcform.weight.value+3.653)*100)/100);}
 else
 {if (document.calcform.age.value<75)
 {document.calcform.bmr.value=(Math.round((0.0499*document.calcform.weight.value+2.930)*100)/100);}
 else
 {document.calcform.bmr.value=(Math.round((0.035*document.calcform.weight.value+3.434)*100)/100);}
 }}}}}
 else
 { if (document.calcform.age.value<10)
 {document.calcform.bmr.value='n/calc';
 document.calcform.advice.value='BMR not calculated for subjects <10 years';}
 else
 {document.calcform.advice.value='';
 if (document.calcform.age.value<18)
 {document.calcform.bmr.value=(Math.round((0.056*document.calcform.weight.value+2.898)*100)/100);}
 else
 {if (document.calcform.age.value<30)
 {document.calcform.bmr.value=(Math.round((0.062*document.calcform.weight.value+2.036)*100)/100);}
 else
 {if (document.calcform.age.value<60)
 {document.calcform.bmr.value=(Math.round((0.034*document.calcform.weight.value+3.538)*100)/100);}
 else
 {if (document.calcform.age.value<75)
 {document.calcform.bmr.value=(Math.round((0.0386*document.calcform.weight.value+2.875)*100)/100);}
 else
 {document.calcform.bmr.value=(Math.round((0.041*document.calcform.weight.value+2.61)*100)/100);}
 }}}}
 }}
 if (document.calcform.bmr.value=='n/calc')
  {document.calcform.bmrcal.value='n/calc';
   document.calcform.enjday.value='n/calc';
   document.calcform.encalday.value='n/calc';}
 else
 {document.calcform.bmrcal.value=(Math.round(document.calcform.bmr.value*1000/4.184));
  switch (document.calcform.activ1.value) {
  case '1' : switch (document.calcform.activ2.value) {
   case '1' : mult=1.4;
    break;
   case '2' : mult=1.5;
    break;
   case '3' : mult=1.6;
    break;
   }
   break;
  case '2' : switch (document.calcform.activ2.value) {
   case '1' : mult=(document.calcform.sex[0].checked)? 1.6:1.5;
    break;
   case '2' : mult=(document.calcform.sex[0].checked)? 1.7:1.6;
    break;
   case '3' : mult=(document.calcform.sex[0].checked)? 1.8:1.7;
    break;
   }
   break;
  case '3' : switch (document.calcform.activ2.value) {
   case '1' : mult=(document.calcform.sex[0].checked)? 1.7:1.5;
    break;
   case '2' : mult=(document.calcform.sex[0].checked)? 1.8:1.6;
    break;
   case '3' : mult=(document.calcform.sex[0].checked)? 1.9:1.7;
    break;
   }
   break;
  case '4' : switch (document.calcform.activ2.value) {
   case '1' : mult=1.4;
    break;
   case '2' : mult=1.5;
    break;
   case '3' : mult=1.6;
    break;
   }
   break;
  }
  document.calcform.enjday.value=(Math.round(document.calcform.bmr.value*mult*100)/100);
  document.calcform.encalday.value=(Math.round(document.calcform.bmr.value*1000/4.184*mult));
 }
 }
 function bmrclear() {
  document.calcform.age.value='';
  document.calcform.weight.value='';
  document.calcform.iweights.value='';
  document.calcform.iweightp.value='';
  document.calcform.bmr.value='';
  document.calcform.bmrcal.value='';
  document.calcform.enjday.value='';
  document.calcform.encalday.value='';
  x=0;
  y=0;
  z=0;
  a=0;
  b=0;
  c=0;
  document.calcform.advice.value='';
  document.calcform.activ1.value=1;
  document.calcform.activ2.value=1;
  document.calcform.age.focus();
 }
function newfocus(kcode,ax){
if (kcode=="13")
{ax.focus();}
}
