function BuyerRegistration_OnValidate(oForm){
	try{

		if ( oForm.slSalutation.value.length == 0 ){
			alert("Please select an appropriate salutation");
			oForm.slSalutation.focus();
			return false;
		}
		if ( oForm.txtContactFirstName.value.length == 0 ){
			alert("Please enter your first name");
			oForm.txtContactFirstName.focus();
			return false;
		}
		if ( oForm.txtContactLastName.value.length == 0 ){
			alert("Please enter your last name");
			oForm.txtContactLastName.focus();
			return false;
		}
		//validate address details if available
		if ( oForm.txtHouseNameOrNumber ){
			if ( oForm.txtHouseNameOrNumber.value.length == 0 ){
				alert("Please enter the house name or number of the address where you live");
				oForm.txtHouseNameOrNumber.focus();
				return false;
			}
		}
		if ( oForm.txtStreet ){
			if ( oForm.txtStreet.value.length == 0 ){
				alert("Please enter the street name of the address where you live");
				oForm.txtStreet.focus();
				return false;
			}
		}
		if ( oForm.txtTownOrCity ){
			if ( oForm.txtTownOrCity.value.length == 0 ){
				alert("Please enter the town or city name of the address where you live");
				oForm.txtTownOrCity.focus();
				return false;
			}
		}
		if ( oForm.txtCounty ){
			if ( oForm.txtCounty.value.length == 0 ){
				alert("Please enter the county name of the address where you live");
				oForm.txtCounty.focus();
				return false;
			}
		}
		if ( oForm.txtPostcode.value.length == 0 ){
			alert("Please enter a valid UK postcode");
			oForm.txtPostcode.focus();
			return false;
		}
		//at least one telephone number required
		if ( oForm.txtHomeTelephone.value.length == 0 && oForm.txtWorkTelephone.value.length == 0 && oForm.txtMobileTelephone.value.length == 0 ){
			alert("Please provide at least one telephone number so that we can contact you");
			oForm.txtHomeTelephone.focus();
			return false;
		}

		if ( oForm.txtEmailAddress.value.length == 0 ){
			alert("Please provide a valid email address");
			oForm.txtEmailAddress.focus();
			return false;
		}
		
		//check they've entered valid min price if entered
		if ( oForm.txtMinimumPrice.value.length > 0 && isNaN(oForm.txtMinimumPrice.value) ){
			alert("The minimum price you have entered is not numeric, please correct and try again");
			oForm.txtMinimumPrice.focus();
			return false;
		}
		if ( isNaN(oForm.txtMaximumPrice.value) && oForm.txtMaximumPrice.value.length > 0 ){
			alert("The maximum price you have entered is not numeric, please correct and try again");
			oForm.txtMaximumPrice.focus();
			return false;
		}
		if ( oForm.txtMaximumPrice.value.length == 0 ){
			alert("Please enter a maximum price");
			oForm.txtMaximumPrice.focus();
			return false;
		}
		
		oCookieManager.StoreFormData();
		return true;
	}catch(e){
		return false;
	}

}

function Registration_Page_OnLoad(){
	//check offices
	if ( typeof document.frmRegister.chkOfficeRegister.length == "undefined" ){
		HttpManager.Document.GetObject("chkOfficeRegister").checked = true;
	}else{
		for ( var i = 0; i < document.frmRegister.chkOfficeRegister.length; i ++ ){
			document.frmRegister.chkOfficeRegister[i].checked = true;
		}
	}
}

function Registration_chkOfficeRegister_OnClick(o){
	var iselected = 0;
	if ( typeof document.frmRegister.chkOfficeRegister.length == "undefined" ){
		if ( o.checked ){
			iselected = 1;
		}
	}else{
		for ( var i = 0; i < document.frmRegister.chkOfficeRegister.length; i ++ ){
			if ( document.frmRegister.chkOfficeRegister[i].checked ){
				iselected ++;
			}
		}
	}
	if ( iselected == 0 ){
		alert("You must select at least one office to register with");
		o.checked = true;
	}
}
