
////////////////////////////// LA BUSQUEDA //////////////////////////
//FUNCIONES DE BUSQUEDA
// EL AJAX
function nuevoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

// cargamos los modos ( primer opcion de form )
function cargaModos(){
var t1,t8, contenedor;

contenedor = document.getElementById('div1');
t1 = document.busqueda.iniciarbusqueda.value = '1';
t8 = document.busqueda.lang.value;

ajax=nuevoAjax();
ajax.open("POST", "ajax_busqueda.php",true);
ajax.onreadystatechange=function() {
	if (ajax.readyState==1) {
}
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
totalParcial();
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("t1="+t1+"&t8="+t8)
}

function cargaInmueble(){

var t2,t8, contenedor;
contenedor = document.getElementById('div2');
t2 = document.busqueda.modo.value;
t8 = document.busqueda.lang.value;

ajax=nuevoAjax();
ajax.open("POST", "ajax_busqueda.php",true);
ajax.onreadystatechange=function() {
	if (ajax.readyState==1) {
	document.getElementById('div2').innerHTML = '';
	document.getElementById('div3').innerHTML = '<input name="departamento" type="hidden" id="departamento" />';
	document.getElementById('div4').innerHTML = '<input name="localidad" type="hidden" id="localidad" />';
	document.getElementById('div5').innerHTML = '<input name="zona" type="hidden" id="zona" />';
	}
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
totalParcial();
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("t2="+t2+"&t8="+t8)
}

function cargaDepartamento(){

var t2,t3,t8, contenedor;
contenedor = document.getElementById('div3');
t2 = document.busqueda.modo.value;
t3 = document.busqueda.inmueble.value;
t8 = document.busqueda.lang.value;

ajax=nuevoAjax();
ajax.open("POST", "ajax_busqueda.php",true);
ajax.onreadystatechange=function() {
	if (ajax.readyState==1) {
		document.getElementById('div3').innerHTML = '';
	document.getElementById('div4').innerHTML = '<input name="localidad" type="hidden" id="localidad" />';
	document.getElementById('div5').innerHTML = '<input name="zona" type="hidden" id="zona" />';

	}
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
totalParcial();
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("t2="+t2+"&t3="+t3+"&t8="+t8)
}

function cargaLocalidad(){

var t2,t3,t4,t8, contenedor;
contenedor = document.getElementById('div4');
t2 = document.busqueda.modo.value;
t3 = document.busqueda.inmueble.value;
t4 = document.busqueda.departamento.value;
t8 = document.busqueda.lang.value;

ajax=nuevoAjax();
ajax.open("POST", "ajax_busqueda.php",true);
ajax.onreadystatechange=function() {
	if (ajax.readyState==1) {
		document.getElementById('div4').innerHTML = '';
	document.getElementById('div5').innerHTML = '<input name="zona" type="hidden" id="zona" />';

	}
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
totalParcial();
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("t2="+t2+"&t3="+t3+"&t4="+t4+"&t8="+t8)
}
function cargaZona(){

var t2,t3,t4,t5,t8, contenedor;
contenedor = document.getElementById('div5');
t2 = document.busqueda.modo.value;
t3 = document.busqueda.inmueble.value;
t4 = document.busqueda.departamento.value;
t5 = document.busqueda.localidad.value;
t8 = document.busqueda.lang.value;
ajax=nuevoAjax();
ajax.open("POST", "ajax_busqueda.php",true);
ajax.onreadystatechange=function() {
	if (ajax.readyState==1) {
		document.getElementById('div5').innerHTML = '';
	}
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
totalParcial();
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("t2="+t2+"&t3="+t3+"&t4="+t4+"&t5="+t5+"&t8="+t8)
}

// TOTAL HASTA EL MOMENTO

function totalParcial(){

var t2,t3,t4,t5,t6,t7, contenedor;
contenedor = document.getElementById('nresult');
t2 = document.busqueda.modo.value;
t3 = document.busqueda.inmueble.value;
t4 = document.busqueda.departamento.value;
t5 = document.busqueda.localidad.value;
t6 = document.busqueda.parcial.value = "1";
t7 = document.busqueda.zona.value;


ajax=nuevoAjax();
ajax.open("POST", "Tparcial.php",true);
ajax.onreadystatechange=function() {
	if (ajax.readyState==1) {
	}
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("t2="+t2+"&t3="+t3+"&t4="+t4+"&t5="+t5+"&t6="+t6+"&t7="+t7)
}
//´BUSCAMOS LA PROPIEDAD
function buscarProp() {
t2 = document.busqueda.modo.value;
t3 = document.busqueda.inmueble.value;
t4 = document.busqueda.departamento.value;
t5 = document.busqueda.localidad.value;
t6 = document.busqueda.parcial.value = "1";
t7 = document.busqueda.zona.value;
document.busqueda.submit();
}



