$(document).ready(function(){
	var sb_region = "sb-all-neighborhoods";
	$("#search-box-neighborhood").children("*[id^=sb]").hide();
	$("#sb-all-neighborhoods").show();
	$("#id_region").change(function(){
		$("#search-box-neighborhood").children("*[id^=sb]").hide();
		sb_region = $("#id_region :selected").attr("opt");
		$("#"+sb_region).show();
	});
	
	$("#search-box-form").submit(function(){
		var beds = $("#id_beds_min").val();
		var baths = $("#id_baths_min").val();
		var neighborhood = $(":input[name='"+sb_region+"']").val();
		var min = $("#id_list_price_min").val();
		var max = $("#id_list_price_max").val();
		var searchstr = "?PerformSearch";
		if(beds !=0) searchstr +="&MinBeds="+beds;
		if(baths !=0) searchstr +="&MinBaths="+baths;
		if(neighborhood != "all") searchstr +="&Cities="+neighborhood+"&Communities="+neighborhood;
		if(neighborhood == "all") searchstr += "&" + $(":input[name='region']").val();
		if(min !="all") searchstr +="&MinPrice="+min;
		if(max !="all") searchstr +="&MaxPrice="+max;
		var property_types = "";
		if($("#id_res:checked").length>0)  property_types += "%2C459";
		if($("#id_con:checked").length>0) property_types += "%2C460";
		if($("#id_mul:checked").length>0) property_types += "%2C463";
		if($("#id_lnd:checked").length>0) property_types += "%2C461";
		if(property_types != "") searchstr += "&PropertyTypes="+property_types;
		window.location="http://www.sandislehawaii.com/propertysearch.html"+searchstr;
		return false;
	});
});
