seleccionCiudad = function() {

	$.ajax({
	  type: 'POST',
	  url: 'cargarBarrios.php',
	  async: false,
	  data: 'idCiudad='+$("select#idCiudad").val()+'&idBarrio='+$("#idBarrioDef").val(),
	  dataType: 'html',
	  beforeSend: function() {
			$("select#idBarrio").html('');
	  },
	  success: function(html) {
			$("select#idBarrio").html(html);
	  }
	});

}

//idOperacion

$(document).ready(function() {

	$("select#idCiudad").change(function(){
		seleccionCiudad();
	});

	
	if ($("select#idCiudad").val() != ''){
		seleccionCiudad();
	}


	$('#quick_find').submit(function() {

		if (!quick_find_validar()) return false;

		return true;

	});

	$("select#idOperacion").change(function(){

		if ($(this).val() == "A") var precios = precios_alquiler;
		if ($(this).val() == "V") var precios = precios_venta;

		var options = '';
		options += '<option value="">Mínimo</option>';
		$("select#idPrecioDesde").html(options);

		for (var i = 0; i < precios.length-1; i++) {
			options += '<option value="' + precios[i] + '">' + precios[i] + '</option>';
		}
		$("select#idPrecioDesde").html(options);


		var options = '';
		options += '<option value="">Máximo</option>';
		$("select#idPrecioHasta").html(options);

		for (var i = 0; i < precios.length; i++) {
			options += '<option value="' + precios[i] + '">' + precios[i] + '</option>';
		}
		$("select#idPrecioHasta").html(options);

	});

	

});

function quick_find_validar(){

	if (parseInt($("#idPrecioDesde").val()) > parseInt($("#idPrecioHasta").val())) {
		alert($("#ValidarPrecios").val());
		$("#idPrecioDesde").focus();
		return false;
	}
	return true;
}



