<!-- Author: Brian Mackenzie -->
<!-- Date: 1st June 2004 -->
<!-- Version: 1.0 -->

<!-- Function:  calculate calories in diet -->

<!-- Required by: nutrit.htm -->

<!-- Copyright Brian Mackenzie 2004 -->

function caloriecalculate()
{
  var hours = document.calorie.hours.value;
  var weightunits = document.calorie.weightunits.options[document.calorie.weightunits.selectedIndex].value;
  var weight = document.calorie.weight.value;

  if (weightunits == "pounds")
    {
      weight /= 2.2;
    }

  var basic = weight *24 *1.3;    
  var extra = weight * hours * 8.5;
  var total = basic + extra;
  carb = total * 0.57 / 4;
  pro = total * 0.13 / 4;
  fat = total * 0.3 / 9;
          
  document.calorie.basic.value = Math.round(basic);
  document.calorie.extra.value = Math.round(extra);
  document.calorie.total.value = Math.round(total);
  document.calorie.carb.value = Math.round(carb);
  document.calorie.pro.value = Math.round(pro);
  document.calorie.fat.value = Math.round(fat);
}



function valclear()

{
  document.calorie.basic.value = "";
  document.calorie.extra.value = "";
  document.calorie.total.value = "";
  document.calorie.carb.value = "";
  document.calorie.pro.value = "";
  document.calorie.fat.value = "";
}
