function ArrangeViewing_Forms_Validate(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.txtHomeTelephone.value.length == 0 ){
		alert("Please provide a primary telephone number so that we can contact you");
		oForm.txtHomeTelephone.focus();
		return false;
	}
	
	HttpManager.Document.GetObject("_ctl1_CenterRegion_txtSelectedDate").value = HttpManager.Document.GetObject("_ctl1_CenterRegion_txtDateText").innerHTML;

	oCookieManager.StoreFormData();
	
	}
	catch(e){
		alert("There was an error validating the current viewing request, please contact the agent to complete");
		return false;
	}
	return true;
}

function ArrangeViewing_OnPropertySelectedViewChange(){
	if (typeof document.frmArrangeViewing.chkSavedProperties_SelectedItem.length != "undefined"){
		var iSelected = 0;
		for ( var i = 0; i < document.frmArrangeViewing.chkSavedProperties_SelectedItem.length; i ++ ){
			var oItem = document.frmArrangeViewing.chkSavedProperties_SelectedItem[i];
			if ( oItem.checked ){
				iSelected ++;
			}
		}
		if ( iSelected == 0 ){
			alert("You must select at least one property to view");
			return false;
		}
		
	}else{
		alert("You must select at least one property to view");
		return false;
	}
}

function Page_ArrangeViewing_Calendar_OnClick(){
	HttpManager.Document.GetObject("pnlCalendar").style.visibility = "visible";
}

function Calendar_OnDateSelected(newdate){
	HttpManager.Document.GetObject("_ctl1_CenterRegion_txtDateText").innerHTML = newdate;
	Calendar_OnCancel();
}

function Calendar_OnCancel(){
	HttpManager.Document.GetObject("pnlCalendar").style.visibility = "hidden";
}
