function resetForm() {
		document.criteria.reset();
		updateCount();
}


function updateCount() {

	document.getElementById('total_count_found').innerHTML = "<h2>Updating...</h2>";

	var query_types = "Property_Types=";
	var typesBox = document.getElementById('Property_Types');
	
	for (i=0; i<typesBox.options.length; i++) {
		if (typesBox.options[i].selected && typesBox.options[i].value != "") {
			query_types = query_types + typesBox.options[i].value + ",";
		}
	}

	var query_city = "City=";
	var cityBox = document.getElementById('City');
	
	for (i=0; i<cityBox.options.length; i++) {
		if (cityBox.options[i].selected && cityBox.options[i].value != "") {
			query_city = query_city + cityBox.options[i].value + ",";
		}
	}


	var query_school = "School_District=";
	var schoolBox = document.getElementById('School_District');
	
	for (i=0; i<schoolBox.options.length; i++) {
		if (schoolBox.options[i].selected && schoolBox.options[i].value != "") {
			query_school = query_school + schoolBox.options[i].value + ",";
		}
	}
	
	
	var query_minprice = "Min_Price="+document.getElementById('Min_Price').options[document.getElementById('Min_Price').selectedIndex].value;
	var query_maxprice = "Max_Price="+document.getElementById('Max_Price').options[document.getElementById('Max_Price').selectedIndex].value;

	var query_zipcode = "Zip_Code="+document.getElementById('Zip_Code').value;
        //var query_zipcode = "Zip_Code=";
	
	var query_sat = "Show_Saturday=";
	if (document.getElementById('show_saturday') && document.getElementById('show_saturday').checked) {
		query_sat += "Y";
	}
	
	var query_sun = "Show_Sunday=";
	if (document.getElementById('show_sunday') && document.getElementById('show_sunday').checked) {
		query_sun += "Y";	
	}
	
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		return false;
	}

	//alert("action=searchq&"+query_city+"&"+query_school+"&"+query_minprice+"&"+query_maxprice+"&"+query_zipcode+"&"+query_sat+"&"+query_sun);
	req.open("GET", "./searchq.php?action=searchq&"+query_city+"&"+query_school+"&"+query_minprice+"&"+query_maxprice+"&"+query_zipcode+"&"+query_sat+"&"+query_sun+"&"+query_types, true);
	
	req.onreadystatechange=function() {
		if (req.readyState == 4) {
			//document.getElementById('footer').innerHTML = req.responseText;
			var theArray = req.responseText.evalJSON();
			var total_found = 0;
			for (i=0; i<allproperties.length; i++) {
				var tagname = "search_result_"+allproperties[i];
				document.getElementById(tagname).style.display = "block";
				document.getElementById(tagname).style.display = "none";
			}
			for (i=0; i<theArray.length; i++) {
				if (total_found < 100) {
					var tagname = "search_result_"+theArray[i];
					var tagname_image = "prop_image_"+theArray[i];
					if (!document.getElementById(tagname)) {
						window.location = "http://www.stlouisopenhouses.com/?q=refresh";
						return;
					}
					document.getElementById(tagname_image).src = prop_images[theArray[i]];
					document.getElementById(tagname).style.display = "block";
				}
				total_found++;
			}
			if (total_found > 100) {
				document.getElementById('total_count_found').innerHTML = "<h2 style='font-weight: normal;'><b>"+total_found+"</b> St. Louis Open Houses Found. &nbsp;Results limited to 100. &nbsp;Please narrow your search.</h2>";
			}
			else {
				document.getElementById('total_count_found').innerHTML = "<h2 style='font-weight: normal;'><b>"+total_found+"</b> St. Louis Open Houses Found.</h2>";
			}
		}
	}	
	
	req.send(null);	

}

function doSearch() {
	var query_city = "City=";
	var cityBox = document.getElementById('City');
	
	for (i=0; i<cityBox.options.length; i++) {
		if (cityBox.options[i].selected && cityBox.options[i].value != "") {
			query_city = query_city + cityBox.options[i].value + ",";
		}
	}


	var query_school = "School_District=";
	var schoolBox = document.getElementById('School_District');
	
	for (i=0; i<schoolBox.options.length; i++) {
		if (schoolBox.options[i].selected && schoolBox.options[i].value != "") {
			query_school = query_school + schoolBox.options[i].value + ",";
		}
	}
	
	
	var query_minprice = "Min_Price="+document.getElementById('Min_Price').options[document.getElementById('Min_Price').selectedIndex].value;
	var query_maxprice = "Max_Price="+document.getElementById('Max_Price').options[document.getElementById('Max_Price').selectedIndex].value;

       var query_zipcode = "Zip_Code="+document.getElementById('Zip_Code').value;
	//  var query_zipcode = "Zip_Code=";
	
	window.location = "search.php?action=search&"+query_city+"&"+query_school+"&"+query_minprice+"&"+query_maxprice+"&"+query_zipcode;

}
