<!-- 

//Percentage and rent calculation
function isBlank(aString) {
	var lString=" ";
	var TempChar;
	var Count;
	var SpacesOnly = 0;
	if (aString.length == 0||aString==""||aString==null)	{
		return(true);
	}

	for (Count=0; Count < aString.length; Count++)	{
		if(aString.charAt(Count) != lString)	{
			return(false);
		}
	}
	
	return(true);
}

function isValid(field, fieldName) {
  var lValue = field.value;
  if(isNaN(field.value) || isBlank(field.value) ) {
		alert("Please enter a numeric value for the field : " + fieldName);
		field.value = "";
		field.focus();
		return false;
  }	

  return true;
}

function stripBad(string) {
  for (var i=0, output='', valid="eE+/*-0123456789.()"; i<string.length; i++)
	 if (valid.indexOf(string.charAt(i)) != -1)
		output += string.charAt(i);
  return output;
}



function CalculateBRM(aForm) {
	var lGender = aForm.gender.value;
	var lWeight = aForm.weight.value;
	var lHeight = aForm.height.value;
	var lAge    = aForm.age.value
	var lWUnits = aForm.sweight.selectedIndex;
	var lHUnits = aForm.sheight.selectedIndex;

	if (isValid(aForm.age, "Age") && isValid(aForm.weight, "Weight") && isValid(aForm.height, "Height")
			) {
/*
		if (lWUnits == 0) {
				alert("Select a unit for weight");
				return false;
		}

		if (lHUnits == 0) {
				alert("Select a unit for weight");
				return false;
		}

		if (lGender == 0) {
				alert("Select a gender");
				return false;
		}

		if (lHUnits != lWUnits) {
			alert("Follow common unit standard for height and weight: either KG/CMS or LBS/Inch");
			return false;
		}
*/
		if (lGender == 1) { //Woman
			if (lWUnits == 0) { //pounds
				wFactor = 4.35 * lWeight;
			} else {
				wFactor = 9.6 * lWeight;
			}

			if (lHUnits == 0) {//Inch
				hFactor = 4.7 * lHeight;
			} else {
				hFactor = 1.8 * lHeight;
			}

			aFactor = 655 - 4.7 * lAge;
		} else { //Man

			if (lWUnits == 0) { //pounds
				wFactor = 6.23 * lWeight;
			} else {
				wFactor = 13.7 * lWeight;
			}

			if (lHUnits == 0) {//Inch
				hFactor = 12.7 * lHeight;
			} else {
				hFactor = 5 * lHeight;
			}

			aFactor = 66 - 6.8 * lAge;
		}

		var BRM = aFactor + hFactor +wFactor;
		var lFoodIntake = BRM;
		
		var lCategory = aForm.category.selectedIndex;
		
		if (lCategory == 0)
			lFoodIntake *= 1.2;
			
		if (lCategory == 1)
			lFoodIntake *= 1.375;
			
		if (lCategory == 2)
			lFoodIntake *= 1.55;
			
		if (lCategory == 3)
			lFoodIntake *= 1.725;
			
		if (lCategory == 4)
			lFoodIntake *= 1.9;
			
		var lFoodIntakeKJ = lFoodIntake * 4.187;

		var lString = lFoodIntake.toFixed(1) + " kcal (" + lFoodIntakeKJ.toFixed(1) + " kj)";					
			
		aForm.brmResult.value = lString;
	}
}


-->
