// Usuarios de navegador distinto de IE
var isIE = false;
//  Creamos una variable para el objeto XMLHttpRequest
var req;
//  Creamos una funcion para cargar los datos en nuestro objeto.
//  Logicamente, antes tenemos que crear el objeto.
//  Vease que la sintaxis varia dependiendo del navegador
function cargaXML(url,div,lista) {
	//alert(div)
	cont	= div;
	if(cont == 'home_listings_results')
    	document.getElementById("home_listings_results").innerHTML="";
	
	if(lista == 'more_visited')
	{
		document.getElementById("more_visited").className = "active_listings";
		document.getElementById("apart_li").className = null;
		document.getElementById("house_li").className = null;
		document.getElementById("office_li").className = null;
		document.getElementById("retail_li").className = null;
		document.getElementById("others_li").className = null;
	}
	if(lista == 'apart_li')
	{
		document.getElementById("apart_li").className = "active_listings";
		document.getElementById("more_visited").className = null;
		document.getElementById("house_li").className = null;
		document.getElementById("office_li").className = null;
		document.getElementById("retail_li").className = null;
		document.getElementById("others_li").className = null;
	}
	if(lista == 'house_li')
	{
		document.getElementById("house_li").className = "active_listings";
		document.getElementById("apart_li").className = null;
		document.getElementById("more_visited").className = null;
		document.getElementById("office_li").className = null;
		document.getElementById("retail_li").className = null;
		document.getElementById("others_li").className = null;
	}
	if(lista == 'office_li')
	{
		document.getElementById("office_li").className = "active_listings";
		document.getElementById("apart_li").className = null;
		document.getElementById("house_li").className = null;
		document.getElementById("more_visited").className = null;
		document.getElementById("retail_li").className = null;
		document.getElementById("others_li").className = null;
	}
	if(lista == 'retail_li')
	{
		document.getElementById("retail_li").className = "active_listings";
		document.getElementById("apart_li").className = null;
		document.getElementById("house_li").className = null;
		document.getElementById("office_li").className = null;
		document.getElementById("more_visited").className = null;
		document.getElementById("others_li").className = null;
	}
	if(lista == 'others_li')
	{
		document.getElementById("others_li").className = "active_listings";
		document.getElementById("apart_li").className = null;
		document.getElementById("house_li").className = null;
		document.getElementById("office_li").className = null;
		document.getElementById("retail_li").className = null;
		document.getElementById("more_visited").className = null;
	}

    if(url=='')
        return;
    
    //  Usuario navegador distinto de IE
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}


function processReqChange(){
	//alert(cont)
    //    Referencia a nuestro DIV con ID unica:
	if(cont == 'home_listings_results')
    	var home_listings_results = document.getElementById("home_listings_results");
	
	//if(cont == 'detalles2')
		//var detalles = document.getElementById("detalles2");
	/*	
	if(cont == 'calendario')
	{
		var detalles = document.getElementById("calendario");
		document.getElementById("calendario").style.visibility='visible';
	}*/
    //    Si se ha completado la carga de datos, los mostramos en el DIV...
    if(req.readyState == 4){
		
        home_listings_results.innerHTML = req.responseText;
    } else {
        //    ...en caso contrario, le diremos al usuario que los estamos cargando:
        home_listings_results.innerHTML = '<div id="results_loader"><p><img src="images/loader.gif" alt="Cargando..." width="128" height="15"></p></div>';
    }
}

//***************************************************CARGAR SELECTS***************************************************


function cargaXML2(url,div) {
	//alert(div)
	cont	= div;
	if(cont == 'estado')
	{
    	document.getElementById("estado").innerHTML="";
		document.getElementById("ciudad").innerHTML='<select name="ciudad2" id="ciudad2"><option value="0" selected="selected">- Seleccione Ciudad-</option></select>';
		document.getElementById("municipio").innerHTML='<select name="municipio2" id="municipio2"><option value="0" selected="selected">- Seleccione Municipio-</option></select>';
		document.getElementById("parroquia").innerHTML='<select name="parroquia2" id="parroquia2"><option value="0" selected="selected">- Seleccione Parroquia-</option></select>';
		document.getElementById("urbanizacion").innerHTML='<select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Seleccione Urbanizacion-</option></select>';
	}
	
	
	if(cont == 'ciudad')
	{
    	document.getElementById("ciudad").innerHTML="";
		document.getElementById("municipio").innerHTML='<select name="municipio2" id="municipio2"><option value="0" selected="selected">- Todos/Municipios -</option></select>';
		document.getElementById("urbanizacion").innerHTML='<select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todas/Urb. o sectores-</option></select>';
	}
	if(cont == 'municipio')
	{
    	document.getElementById("municipio").innerHTML="";
		document.getElementById("urbanizacion").innerHTML='<select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todas/Urb. o sectores-</option></select>';
	}
	if(cont == 'urbanizacion')
    	document.getElementById("urbanizacion").innerHTML="";
		
	
    if(url=='')
        return;
    
    //  Usuario navegador distinto de IE
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange2;
        req.open("GET", url, true);
        req.send(null);
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange2;
            req.open("GET", url, true);
            req.send();
        }
    }
}


function processReqChange2(){
	//alert(cont)
    //    Referencia a nuestro DIV con ID unica:
	if(cont == 'ciudad')
	  	var combo  = document.getElementById("ciudad");
	if(cont == 'municipio')
    	var combo 	= document.getElementById("municipio");
	if(cont == 'urbanizacion')
    	var combo = document.getElementById("urbanizacion");
    //    Si se ha completado la carga de datos, los mostramos en el DIV...
    if(req.readyState == 4){
		
        combo.innerHTML = req.responseText;
    } else {
        //    ...en caso contrario, le diremos al usuario que los estamos cargando:
		if(cont == 'estado')
        	combo.innerHTML = ' <select name="pais2" id="pais2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'ciudad')
        	combo.innerHTML = ' <select name="ciudad2" id="ciudad2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'municipio')
        	combo.innerHTML = ' <select name="municipio2" id="municipio2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'urbanizacion')
        	combo.innerHTML = ' <select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Cargando... -</option></select>';	
    }
}




function cargaXML3(url,div) {
	//alert(div)
	cont	= div;
	if(cont == 'estado')
	{
    	document.getElementById("estado").innerHTML="";
		document.getElementById("ciudad").innerHTML='<label for="ciudad"><span class="asterisco">*</span>Ciudad:</label><select name="ciudad2" id="ciudad2"><option value="0" selected="selected">- Seleccione Ciudad-</option></select>';
		document.getElementById("municipio").innerHTML='<label for="municipio"><span class="asterisco">*</span>Municipio:</label><select name="municipio2" id="municipio2"><option value="0" selected="selected">- Seleccione Municipio-</option></select>';
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion"><span class="asterisco">*</span>Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Seleccione Urbanizacion-</option></select>';
	}
	
	
	if(cont == 'ciudad')
	{
    	document.getElementById("ciudad").innerHTML="";
		document.getElementById("municipio").innerHTML='<label for="municipio"><span class="asterisco">*</span>Municipio:</label><select name="municipio2" id="municipio2"><option value="0" selected="selected">- Todos/Municipios -</option></select>';
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion"><span class="asterisco">*</span>Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todas/Urb. o sectores-</option></select>';
	}
	if(cont == 'municipio')
	{
    	document.getElementById("municipio").innerHTML="";
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion"><span class="asterisco">*</span>Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todas/Urb. o sectores-</option></select>';
	}
	if(cont == 'parroquia')
	{
    	document.getElementById("parroquia").innerHTML="";
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion"><span class="asterisco">*</span>Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todas/Urb. o sectores-</option></select>';
	}
	if(cont == 'urbanizacion')
    	document.getElementById("urbanizacion").innerHTML="";
		
	
    if(url=='')
        return;
    
    //  Usuario navegador distinto de IE
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange3;
        req.open("GET", url, true);
        req.send(null);
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange3;
            req.open("GET", url, true);
            req.send();
        }
    }
}


function processReqChange3(){
	//alert(cont)
    //    Referencia a nuestro DIV con ID unica:
	if(cont == 'estado')
	{
    	var combo = document.getElementById("estado");
		var pais = document.getElementById("pais").value;
		if(pais == "Otro")
			document.getElementById("paisvalor").style.display = "block";
			//document.getElementById('paisvalor').style.visibility = "visible";
		else
		{
			document.getElementById("otro_pais").value = "";
			document.getElementById("paisvalor").style.display = "none";
			//document.getElementById('paisvalor').style.visibility = "hidden";
		}
	}	
	if(cont == 'ciudad')
	{
    	var combo  = document.getElementById("ciudad");
		var estado = document.getElementById("estado2").value;
		if(estado == "Otro" && document.getElementById("pais").value != 1)
			document.getElementById("estadovalor").style.display = "block";
			//document.getElementById('estadovalor').style.visibility = "visible";
		else
		{
			document.getElementById("otro_estado").value = "";
			document.getElementById("estadovalor").style.display = "none";
			//document.getElementById('estadovalor').style.visibility = "hidden";
		}
	}
	if(cont == 'municipio')
	{
    	var combo 	= document.getElementById("municipio");
		var ciudad	= document.getElementById("ciudad2").value;
		if(ciudad == "Otro")
			document.getElementById("ciudadvalor").style.display = "block";
		else
		{
			document.getElementById("otra_ciudad").value = "";
			document.getElementById("ciudadvalor").style.display = "none";
		}
	}
	if(cont == 'parroquia')
	{
    	var combo 		= document.getElementById("parroquia");
		var municipio	= document.getElementById("municipio2").value;
		if(municipio == "Otro")
			document.getElementById("municipiovalor").style.display = "block";
		else
		{
			document.getElementById("otro_municipio").value = "";
			document.getElementById("municipiovalor").style.display = "none";
		}
	}
	if(cont == 'urbanizacion')
	{
    	var combo 		= document.getElementById("urbanizacion");
		var municipio	= document.getElementById("municipio2").value;
		if(municipio == "Otro")
			document.getElementById("municipiovalor").style.display = "block";
		else
		{
			document.getElementById("otro_municipio").value = "";
			document.getElementById("municipiovalor").style.display = "none";
		}
			
	}
    //    Si se ha completado la carga de datos, los mostramos en el DIV...
    if(req.readyState == 4){
		
        combo.innerHTML = req.responseText;
    } else {
        //    ...en caso contrario, le diremos al usuario que los estamos cargando:
		if(cont == 'estado')
        	combo.innerHTML = ' <div id="estado"><label for="estado2"><span class="asterisco">*</span>Estado:</label><select name="estado2" id="estado2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'ciudad')
        	combo.innerHTML = ' <label for="ciudad"><span class="asterisco">*</span>Ciudad:</label><select name="ciudad2" id="ciudad2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'municipio')
        	combo.innerHTML = '<label for="municipio"><span class="asterisco">*</span>Municipio:</label><select name="municipio2" id="municipio2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'parroquia')
        	combo.innerHTML = '<label for="parroquia"><span class="asterisco">*</span>Parroquia:</label><select name="parroquia2" id="parroquia2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'urbanizacion')
        	combo.innerHTML = '<label for="urbanizacion"><span class="asterisco">*</span>Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Cargando... -</option></select>';	
    }
}


function cargaXML4(url,div) {
	//alert(div)
	cont	= div;
	if(cont == 'estado')
	{
    	document.getElementById("estado").innerHTML="";
		document.getElementById("ciudad").innerHTML='<label for="ciudad"><span class="asterisco">*</span>Ciudad:</label><select name="ciudad2" id="ciudad2"><option value="0" selected="selected">- Seleccione -</option></select>';
		document.getElementById("municipio").innerHTML='<label for="municipio">Municipio:</label><select name="municipio2" id="municipio2"><option value="0" selected="selected">- Todos -</option></select>';
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion">Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todos -</option></select>';
	}
	
	
	if(cont == 'ciudad')
	{
    	document.getElementById("ciudad").innerHTML="";
		document.getElementById("municipio").innerHTML='<label for="municipio">Municipio:</label><select name="municipio2" id="municipio2"><option value="0" selected="selected">- Todos -</option></select>';
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion">Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todos -</option></select>';
	}
	if(cont == 'municipio')
	{
    	document.getElementById("municipio").innerHTML="";
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion">Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todos -</option></select>';
	}
	if(cont == 'parroquia')
	{
    	document.getElementById("parroquia").innerHTML="";
		document.getElementById("urbanizacion").innerHTML='<label for="urbanizacion">Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Todos -</option></select>';
	}
	if(cont == 'urbanizacion')
    	document.getElementById("urbanizacion").innerHTML="";
		
	
    if(url=='')
        return;
    
    //  Usuario navegador distinto de IE
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange4;
        req.open("GET", url, true);
        req.send(null);
    //  ...y usuario de Internet Explorer Windows
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange4;
            req.open("GET", url, true);
            req.send();
        }
    }
}


function processReqChange4(){
	//alert(cont)
    //    Referencia a nuestro DIV con ID unica:
	if(cont == 'estado')
	{
    	var combo = document.getElementById("estado");
		var pais = document.getElementById("pais").value;
		if(pais == "Otro")
			document.getElementById("paisvalor").style.display = "block";
			//document.getElementById('paisvalor').style.visibility = "visible";
		else
		{
			document.getElementById("otro_pais").value = "";
			document.getElementById("paisvalor").style.display = "none";
			//document.getElementById('paisvalor').style.visibility = "hidden";
		}
	}	
	if(cont == 'ciudad')
	{
    	var combo  = document.getElementById("ciudad");
		var estado = document.getElementById("estado2").value;
		if(estado == "Otro" && document.getElementById("pais").value != 1)
			document.getElementById("estadovalor").style.display = "block";
			//document.getElementById('estadovalor').style.visibility = "visible";
		else
		{
			document.getElementById("otro_estado").value = "";
			document.getElementById("estadovalor").style.display = "none";
			//document.getElementById('estadovalor').style.visibility = "hidden";
		}
	}
	if(cont == 'municipio')
	{
    	var combo 	= document.getElementById("municipio");
		var ciudad	= document.getElementById("ciudad2").value;
		if(ciudad == "Otro")
			document.getElementById("ciudadvalor").style.display = "block";
		else
		{
			document.getElementById("otra_ciudad").value = "";
			document.getElementById("ciudadvalor").style.display = "none";
		}
	}
	if(cont == 'parroquia')
	{
    	var combo 		= document.getElementById("parroquia");
		var municipio	= document.getElementById("municipio2").value;
		if(municipio == "Otro")
			document.getElementById("municipiovalor").style.display = "block";
		else
		{
			document.getElementById("otro_municipio").value = "";
			document.getElementById("municipiovalor").style.display = "none";
		}
	}
	if(cont == 'urbanizacion')
	{
    	var combo 		= document.getElementById("urbanizacion");
		var municipio	= document.getElementById("municipio2").value;
		if(municipio == "Otro")
			document.getElementById("municipiovalor").style.display = "block";
		else
		{
			document.getElementById("otro_municipio").value = "";
			document.getElementById("municipiovalor").style.display = "none";
		}
			
	}
    //    Si se ha completado la carga de datos, los mostramos en el DIV...
    if(req.readyState == 4){
		
        combo.innerHTML = req.responseText;
    } else {
        //    ...en caso contrario, le diremos al usuario que los estamos cargando:
		if(cont == 'estado')
        	combo.innerHTML = ' <div id="estado"><label for="estado2"><span class="asterisco">*</span>Estado:</label><select name="estado2" id="estado2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'ciudad')
        	combo.innerHTML = ' <label for="ciudad"><span class="asterisco">*</span>Ciudad:</label><select name="ciudad2" id="ciudad2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'municipio')
        	combo.innerHTML = '<label for="municipio">Municipio:</label><select name="municipio2" id="municipio2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'parroquia')
        	combo.innerHTML = '<label for="parroquia">Parroquia:</label><select name="parroquia2" id="parroquia2"><option value="0" selected="selected">- Cargando... -</option></select>';
		if(cont == 'urbanizacion')
        	combo.innerHTML = '<label for="urbanizacion">Urb., zona o sector:</label><select name="urbanizacion2" id="urbanizacion2"><option value="0" selected="selected">- Cargando... -</option></select>';	
    }
}




function val_urb(value)
{
	//alert(value)
	if(value == "Otro")
		document.getElementById("urbanizacionvalor").style.display = "block";
	else
	{
		document.getElementById("otro_urb_sector").value = "";
		document.getElementById("urbanizacionvalor").style.display = "none";
	}
}

