var processFilter = function(response)
{
	var go = true;
	$(".search_results").addClass('marked_for_death');
	var count = 0;
	for (i in response) {
		++count;
		var r = $('#'+i);
		if (r.length) {
			r.removeClass('marked_for_death');
		} else {
			var n = $('#filter_display_results').prepend(response[i]);
			$(n).show();
		}
	}
	$('.marked_for_death').each(function(idx, item) {
		$(item).remove();
	});
	$('#filter_details').text('Displaying ' + (count==numProperties?"all":count) + ' of ' + numProperties + ' available properties: ').effect('highlight',{},1000);
	i = 0;
	$('.search_results').each(function(idx, item) {
		if (++i % 4 == 0) {
			$(item).addClass('search_results_4th');
		} else {
			$(item).removeClass('search_results_4th');
		}
	});
}

$(document).ready(function(){
	$('#filter_form').ajaxForm({
		success: processFilter,
		dataType: 'json'
	});
	$('select').change(function(){
		$('#filter_details').text('Processing...');
		$('#filter_form').submit();
	});
});
