
var messageSent = "no";
function frmValidate()
{
	if(document.frmRegister.username.value == "")
	{
		alert("Please enter your Username");
		document.frmRegister.username.focus();
		return false;
	}
	if(document.frmRegister.propID_pass1.value == "")
	{
		alert("Please enter New Password");
		document.frmRegister.propID_pass1.focus();
		return false;
	}
	if(document.frmRegister.propID_pass2.value == "")
	{
		alert("Please confirm your password");
		document.frmRegister.propID_pass2.focus();
		return false;
	}
	if(document.frmRegister.propID_email.value == "")
	{
		alert("Please enter your email address");
		document.frmRegister.propID_email.focus();
		return false;
	}
	if(document.frmRegister.propID_firstname.value == "")
	{
		alert("Please enter your first name");
		document.frmRegister.propID_firstname.focus();
		return false;
	}
	if(document.frmRegister.propID_lastname.value == "")
	{
		alert("Please enter your last name");
		document.frmRegister.propID_lastname.focus();
		return false;
	}
	if(!document.frmRegister.checkbox.checked)
	{
		alert("Please select the PrivacyPoly box");
		document.frmRegister.checkbox.focus();
		return false;
	}


    if (!isEmailAddr(document.frmRegister.propID_email.value))
    {
		alert("Please enter a valid email address");
		document.frmRegister.propID_email.focus();
		return false;
	}
	if (document.frmRegister.propID_pass1.value != document.frmRegister.propID_pass2.value)
	{
		alert("Please ensure that your confirm password field matches your new password field");
		document.frmRegister.propID_pass1.value = '';
		document.frmRegister.propID_pass2.value = '';
		document.frmRegister.propID_pass1.focus();
		return false;
	}
	if (messageSent == "no")
	{
		messageSent = "yes";
		document.frmRegister.submitprofile.value='Register';
		document.frmRegister.cancel.value='';
		document.frmRegister.submit();
		return true;
	}
}

function isEmailAddr(email)
{
	var result = false
	var theStr = new String(email)
	var index = theStr.indexOf("@");

	if (index > 0)
	{
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}

