// JavaScript Document

function ValidateRegForm(){ //v2.5.2

	var theForm = document.forms['registration'];
	var emailRE = /(@\w[-._\w]*\w\.\w{2,4})$/;
	var errMsg = "";
	var setfocus = "";

	if (theForm['first_name'].value == ""){
		errMsg += "Please enter your first name.\n";
		setfocus = "['first_name']";
	}
	if (theForm['last_name'].value == ""){
		errMsg += "Please enter your last name.\n";
		setfocus = "['last_name']";
	}
	if (!emailRE.test(theForm['email'].value)){
		errMsg += "Please enter a valid email address.\n";
		setfocus = "['email']";
	}
	if (theForm['phone'].value == ""){
		errMsg += "Please enter your phone number.\n";
		setfocus = "['phone']";
	}
	if (theForm['password'].value==""){
		errMsg += "Please choose a password.\n";
		setfocus = "['password']";
	}else{
		if (theForm['password'].value != theForm['password_confirm'].value ){
			errMsg += "Passwords to not match. Please re-enter your password.\n";
			setfocus = "['password']";
		}
	}

	if (!theForm['chk_terms'].checked){
		errMsg += "You must accept the Terms and Conditions.\n";
		setfocus = "['chk_terms']";
	}

	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}else{
		show_app_info(450, 250); //show the "please wait" popup 
		theForm.submit();
	}
}