
/* $Revision: 5 $
 * $Author: Kiran $
 * $Date: 11/12/09 2:17p $
 * $Logfile: /Development/Property Phase1/Web/BuyerManager/js/incREzyBuyers.js $
 * $NoKeywords: $
 */

/* Purpose: Realestateezy.com.au Buyersregistration form functions. */
		function ValidateInput(frm, blnQSearch) {
		
		var strMsg = "";
		var blnRet = true;
		
			// Alliance Name is mandatory
			
			
			if (frm.AllianceID.value == 0) {
				strMsg = strMsg + " Please choose an Market Operator." + "\n";
				SetFocusCtl(frm.AllianceID)
				}

			  // Contact Mobile is mandatory
			  
				if (IsEmptyString(frm.ContactMobile.value)) {
					strMsg = strMsg + " Please enter mobile no." + "\n";
					SetFocusCtl(frm.ContactMobile)
				}
				// ContactEmail is mandatory
				if (IsEmptyString(frm.ContactEmail.value)) {
					strMsg = strMsg + " Please enter your email address." + "\n";
					SetFocusCtl(frm.ContactEmail)
				}
				else {
					if (!IsValidEmail(frm.ContactEmail.value)) {
						strMsg = strMsg + " Invalid Email address." + "\n";
						SetFocusCtl(frm.ContactEmail)
					}
				}
			// eMail Check
			if (frm.ContactEmail.value != frm.ConfirmEmail.value) {
					strMsg = strMsg + " Confirm EMail you entered do not match.\n";
					SetFocusCtl(frm.ConfirmEmail);
			}
				// Contact Title is mandatory
				
				if (IsEmptyString(GetValueFromCtl(frm.ContactTitleID))) {
				
					strMsg = strMsg + " Please choose a title." + "\n";
					SetFocusCtl(frm.ContactTitleID)
				}
				// ContactFirstName is mandatory
				if (IsEmptyString(frm.ContactFirstName.value)) {
					strMsg = strMsg + " Please enter your first name." + "\n";
					SetFocusCtl(frm.ContactFirstName)
				}
				
				
				// MailingPostcode is mandatory
			//	if (IsEmptyString(frm.MailingPostcode.value)) {
				//	strMsg = strMsg + " Please enter a postcode." + "\n";
				//SetFocusCtl(frm.MailingPostcode)
			//	}
	
			
			// Signature Check
			if (!frm.SignedAgreement.checked) {
				strMsg = strMsg + " You must accept the Agreement to register.\n";
				SetFocusCtl(frm.SignedAgreement);
			}
			//else if (frm.agreement.value != frm.ReTypePassword.value) {
			//		strMsg = strMsg + " The passwords you entered do not match.\n";
			//		SetFocusCtl(frm.agreement);
			//}
			/*} else {
		if (IsNVDValid(frm)) {
			if (window.confirm("Please confirm that you are the authorized producer to sign this nvd.")) {
				frm.Svr.value = ""; //"ShowNVD";
				frm.cmd.value="save";
				frm.NVDSigned.value=1;
				frm.submit();
				return true;
			} else {
				window.alert ("Please save & ensure the correct person logs-in to be able to sign this. You may need to log-out and try again or save & send this to the correct person (see below).");
				return false;
			}
		}
	}*/
	
		// check if there's a msg to display
		if (strMsg.length > 0) {
			blnRet = false;
			strMsg = "Please take note of the following when completing the form:\n" + strMsg;
			alert (strMsg);
			m_ctlFocus.focus();
		}
		return blnRet;
	}
	function Save(frm) {
			if (ValidateInput(frm)){			
			frm.Svr2.value="save";		
			frm.submit();
		}	
		return false;
	}