
function doMaxOxygenUptakeCalc ()
{


   var calc = 0;
   var calc1 = 0;
   var calc2 = 0;
   var calc3 = 0;
   var calc4 = 0;
   var subtractor = 0;

   if (sex == MALE)
   {
      subtractor = MOU_M_SUBTRACTOR;
   }
   else
   {
      subtractor = MOU_F_SUBTRACTOR;
   }

   calc1 = MOU_AGE * age;
   calc2 = MOU_WEIGHT * (kilosToPounds (weight));
   calc3 = MOU_WALK_TIME * walkTime;
   calc4 = MOU_EX_HEART_RATE * exHeartRate;

   calc = subtractor - calc1 - calc2 - calc3 - calc4;


   calc = Math.round (calc);

   return calc;

}


function doBodyFatDistributionCalc ()
{



   return roundFloat ((waist / hips), 2);
   
}


function doBodyFatPercentEstCalc ()
{
//#top doBodyFatPercentEstCalc

   var bodyDensity = 0;

   if (sex == MALE)
   {
      bodyDensity = doMaleBodyDensityCalc ();
   }
   else
   {
      bodyDensity = doFemaleBodyDensityCalc ();
   }

   temp = (BF_NUMERATOR / bodyDensity) - BF_SUBTRACTOR;

   // round the result to one decimal place
   return roundFloat (temp,1);

} //#end doBodyFatPercentEstCalc

/**
 * calculate the Body Density (used for getting
 * the estimated body fat % for a woman
 */
function doFemaleBodyDensityCalc ()
{
//#top doFemaleBodyDensityCalc

   var bodyDensity = 0;
   var calc1 = 0;
   var calc2 = 0;
   var calc3 = 0;
   var calc4 = 0;
   var calc5 = 0;

   // these calculations are based on cm so convert all values to
   // cm before calculating
   calc1 = BF_F_ABDOMEN * abdomen;
   calc2 = BF_F_ABDOMEN_SQUARED * square (abdomen);
   calc3 = BF_F_HIPS * hips;
   calc4 = BF_F_HEIGHT * height;
   calc5 = BF_F_AGE * age;

   bodyDensity = BF_F_SUBTRACTOR - calc1  + calc2 - calc3 + calc4 - calc5;

   return bodyDensity;

} //#end doFemaleBodyDensityCalc

/**
 * calculate the Body Density (used for getting
 * the estimated body fat %) for a man
 */
function doMaleBodyDensityCalc ()
{
//#top doMaleBodyDensityCalc

   var bodyDensity = 0;
   var calc1 = 0;
   var calc2 = 0;
   var calc3 = 0;
   var calc4 = 0;

   // these calculations are based on cm 
   calc1 = BF_M_WEIGHT * weight;
   calc2 = BF_M_ILIAC * iliac;
   calc3 = BF_M_HIPS * hips;
   calc4 = BF_M_ABDOMEN * abdomen;

   bodyDensity = BF_M_ADDER + calc1 - calc2 - calc3 - calc4;

   return bodyDensity;

} //#end doMaleBodyDensityCalc

/**
 * calculate the Body Mass Index
 */
function doBodyMassIndexCalc ()
{
//#top doBodyMassIndexCalc

   var temp = (weight / square (height/100));

   // round the result to a whole number
   return Math.round (temp);

} //#end doBodyMassIndexCalc

/**
 * calculate the low end Target Heart Rate
 */
function doTargetHeartRateLowCalc ()
{
//#top doTargetHeartRateLowCalc

   var temp = (220 - age) * TARGET_HEART_RATE_LOW;

   // round the results to a whole number
   return Math.round (temp);


} //#end doTargetHeartRateLowCalc


/**
 * calculate the high end Target Heart Rate
 */
function doTargetHeartRateHighCalc ()
{
//#top doTargetHeartRateHighCalc

   return (220 - age) * TARGET_HEART_RATE_HIGH;

} //#end doTargetHeartRateHighCalc

//*************************************************
// helper functions
//*************************************************
/**
 * square
 * 
 * @param aValue the value you want squared
 * @return the squared value
 */
function square (aValue)
{
//#top square

   return aValue * aValue;

} //#end square

/**
 * round a number to the desired number of decimal places
 *
 * @param num the number being rounded
 * @param places the number of decimal places to round to 
 */
function roundFloat (num, places)
{
//#top roundFloat 

   var multiplier = 10;
   var i = 0;

   for (i=1; i<places; i++)
   {
      multiplier = multiplier * 10;
   }

   temp = Math.round (num * multiplier);

   return temp / multiplier;
     
}  //#end roundFloat
