$(document).ready(function(){
	
	//var sitec='http://192.168.0.29/paginas/c21trueba2010/';
	
	$('#op').change(function(){
		$('#ti').html('');
		$('#ie').html('');
		$('#im').html('');
		if ($(this).val()!='')
			$.get('/cargacombos.m3',{"op":$(this).val()},function(data){$('#ti').html(data);});
	});

	$('#ti').change(function(){
		$('#ie').html('');
		$('#im').html('');
		if ($(this).val()!='')
			$.get('/cargacombos.m3',{"op":$('#op').val(),"ti":$('#ti').val()},function(data){$('#ie').html(data);});
	});
	$('#ie').change(function(){
		$('#im').html('');
		if ($(this).val()!='')
			$.get('/cargacombos.m3',{"op":$('#op').val(),"ti":$('#ti').val(),"ie":$('#ie').val()},function(data){$('#im').html(data);});
	});
	$('#im').change(function(){
		$('#ic').html('');
		if ($(this).val()!='')
			$.get('/cargacombos.m3',{"op":$('#op').val(),"ti":$('#ti').val(),"ie":$('#ie').val(),"im":$('#im').val()},function(data){$('#ic').html(data);});
	});	
	
		
	$('#bsqprop').click(function(){
		if ($('#op').val()!='')
			if ($('#ti').val()!='')
				if ($('#ie').val()!='')
					if ($('#im').val()!='')
					{
						$.cookie('idorden','');
						$.cookie('numpag','');
						$.cookie('idrecord','');
						$.cookie('idorden','PA_1');
						edo=reemplazaVal('ie');
						mun=reemplazaVal('im');
						ope=reemplazaVal('op');
						tip=reemplazaVal('ti');
						
						window.location.href="/buscador.m3/"+ope+"/"+tip+"/"+edo+"/"+mun+"?ti="+$('#ti').val()+"&numpag=1";
					}else
						alert("Debe seleccionar un municipio");
				else
					alert("Debe seleccionar un estado");
			else
				alert("Debe seleccionar un tipo de inmueble");
		else
			alert("Debe seleccionar una operacion");
	});

delay_reco=true;
delay_reco_ctl=false;
jQuery.fn.delay2 = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	return this;
};


});
function reemplazaVal(valor){
	valor=$('#'+valor+' :selected').html().replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace('á','a').replace('é','e').replace('í','i').replace('ó','o').replace('ú','u');
	return valor;
}

