function get_neighborhoods()
{
	region = $("#region").val();
	$("#neighborhood").html('<option value="all">Please wait</option>');
	$("#neighborhood").attr("disabled", "disabled");
	
	if(region == "all")
	{
		$("#neighborhood").html('<option value="all">Select a region first</option>');
	}
	else
	{
		$.getJSON("regions_neighborhoods.php?region_id=" + region, function(data)
		{
			$("#neighborhood").html('<option value="all">All Neighborhoods</option>');
			$.each(data, function()
			{
				$("#neighborhood").append('<option value="' + this.place_id + '">' + this.place_name + "</option>");
			});
			$("#neighborhood").removeAttr("disabled");
		});
	}
}

function validate_form()
{
	if($("#max_rent").val() < $("#min_rent").val())
	{
		alert("Please make sure the minimum rent is less than the maximum rent");
	}
	else
	{
		$("#search_form").submit();
	}
}

$(document).ready(function()
{	
	get_neighborhoods();
});