$(function() {
	$( "#complex" ).autocomplete({
		minLength: 1,
		source: "/search.php?type=complex"
	});
	$( "#address" ).autocomplete({
		minLength: 1,
		source: "/search.php?type=address&deal=buy"
	});
	$( "#address_rent" ).autocomplete({
		minLength: 1,
		source: "/search.php?type=address&deal=rent"
	});		
});

$(document).ready(function(){

	$('.lnk-delete').click(function(){
		window.location = $(this).attr('href');
		return false;
	});	
	
	$('.check_newbuilding').click(function(){
		$("input[name='newbuilding']").attr({'checked' : !$("input[name='newbuilding']").attr('checked')});
		return false;
	});	
	$('.check_penthouse').click(function(){
		$("input[name='penthouse']").attr({'checked' : !$("input[name='penthouse']").attr('checked')});
		return false;
	});		
	/*-------- Очистить блок для поиска */
	$('#clear-search-block').click(function(e){
		
		
		$("input[name='square_from']").val('');
		$("input[name='square_to']").val('');
		
		$("input[name='room']").val('');
		
		$("input[name='buy_price_from']").val('');
		$("input[name='buy_price_to']").val('');
		
		$("input[name='rent_price_from']").val('');
		$("input[name='rent_price_to']").val('');
		
		$("input[name='buy_lot']").val('');
		$("input[name='rent_lot']").val('');
		
		$("input[name='newbuilding']").attr({'checked' : false});
		$("input[name='penthouse']").attr({'checked' : false});
		
		$("input[name='complex']").val('');
		$("input[name='address']").val('');
		
		$("select[name='region'], select[name='metro']").attr('selectedIndex', 0);
		$("select[name='buy_price_unit'], select[name='rent_price_unit']").attr('selectedIndex', 0);
		
		return false;
	});	

	
});
