function Module_Valuation_OnValidate(o){
	
	if ( o.Name_2.value.length == 0 ){
		alert("Please enter your full name");
		o.Name_2.focus();
		return false;
	}	
	
	if ( o.Email_Address_3.value.length == 0 ){
		alert("Please enter your email address");
		o.Email_Address_3.focus();
		return false;
	}
	
	if ( o.PostCode_5.value.length == 0 ){
		alert("Please enter your postcode");
		o.PostCode_5.focus();
		return false;
	}
	
	if ( o.Valuation_Purpose_6.selectedIndex == 0 ){
		if ( o.slBranchLocations.selectedIndex == 0 ){
			alert("Please select a branch to handle your valuation");
			o.slBranchLocations.focus();
			return false;
		}
	}

	
	//create date string
	HttpManager.Document.GetObject("Preferred_Date_and_Time_7").value = HttpManager.Document.GetObject("slHour").value + ':' + HttpManager.Document.GetObject("slMinute").value + ' ' + HttpManager.Document.GetObject("Preferred_Date_and_Time_7").value;
	
	oCookieManager.StoreFormData();
	return true;
}

function Calendar_OnDateSelected(newdate){
	HttpManager.Document.GetObject("Preferred_Date_and_Time_7").value = newdate;
	HttpManager.Document.GetObject("txtDateText").innerHTML = newdate;
	HttpManager.Document.GetObject("pnlCalendar").style.display = "none";
	HttpManager.Document.GetObject("slHour").focus();
}

function Valuation_Calendar_OnClick(){
	HttpManager.Document.GetObject("pnlCalendar").style.display = "block";
}

function Calendar_OnCancel(){
	HttpManager.Document.GetObject("pnlCalendar").style.display = "none";
	HttpManager.Document.GetObject("slHour").focus();
}


function GetEmailAddress()
{
	if ( HttpManager.Document.GetObject("slBranchLocations") ){
		 HttpManager.Document.GetObject("__emailer_LocID").value = HttpManager.Document.GetObject("slBranchLocations").value;
	}
}

function Valuation_Purpose_OnChange(o){
	switch ( o.selectedIndex ){
		case 0:
			//Sales
			HttpManager.Document.GetObject("__emailer_ListingType").value = "";
			HttpManager.Document.GetObject("__emailer_LocID").value = "";
			HttpManager.Document.GetObject("valuation-branch-container").style.display = "block";
		break;
		default:
			//Lettings
			HttpManager.Document.GetObject("__emailer_ListingType").value = "6";
			HttpManager.Document.GetObject("__emailer_LocID").value = "6";
			HttpManager.Document.GetObject("slBranchLocations").selectedIndex = 0;
			HttpManager.Document.GetObject("valuation-branch-container").style.display = "none";
		break;
	}
}
