﻿function goToFindProperty(theform,thePageId) {
 
  var theLocation = theform.criteria_location.value;
  //var theArea = theform.criteria_area.value;
  var theType = theform.criteria_type.value;
  var theBedrooms = theform.criteria_bedrooms.value;
	
	
 lochref = 'index.php?pageid='+thePageId+'&filter=Search&criteria=set';

	if (theLocation != '') {	lochref += '&loc=' + theLocation; }
	//if (theArea != '') {	lochref += '&area=' + theArea; }
	if (theType != '') {	lochref += '&type=' + theType; }
	if (theBedrooms != '') {	lochref += '&bedrooms=' + theBedrooms; }

	location = lochref;
}

function CheckCriteriaType(theform) {

	var theSelectedType = theform.criteria_type.value;
	if ((theSelectedType == 'OF')||(theSelectedType == 'SH')) {
		theform.criteria_bedrooms.disabled = true;
		theform.criteria_bedrooms.value = "";
	} else {
		theform.criteria_bedrooms.disabled = false;
	}

}

function Populate_ComboBox(theMasterField, theDivId, theLang){
	var ajaxRequest;  // The variable that makes Ajax possible!

	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Something is wrong with your browser!");
				return false;
			}
		}
	}

	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById(theDivId);
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var cbx_id = document.getElementById(theMasterField).value;
	var queryString = "?cbxid=" +cbx_id+'&lang='+theLang;
	//alert(queryString);
	ajaxRequest.open("GET", "tools/searchproperty/includes/populate_combobox.php" + queryString, true);
	ajaxRequest.send(null); 
}
