$(function(){
	
$("select[name=marca]").change(function(){
		
		beforeSend:$("select[name=modelo]").html('<option value="0">Aguarde Carregando...</option>');
		
		var categoria = $("select[name=marca]").val();
		$.post("filtro/modelo.php",{modelo: modelo}, function(pega_modelo){
		
			complete:$("select[name=categoria]").html(pega_cat);
		
$("select[name=categoria]").change(function(){
		
		beforeSend:$("select[name=estado]").html('<option value="">Aguarde Carregando...</option>');
		
		var tipo = $("select[name=tipo]").val();
		var estado = $("select[name=categoria]").val();
		$.post("filtro/estado.php",{categoria: categoria, estado: estado}, function(pega_estado){
		
		complete:$("select[name=estado]").html(pega_estado);
		
$("select[name=estado]").change(function(){
		
		beforeSend:$("select[name=cidade]").html('<option value="">Aguarde Carregando...</option>');
		
		var tipo = $("select[name=tipo]").val();
		var estado = $("select[name=categoria]").val();
		var cidade = $("select[name=estado]").val();
		$.post("filtro/cidade.php",{categoria: categoria, estado: estado, cidade: cidade}, function(pega_cidade){
		
		complete:$("select[name=cidade]").html(pega_cidade);

$("select[name=cidade]").change(function(){
		
		beforeSend:$("select[name=valor]").html('<option value="">Aguarde Carregando...</option>');
		
		var tipo = $("select[name=tipo]").val();
		var estado = $("select[name=categoria]").val();
		var cidade = $("select[name=estado]").val();
		var valor = $("select[name=cidade]").val();
		$.post("filtro/valor.php",{categoria: categoria, estado: estado, cidade: cidade, valor: valor}, function(pega_valor){
		
		complete:$("select[name=valor]").html(pega_valor);
			
$("select[name=valor]").change(function(){
		
		beforeSend:$("select[name=comodos]").html('<option value="">Aguarde Carregando...</option>');
		
		var tipo = $("select[name=tipo]").val();
		var estado = $("select[name=categoria]").val();
		var cidade = $("select[name=estado]").val();
		var valorInicial = $("select[name=cidade]").val();
		var comodos = $("select[name=valor]").val();
		$.post("filtro/comodos.php",{categoria: categoria, estado: estado, cidade: cidade, valor: valor, comodos: comodos}, function(pega_comodos){
		
			complete:$("select[name=comodos]").html(pega_comodos);
						 });
			            });
			          });
		            });
		          });
		       });
	        });
         });
      });
   });	
})
