function validateDietForm() {

// Set all values that we will post for email
var newsletterURL = '#';
//var EmailAddr = document.wlc_bmi_calc.EmailAddr.value;
var SiteName = '#';

// Combine all of them into a post
//var postThis = newsletterURL + '?emailaddr=' + EmailAddr + '&sitename=' + SiteName + '&PopUp=3';

// setup expressions for the input fields
var reg_point        = new RegExp("^[1-9][0-9]*[/.,][0-9]+$","g");
var reg_sans_point   = new RegExp("^[1-9][0-9]*$","g");
var reg_sans_point_0 = new RegExp("^(([1-9][0-9]*)|0)$","g");

var current_weight   = document.wlc_bmi_calc.current_weight.value;
var current_weight_kg  = document.wlc_bmi_calc.current_weightkg.value;
var goal_weight = document.wlc_bmi_calc.goal_weight.value;
var goal_weight_kg = document.wlc_bmi_calc.goal_weightkg.value;
var height_feet      = document.wlc_bmi_calc.height_feet.value;
var height_inches      = document.wlc_bmi_calc.height_inches.value;
var age            = document.wlc_bmi_calc.age.value
  
// Popup alerts if they have not filled out all the fields
if(!current_weight.match(reg_sans_point) && !current_weight_kg.match(reg_sans_point)){
	alert("Your current weight seems incorrect.\nPlease check your form.");
	return false;
}
if(!goal_weight.match(reg_sans_point) && !goal_weight_kg.match(reg_sans_point)){
	alert("Your target weight seems incorrect.\nPlease check your form.");
	return false;
}
if(!height_feet.match(reg_sans_point) || !height_inches.match(reg_sans_point_0)){
	alert("Your height seems incorrect.\nPlease check your form.");
	return false;
}
if(!age.match(reg_sans_point)){
	alert("Your age seems incorrect.\nPlease check your form.");
	return false;
}

current_weight = parseInt(current_weight);
goal_weight = parseInt(goal_weight);
current_weightkg= parseInt(current_weight_kg);
goal_weightkg = parseInt(goal_weight_kg);

height = parseInt(convert_feet_inches_to_feet(height_feet,height_inches));
age = parseInt(age);
 
 	if(current_weight!="") {
		if((current_weight < 77.2) || (current_weight > 440.9)){
			alert("The number you entered for your current weight seems unlikely.\nYou must be between 77.2 and 440.9 pounds.");
			return false;
		}
	}


	if(current_weightkg!="") {
		if((current_weightkg < 35.1) || (current_weightkg > 200.41)){
			alert("The number you entered for your current weight seems unlikely.\nYou must be between 35.1 and 200.41 kilos.");
			return false;
		}
	}



if(goal_weight!="") {
	if((goal_weight < 77.2) || (goal_weight > 440.9)){
		alert("The number you entered for your target weight seems unlikely.\nYou must be between 77.2 and 440.9 pounds.");
		return false;
	}

}

if(goal_weightkg!="") {
	if((goal_weightkg < 35.1) || (goal_weightkg > 200.41)){
		alert("The number you entered for your target weight seems unlikely.\nYou must be between 35.1 and 200.41 kilos.");
		return false;
	}

}


if(goal_weight!="" && current_weight!="") {
	if(current_weight < goal_weight){
		alert("We are sorry, but we do not currently provide a program for weight gain. If you'd like to maintain or lose weight, please double-check your entry.");
		return false;
	}
}



if(goal_weightkg!="" && current_weightkg!="") {
	if(current_weightkg < goal_weightkg){
		alert("We are sorry, but we do not currently provide a program for weight gain. If you'd like to maintain or lose weight, please double-check your entry.");
		return false;
	}
}


if((height < 4.27) || (height > 7.22)){
	alert("The number you entered for your height seems unlikely.\nYou must be between 4.27 and 7.22 feet.");
	return false;
}

if((age < 18) || (age > 95)){
	alert("The number you entered for your age is unsuitable.\nYou must be between 18 and 95 years old.");
	return false;
}
/**
// If newsletter is checked do that
if (document.wlc_bmi_calc.signup.checked) {
	emailOK = checkEmailAddr();
	
	if (emailOK) {
		// Run Omniture call
		ctrs('nl_wtlss');
		
		// Post to Image with a string as to not to return a thank you page
		tempImage = new Image();
		tempImage.src = postThis;
		
		// Pausing for one sec to make sure image http request gets processed
		pauseComp(1000);
	}
	else {
		return false;
	}
	
	return true
}
*/
// If gets through above checks submit form
return true;

}

function convert_feet_inches_to_feet(taille_feet,taille_inches){
  taille_feet   = parseInt(taille_feet);
  taille_inches = parseInt(taille_inches);
  return (taille_feet+((Math.round((taille_inches/12)*100))/100));
}

function pauseComp(mls)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < mls);
} 

function propagateFields() {
	var height_feet, height_inches, current_weight, goal_weight;
	tmp = window.location.toString().split('?');
	if (tmp[1]) {
		queryString = tmp[1];
		tmp2 = tmp[1].split('&');
		for (i=0; i<tmp2.length; i++) {
			tmp = tmp2[i].split('=');
			eval(tmp[0] + ' = "' + tmp[1] + '"');
		}
	}
	if (height_feet) {
		document.getElementById('height_feet').value=height_feet;
	}
	if (height_inches) {
		document.getElementById('height_inches').value=height_inches;
	}
	if (current_weight) {
		document.getElementById('current_weight').value=current_weight;
	}
	if (goal_weight) {
		document.getElementById('goal_weight').value=goal_weight;
	}
}

/*
function checkEmailAddr() 
 {
  illegal = /[^\w._\-]/;
  email = document.wlc_bmi_calc.EmailAddr.value;

  if (email.length<6 || email.indexOf("@")==-1 || email.indexOf('.')==-1)
  { email=""; }
  else 
  {
   At = email.indexOf("@");
   Period = email.lastIndexOf('.');
   DNS1 = email.substring(0,At);
   if (DNS1.length<1 || DNS1.match(illegal)!=null) email="";
   DNS2 = email.substring(At+1,Period);
   if (DNS2.length<1 || DNS2.match(illegal)!=null) email="";
   DNS3 = email.substring(Period+1,email.length);
   if (DNS3.length<2 || DNS3.match(illegal)!=null) email="";
  }

  if (email.length==0) 
  {
   alert("The email address you have entered is invalid. Please re-enter a valid email address.\n");
   document.wlc_bmi_calc.EmailAddr.focus();
   return false;
  }
  
  return true;
}
*/
