var myConn_selec_tipo_producto = new XHConn();
var fin_selec_tipo_producto = function (oXML) { document.getElementById('div_selec_subtipo').innerHTML = oXML.responseText;};
function selec_tipo_producto(idtipo){
	if (idtipo == 0){
		if (subtipo_activo != 0){
			desaciva_subtipo();
		}
		if (estado_activo != 0){
			desaciva_estado();
		}
	} else {
		if (estado_activo != 0){
			desaciva_estado();
		}
		document.getElementById('div_selec_subtipo').innerHTML = '<img src="img/preload-campos.gif" width="56" height="21">';
		window.setTimeout("myConn_selec_tipo_producto.connect('catalogo/selec_subtipo.php', 'GET', 'idtipo="+idtipo+"&estado_activo="+estado_activo+"&subtipo_activo="+subtipo_activo+"', fin_selec_tipo_producto)", 1000);
		boton_buscar();
	}
}

function desaciva_subtipo(){
	desplegable_desactivado = '<select name="subtipo" class="camps_form_busc" id="subtipo" disabled="disabled">';
	desplegable_desactivado += '<option value="0" selected="selected">Cualquier</option>';
	desplegable_desactivado += '</select>';
	document.getElementById('div_selec_subtipo').innerHTML = desplegable_desactivado;
}

function desaciva_estado(){
	desplegable_desactivado = '<select name="estado" class="camps_form_busc" id="estado" disabled="disabled">';
	desplegable_desactivado += '<option value="0" selected="selected">Cualquier</option>';
	desplegable_desactivado += '</select>';
	document.getElementById('div_selec_estado').innerHTML = desplegable_desactivado;
}

var myConn_selec_subtipo_producto = new XHConn();
var fin_selec_subtipo_producto = function (oXML) { document.getElementById('div_selec_estado').innerHTML = oXML.responseText;};
function selec_subtipo_producto(idsubtipo,idtipo){
	if (idsubtipo == 0){
		if (estado_activo != 0){
			desaciva_estado();
		}
	} else {
		boton_buscar();
		document.getElementById('div_selec_estado').innerHTML = '<img src="img/preload-campos.gif" width="56" height="21">';
		window.setTimeout("myConn_selec_subtipo_producto.connect('catalogo/selec_estado.php', 'GET', 'idtipo="+idtipo+"&idsubtipo="+idsubtipo+"', fin_selec_subtipo_producto)", 1000);
	}
}

var myConn_boton_buscar = new XHConn();
var fin_boton_buscar = function (oXML) { document.getElementById('div_boton_buscar').innerHTML = oXML.responseText;};
function boton_buscar(){
	document.getElementById('div_boton_buscar').innerHTML = '<img src="img/preload-campos.gif" width="56" height="21">';
	window.setTimeout("myConn_boton_buscar.connect('catalogo/boton_buscar.php', 'GET', 'idtipo=', fin_boton_buscar)", 1000);
}

function activar_boton_buscar(){
	buscar_descativado = '<a href="javascript:buscar();" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'buscar\',\'\',\'img/boto_buscar02.jpg\',1)"><img src="img/boto_buscar01.jpg" name="buscar" width="60" height="19" border="0" id="buscar" /></a>';
	document.getElementById('div_boton_buscar').innerHTML = buscar_descativado;
}

function buscar(){
	idtipo_global = document.getElementById('tipo').value;
	if (subtipo_activo != 0){
		idsubtipo_global = document.getElementById('subtipo').value;
	} else {
		idsubtipo_global = 0;
	}
	if (estado_activo != 0){
		estado_global = document.getElementById('estado').value;
	} else {
		estado_global = 0;
	}
	listado_productos();
}

var myConn_listado_productos = new XHConn();
var fin_listado_productos = function (oXML) { document.getElementById('div_listado_productos').innerHTML = oXML.responseText;};
function listado_productos(pagina,num_pags){
		cargando_lista = '<table width="587" height="246" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_lista += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_listado_productos').innerHTML = cargando_lista;
		window.setTimeout("myConn_listado_productos.connect('catalogo/listado.php', 'GET', 'idtipo="+idtipo_global+"&idsubtipo="+idsubtipo_global+"&estado="+estado_global+"&pagina="+pagina+"&num_pags="+num_pags+"', fin_listado_productos)", 1000);
}

var myConn_carga_ficha = new XHConn();
var fin_carga_ficha = function (oXML) { document.getElementById('div_ficha_producto').innerHTML = oXML.responseText;};
function carga_ficha(idproducto,pagina,productos_x_pag){
		cargando_ficha = '<table width="587" height="246" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_ficha += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_ficha_producto').innerHTML = cargando_ficha;
		window.setTimeout("myConn_carga_ficha.connect('catalogo/ficha.php', 'GET', 'idproducto="+idproducto+"&pagina="+pagina+"&prod_x_pag="+productos_x_pag+"', fin_carga_ficha)", 1000);
}

var myConn_carga_imagen = new XHConn();
var fin_carga_imagen = function (oXML) { document.getElementById('div_foto_principal').innerHTML = oXML.responseText;};
function carga_imagen(foto){
		cargando_imagen = '<table width="253" height="247" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_imagen += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_foto_principal').innerHTML = cargando_imagen;
		window.setTimeout("myConn_carga_imagen.connect('catalogo/ver_foto.php', 'GET', 'foto="+foto+"', fin_carga_imagen)", 1000);
}

//---------------MAPA SITUACIÓN---------------------------------------------------

var map_inmobiliaria; //hacemos global la variable para poder interactuar con otras funciones
function mapa_inmobiliaria() {

			latitud_centro = "41.691169";
			longitud_centro = "2.723458";
			inicia_mapa_inmobiliaria(longitud_centro,latitud_centro);
	
function inicia_mapa_inmobiliaria(longitud_centro,latitud_centro){

	document.getElementById('div_mapa_inmobiliaria').style.width = '680px';
	document.getElementById('div_mapa_inmobiliaria').style.height = '350px';

	var icon = new GIcon();
icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png";
//icon.shadow = "http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png"; 
	icon.iconSize = new GSize(22, 23);
	//icon.shadowSize = new GSize(37, 34);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);

	map_inmobiliaria = new GMap2(document.getElementById("div_mapa_inmobiliaria"));
	map_inmobiliaria.addControl(new GSmallMapControl());
	map_inmobiliaria.setCenter(new GLatLng(latitud_centro, longitud_centro), 16);
	map_inmobiliaria.setMapType(G_NORMAL_MAP);
	
	//function createInfoMarker(point, address) {
	//var marker = new GMarker(point, icon);
	//return marker;
	//}
	
	var point = new GPoint(longitud_centro, latitud_centro);
	//var address = 'prueba';
	//var marker = createInfoMarker(point, address);
	var marker = new GMarker(point, icon);
	map_inmobiliaria.addOverlay(marker);
	
} // fin funcion inicia mapa

} // fin carga_mapa