function GetTKFatCal(bmrTarget, protShake, fatPCT, mealQty) {
            return Math.round(((bmrTarget - protShake) * fatPCT/100) / mealQty);
        }

        function GetTKProtCal(bmrTarget, protShake, protPCT, mealQty) {
            return Math.round(((bmrTarget - protShake) * protPCT / 100) / mealQty);
        }

        function GetTKCarbCal(bmrTarget, protShake, carbPCT, mealQty) {
            return Math.round(((bmrTarget - protShake) * carbPCT/100)/ mealQty);
        }

        function GetBMR(male, weight, height, age) {
            
            if (male)
                return Math.round(66 + (13.7*weight) + (5 * height) - (6.8*age));
            else
                return Math.round(655 + (9.6*weight) + (1.7 * height) - (4.7*age));
        }

        function GetBMRAct(bmr, actRate) {
              return Math.round(bmr * actRate);
        }

        function GetBMRTarget(bmrAct, desire) {
              return Math.round(bmrAct * desire);
          }

          function ValidateUserInput(xWeight, xHeight, xAge, mealQty, protShake, fatPct, protPct, carbPct) {
              if (isNaN(xWeight) || xWeight < 40 || xWeight > 200) {
                  alert("Weight must be between 40 and 200 Kilograms (numbers only)");
                  return false;
              }

              if (isNaN(xHeight) || xHeight < 50 || xHeight > 250) {
                  alert("Height must be between 50 and 250 Centimetres (numbers only)");
                  return false;
              }

              if (isNaN(xAge) || xAge < 18 || xAge > 100) {
                  alert("Age must be between 18 and 100 years (numbers only)");
                  return false;
              }
              
              if (isNaN(mealQty) || mealQty < 1 || mealQty > 8) {
                  alert("Meals per day must be between 1 and 8 (numbers only)");
                  return false;
              }
              
              if (isNaN(protShake) || protShake < 0 || protShake > 500) {
                  alert("Protein Shake Calories must be between 0 and 500 Calories (numbers only)");
                  return false;
              }

              if (isNaN(fatPct) || fatPct < 0 || fatPct > 100) {
                  alert("Fat Percentage must be between 0 and 100 (numbers only)");
                  return false;
              }

              if (isNaN(protPct) || protPct < 0 || protPct > 100) {
                  alert("Protein Percentage must be between 0 and 100 (numbers only)");
                  return false;
              }

              if (isNaN(carbPct) || carbPct < 0 || carbPct > 100) {
                  alert("Carbohydrate Percentage must be between 0 and 100 (numbers only)");
                  return false;
              }
              
              if (parseInt(fatPct) + parseInt(protPct) + parseInt(carbPct) != 100) {
                  alert("Protein, Fat and Carbohydrate Percentages must add up to 100");
                  return false;
              }
              
             return true;
         }
