/* Á É Í Ó Ú Ü Ñ á é í ó ú ü ñ */ 
function Navegador() {

    var ua, s, i;

    this.isIE    = false;
    this.isNS    = false;
    this.version = null;

    ua = navigator.userAgent;

    s = "MSIE";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isIE = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

    s = "Netscape6/";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

        // Treat any other "Gecko" navegador as NS 6.1.

    s = "Gecko";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        this.version = 6.1;
        return;
    }
}

var navegador = new Navegador();

//GESTION DE COOKIES
//Autor: Iván Nieto Pérez
//Este script y otros muchos pueden
//descarse on-line de forma gratuita
//en El Código: www.elcodigo.com
function CojerValorCookie(indice) {
    //indice indica el comienzo del valor
    var galleta = document.cookie
    //busca el final del valor, dado por ;, a partir de indice
    var finDeCadena = galleta.indexOf(";", indice)
    //si no existe el ;, el final del valor lo marca la longitud total de la cookie
    if (finDeCadena == -1)
        finDeCadena = galleta.length

    return unescape(galleta.substring(indice, finDeCadena))
    }

function CojerCookie(nombre) {
    var galleta = document.cookie
    //construye la cadena con el nombre del valor
    var arg = nombre + "="
    var alen = arg.length            //longitud del nombre del valor
    var glen = galleta.length        //longitud de la cookie

    var i = 0
    while (i < glen) {
        var j = i + alen            //posiciona j al final del nombre del valor
        if (galleta.substring(i, j) == arg)    //si en la cookie estamo ya en nombre del valor        
            return CojerValorCookie(j)    //devuleve el valor, que esta a partir de j

        i = galleta.indexOf(" ", i) + 1        //pasa al siguiente
        if (i == 0)
            break                //fin de la cookie
    }
    return null                    //no se encuentra el nombre del valor
}

function GuardarCookie (nombre, valor, caducidad) {
    if(!caducidad)
        caducidad = Caduca(0)

    //crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
    //cada valor esta separado por ; y un espacio
    document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad + "; path=/"
}

function Caduca(dias) {
    var hoy = new Date()                                        //coge la fecha actual
    var msEnXDias = eval(dias) * 24 * 60 * 60 * 1000    //pasa los dias a mseg.

    hoy.setTime(hoy.getTime() + msEnXDias)            //fecha de caducidad: actual + caducidad
    return (hoy.toGMTString())
}

function BorrarCookie(nombre) {
    //para borrar la cookie, se le pone una fecha del pasado mediante Caduca(-1)
    document.cookie = nombre + "=; expires=" + Caduca(-1) + "; path=/"
}

function IntroducirCookie(nombre) {
    //establece la cookie: la caducidad es de 31 dias
    var _31dias = Caduca(31)                //crea la fecha de caducidad si 31 dias
    if (nombre != "") 
        GuardarCookie("crrlctrnc", nombre, _31dias)
}
function IntroducirCookie_pass(nombre) {
    //establece la cookie: la caducidad es de 31 dias
    var _31dias = Caduca(31)                //crea la fecha de caducidad si 31 dias
    if (nombre != "") 
        GuardarCookie("Password", nombre, _31dias)
}
 /*
function MostrarCookie(nombre, formulario) {
    if(CojerCookie(nombre) != null)
        formulario.nombre.value = CojerCookie(nombre)
}    */

function MostrarMiCookie() {
    if(CojerCookie('Nombre') != null){
        if (document.getElementById('usuario') != null){
            document.getElementById('usuario').value = CojerCookie('Nombre');
        }
    } 
    //MostrarCookie('Nombre', document.fvalida)
}
function MostrarMiCookie_pass() {
    if(CojerCookie('Password') != null){   //pass
        if(document.getElementById('pass') != null){
            document.getElementById('pass').value = CojerCookie('Password');
        }
        if(document.getElementById('id_entered_Chave') != null){   //id_entered_Chave
            document.getElementById('id_entered_Chave').value = CojerCookie('Password');
        }
    }
    //MostrarCookie('Password', document.fvalida)
}

/*
window.onload = MostrarMiCookie;
if (document.captureEvents) {                //N4 requiere invocar la funcion captureEvents
    document.captureEvents(Event.LOAD)
}
*/

/*
*************************   FIN GESTIÓN DE COOKIES  *************************************
*******************************************************************************************************************************************
*/


/*
Función para elementoComentario.php, mostrar modo extendido do elemento comentario
*/
    function verMas(cont)
    {
        var cadena = cont.toString();
        var opt=document.getElementById('c-texto' + cadena);
      
        //opt.style.background="scroll 0 0";     
        
        document.getElementById('menos-coment' + cadena).style.display="block";
        document.getElementById('mas-coment'+ cadena).style.display="none"; 
        
        //opt.style.height="auto";    
    }

/*
Función para elementoComentario.php, mostrar modo resumido do elemento comentario
*/
    function verMenos(cont)
    {
        var cadena = cont.toString();
        var opt=document.getElementById('c-texto' + cadena);    
     
        document.getElementById('mas-coment'+ cadena).style.display="block";
        document.getElementById('menos-coment'+ cadena).style.display="none";
    }
/*
Función para elementoListaCapaMapaBusq.php, mostrar modo extendido do elemento
*/
    function mais_info_b(cont, tipo)
    {
        var cadena = cont.toString(); 
        if(tipo ==0){
            document.getElementById('menos_info_mapa_b_' + cadena).style.display="block";
            document.getElementById('mas_info_mapa_b_'+ cadena).style.display="none";  
            document.getElementById('info_mapa_b_'+ cadena).style.display="block"; 
        }
        else{
            document.getElementById('mas_info_capa_b_'+ cadena).style.display="none";
            document.getElementById('menos_info_capa_b_'+ cadena).style.display="block";
            document.getElementById('info_capa_b_'+ cadena).style.display="block"; 
        }   
    } 


    /*
        Función para validar os campos da páxina de edición de usuario
    */
        function validar_edicion(){  

            if(control_logueo == '1'){
                var todo_ok = true;     
				if((document.getElementById('id_entered_Chave_nova').value != '') || (document.getElementById('id_confpass').value != '')){	
					if(((document.f_modificaUser.entered_Chave_nova.value != document.f_modificaUser.confpass.value) ||((document.f_modificaUser.confpass.value.length>10) || (document.f_modificaUser.confpass.value.length<5) ))&&(todo_ok == true)){    
						document.f_modificaUser.entered_Chave_nova.focus();
						todo_ok = false; 
						if(document.f_modificaUser.entered_Chave_nova.value != document.f_modificaUser.confpass.value){
							alerta_aviso(vector_de_traduccion['error_copia_password']);
						}
						else{       
							alerta_aviso(vector_de_traduccion['error_Password']);
						}
					}   
				}
                //valido nombre
                /*if((document.f_modificaUser.nombre.value.length == 0)&&(todo_ok == true)){       
                    document.f_modificaUser.nombre.focus(); 
                    todo_ok = false;            
                    alerta_aviso(vector_de_traduccion['error_nome']);
                } */
                //valido fecha
				if (document.getElementById('fecha_nacemento').value.length!=0){                 //NON É OBLIGATORIO PERO SE EXISTE DEBE SER CORRECTA
					var data_ok = validar_Data(document.getElementById('fecha_nacemento').value);
					if(data_ok == false && document.getElementById('fecha_nacemento').value != ''){       
						document.getElementById('fecha_nacemento').focus(); 
						todo_ok = false;              
						document.getElementById('explicacion_fecha').className = 'explicacion_roja';
					}
				}
				else
				{
					document.getElementById('fecha_nacemento').value = ' ';
				}
                //valida correo

                if(todo_ok == true){
                    //se envia el formulario
                    document.f_modificaUser.submit();
                }
            }
            else{
                alerta_erro(vector_de_traduccion['error_de_entrada']);
            }
        }
  

       
/*
Funcións para registroUsuario.php, 
para validar los campos del formulario
*/ 
    function f_registrar(){
        if (document.getElementById('terminos').checked == true){
            document.getElementById('id_boton').style.visibility = ""; 
        }
        else {
            document.getElementById('id_boton').style.visibility = "hidden";
        }
        return 0;
    }

    function validar_rexistro(){
        //valido usuario
        var todo_ok = true;
		var minimo_caracteres_nome = 3;
		
        //valida contraseña
        if(((document.fvalidar.pass.value.length == 0)||(document.fvalidar.pass.value.length>10)) && todo_ok == true){ 
            document.fvalidar.pass.focus();
            document.getElementById('info_pass').className = 'explicacion_roja';
			todo_ok = false;              
            alerta_aviso(vector_de_traduccion['error_Password']);
        }                   
        //valida confirmacion de contraseña
        if(((document.fvalidar.pass2.value != document.fvalidar.pass.value) || (document.fvalidar.pass2.value.length==0)||(document.fvalidar.pass2.value.length>10)) && todo_ok == true){                                              
            document.fvalidar.pass2.focus();
			document.getElementById('info_pass').className = 'explicacion_roja';
            todo_ok = false;        
            alerta_aviso(vector_de_traduccion['error_copia_password']);
        } 
        //valido nombre
        /*if((document.fvalidar.nombre.value.length < minimo_caracteres_nome )  && todo_ok == true){       
            document.fvalidar.nombre.focus(); 
            todo_ok = false;            
            alerta_aviso(vector_de_traduccion['error_nome']);
			document.getElementById('explicacion_nome').className = 'explicacion_roja';
        } */

        if ( todo_ok == true){
           // var correo_ok = comproba_mail();
			var correo_ok = validar_Mail(document.fvalidar.mail.value);
            if(correo_ok== false){                             
                document.fvalidar.mail.focus(); 
                todo_ok = false;             
                alerta_aviso(vector_de_traduccion['error_mail']);    
            }
        }
                                                  
        if ( todo_ok == true){
            //se envia el formulario
            validar_registro_2(); 
        }  
    }
    
    function validar_registro_2(){  
    
        var minimo_caracteres_nick = 3;
		var maximo_caracteres_nick = 15;
		var caracteresPermitidos= /^([a-zA-Z0-9_])*$/;
		var cadena=document.getElementById('usuario').value;
		
		if(cadena.length>2 && cadena.length<16){
			if (!caracteresPermitidos.test(cadena) || cadena.split(" ").length > 1) {
				document.fvalidar.usuario.focus();
				document.getElementById('explicacion_usuario').className = 'explicacion_roja';
				alerta_aviso(vector_de_traduccion['error_Usuario']);   ;
			}
			else{
					  
				//miramos cal é a chave do kaptcha 
				var params = 'USER=' + escape(document.fvalidar.usuario.value);  
				var WEB_chamada='check_usuario.php?'+ escape(params);  
				var obxeto_validar = Crea_obx_HttpRequest(); 
				
				obxeto_validar.open("POST", WEB_chamada, true); 
				obxeto_validar.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); 
				obxeto_validar.setRequestHeader("Content-length", params.length); 
				obxeto_validar.setRequestHeader("Connection", "close");  
				
				//obxeto.open('GET', WEB_chamada); 
				obxeto_validar.onreadystatechange = function(){ 
					if (obxeto_validar.readyState == 4 ) {  
						var kap_key = obxeto_validar.responseText; 
						//comprobamos se son iguais
						if(kap_key != '0'){ 
							validar_registro_3(kap_key); 
						}
						else{           
							document.fvalidar.usuario.focus();
							alerta_aviso(document.fvalidar.usuario.value + ' ' + vector_de_traduccion['error_Usuario_existente']); 
							todo_ok = false;   
						}
					}
				}                                 
				try {obxeto_validar.send(params); }
				catch(erro){alerta_erro(erro.description)};
			} 
		}
		else{
		
		}
    }
    
    function validar_registro_3(kap_key){      
        //validamos texto en la imagen
        if((document.fvalidar.captcha.value.length==0)){ 
            document.fvalidar.captcha.focus(); 
            alerta_aviso(vector_de_traduccion['error_imaxen']);
        }
        else{   
            //comprobamos se son iguais
            if(kap_key != document.fvalidar.captcha.value){ 
                document.fvalidar.captcha.focus(); 
                todo_ok = false;   
                alerta_aviso(vector_de_traduccion['error_imaxen']);
            }
            else{       
                document.fvalidar.submit(); 
            }
        }      
    }
    
    function validar_Mail(valor) { 
        if (/[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/.test(valor)) {
            return true
        }
        else {
            return false;
        }
    }
     
    function validar_Data(valor) {
		if (/^\d{1,2}\-\d{1,2}\-\d{2,4}$/.test(valor)) {  
			var datos = valor.split('-');
			var ano =  parseInt(datos[2]);
			var mes =  parseInt(datos[1]);
			var dia =  parseInt(datos[0]);
			if (mes > 12){
				return false;
			}
			var max_dia =  30;  
			if ( mes == 2 ){
				if ((ano % 4 == 0) && ((ano % 100 != 0) || (ano % 400 == 0))){ 
					max_dia =  29; 
				}
				else{ 
					max_dia =  28; 
				}
			}
			if ((mes == 1) || (mes == 3) || (mes == 5) || (mes == 7) || (mes == 8) || (mes == 10) || (mes == 12)){
				max_dia =  30;
			} 
			if (dia > max_dia){
				return false;
			} 
			return true
		}
		else {               
			return false;
		}
	}
    
    
/*
    Función para validar un comentario
*/

    var Reserva_id = '';

    function valido_coment(mi_tipo, mi_id){
        var textos_alert = '';
		document.getElementById("comentario_novo").value=document.getElementById("comentario_novo").value.replace(/^\s*|\s*$/g,"");
        if (document.getElementById("comentario_novo") != null){
            if(document.getElementById("comentario_novo").value!=""){
                
                                                               
				var mi_comentario = document.getElementById("comentario_novo").value;    
				if(control_logueo == '1'){  
					var params = 'tipo=' + mi_tipo;
					params = params + '&mi_id=' + mi_id;
					Reserva_id = mi_id; 
					params = params + '&comentario=' + mi_comentario; 
					var WEB_chamada="engadirComentario.php?" + escape(params);
					var obxeto_comentario = Crea_obx_HttpRequest();
											  
					obxeto_comentario.open("POST", WEB_chamada, true); 
					obxeto_comentario.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); 
					obxeto_comentario.setRequestHeader("Content-length", params.length); 
					obxeto_comentario.setRequestHeader("Connection", "close"); 
					obxeto_comentario.onreadystatechange = function(){ 
						if (obxeto_comentario.readyState == 4 ) {
							ver_resultado_novo_comentario (obxeto_comentario.status, obxeto_comentario.responseText); 
							document.getElementById('explicacion_comentario').style.visibility="hidden";
						}
					}    
					try {                       
						obxeto_comentario.send(params); 
					}
					catch(erro){
						error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + '</strong>' + vector_de_traduccion['mns_erro_x'] + ' "' +  erro.description + '"'; 
						alerta_erro(error);
					}
				}
				else{   
					mensaxe = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + '</strong>' + vector_de_traduccion['mns_logueo'] +  erro.description + '"'; 
					alerta_aviso(mensaxe);    
				}
			}
			else{
				textos_alert = vector_de_traduccion['mns_sen_comentario'];
                textos_alert = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + '</strong>' + vector_de_traduccion['mns_sen_comentario'] ; 
                document.getElementById('explicacion_comentario').style.visibility="visible";
				//alerta_aviso(textos_alert);
			
			}
            
        }  
    }
    
    function ver_resultado_novo_comentario (su_status, su_responseText){
        var error = ''; 
        if(su_status == 200){       
            if (document.getElementById("id_mensaje_nota") != null){   
                var datos_devoltos = su_responseText;   
                error = '<br/><strong>' + vector_de_traduccion['mns_indicar'] + '</strong>' + datos_devoltos + '<strong>' + vector_de_traduccion['mns_fue_anhadido'] + '</strong>';
                //alerta_info(error);                       
            }
            cargaComentarios(Reserva_id);
        }
        else if(su_status == 404){
            if (document.getElementById("id_mensaje_nota") != null){
                error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + '</strong>' + vector_de_traduccion['mns_erro_404_b'] ;
                alerta_erro(error);
            }
        }
        else{
            if (document.getElementById("id_mensaje_nota") != null){
                error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + '</strong>' + vector_de_traduccion['mns_erro_x'] + ' "' + su_status + '"'; 
                alerta_erro(error);
            }
        }        
    }     
 
/*
    Función para reemplazar una cadena por otra
*/   
function str_replace(search, replace, subject) {
 
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}

/*
    Función para a creación dun obxecto XMLHttpRequest para calquera navegador que o soporte.
*/
    function Crea_obx_HttpRequest(){                                    
        var obj; 
        if(window.XMLHttpRequest) { // Se non é IE 
            obj = new XMLHttpRequest(); 
        } 
        else { // Se é IE4 ou outro.... 
            try { 
                obj = new ActiveXObject("Microsoft.XMLHTTP"); 
                } 
            catch (e) { 
                alerta_erro(vector_de_traduccion['erro_objecto']); 
            } 
        }  
        return obj; 
    }
    
/*
    Función para desloguearse do sistema
*/
    function deslogueo(){  
		
        var obxeto = Crea_obx_HttpRequest();    
        obxeto.open('GET', 'deslogueo.php'); 
        obxeto.onreadystatechange = function(){ 
            if (obxeto.readyState == 4 ) {
				BorrarCookie('crrlctrnc');	BorrarCookie('Password');		
				
				document.location.href=www_server;
            }
        } 
        obxeto.send('');                      
    }
       
/*
    Función para obetr un novo mapa no sixtema
*/
    var control_cache = true;
    function mapa_novo_cache(){
		if(confirm(vector_de_traduccion["Pregunta_novo"])){
			control_cache = false;
			document.location.href=www_server + 'nuevo-ikimapa';
		}
	}
    
    
/*
    Función para ocultar ou mostrar o div que conten os parametros de busqueda avanzada
*/
    function on_off_busq(){
        var enlace=document.getElementById('mostra_busq');
        var busq_av=document.getElementById('busca_avanz');
        if(busq_av.style.display == 'none'){
            enlace.innerHTML = vector_de_traduccion['busca_ava_off'];
            busq_av.style.display = 'block';
        } 
        else {
            enlace.innerHTML = vector_de_traduccion['busca_ava_on'];
            busq_av.style.display = 'none';
        }
    }
    
/*
    Funcion para validar a busqueda simple
*/
    function valida_busq(){
        if(document.f_busqueda.bus_txt.value.length==0 && document.f_busqueda.sel_catego.value == ''){
            alerta_erro(vector_de_traduccion['error_palabra_corta']);             
            document.f_busqueda.bus_txt.focus();  
        }
        else{
            if ( document.f_busqueda.bus_txt.value.length < 4){
                alerta_erro(vector_de_traduccion['error_palabra_corta']);
            }
            else{//se envia el formulario  
                document.f_busqueda.submit();  
            }
        }
    }
    
	
function trim(cadena)
{

	/*cadena.replace(/\s+/gi, ‘ ‘); //sacar espacios repetidos dejando solo uno
	cadena = cadena.replace(/^\s+|\s+$/gi, ”);*/

}
	
	
/*
    Funcion para buscar mapas e capas
*/
    function buscar(texto,tag){
		
		if(tag && tag!=""){
			var tags="&tag=1";
		
		}
		else{
			var tags="";
		}
		/*if(texto){
			texto = texto;
			//alert(texto);
		}*/
        if(texto && texto != ''){
			var texto2 = texto;
            //var texto = document.f_busqueda.bus_txt.value;
            texto = texto.split(' ');
            var texto_fin = '';
            for (var i= 0; i<texto.length; i++){
                if ( texto[i] != '' ){
                    texto_fin = texto_fin + ' ' +  texto[i];   
                }
            }
    
             if ( texto_fin.length < 1){ 
                alerta_erro(vector_de_traduccion['error_palabra_corta']);
             }
             else{
                // comprobamos que estamos na paxina de busqueda
                if(document.getElementById('mapa_busqueda')){
                    document.f_busqueda.sel_catego.value = '';
                    document.f_busqueda.bus_txt.value = texto_fin;
                    valida_busq(); 
                }
                else{        
                    document.location.href= www_server + 'busqueda.php?t=' + texto2+tags;
                } 
             }   
        }
        else{
            var t= document.getElementById('inp_busca_general').value;//.replace(/^\s+/g,'').replace(/\s+$/g,'');
			//alert(t);
                var texto = t;
                texto = texto.split(' ');
                var texto_fin = '';
                for (var i= 0; i<texto.length; i++){
                    if ( texto[i] != '' ){
                        texto_fin = texto_fin + ' ' +  texto[i];   
                    }
                }    
            if( texto_fin.length < 1){
                alerta_erro(vector_de_traduccion['error_palabra_corta']);
            }
            else{
                // comprobamos que estamos na paxina de busqueda
                if(document.getElementById('mapa_busqueda')){
                    document.f_busqueda.sel_catego.value = '';
                    document.f_busqueda.bus_txt.value = texto_fin;
                    valida_busq(); 
                }
                else{      
                    document.location.href= www_server + 'busqueda.php?t=' + t;
                }
            } 
        }
    }

    
/*
    Funcion para validar a busqueda avanzada
*/
    function valida_busq_avnz(){  
        var valido = false;
        if(document.f_busqueda.inp_todas_palabras){ 
            if(document.f_busqueda.inp_todas_palabras.value.length!=0){             
                valido = true; 
            }                  
            if(document.f_busqueda.sel_fecha.value!=0){
                valido = true;
            }
            if(document.f_busqueda.inp_frase.value.length!=0){             
                valido = true; 
            }      
            if(document.f_busqueda.sel_categoria.value!=''){
                valido = true;
            }
            if(document.f_busqueda.inp_palabra.value.length!=0){             
                valido = true;
            }                      
            if(document.f_busqueda.sel_valoracion.value!=-1){
                valido = true;
            }
            if(document.f_busqueda.inp_excepto_palabras.value.length!=0){             
                valido = true;
            }                   
            if(document.f_busqueda.sel_idioma.value!=0){
                valido = true;
            }  
            if(valido){
                //se envia el formulario
                document.f_busqueda.bus_txt.value='';
                document.getElementById('inp_busca_general').value='';  
                document.f_busqueda.submit();
            }
        }    
        if(document.getElementById('inp_busca_general').value !=''){
            buscar('');    
        }  
        else{
            //alerta_erro('Deberá introducir algún campo de la búsqueda avanzada.');
        }
                
    }
    
    
/*
    Funcións para o paxinado dos comentarios dun mapa
*/
    function pasarPax(page, id, tipo,perfil){
		var envioPerfil="";
		if(perfil==1)
			envioPerfil="&perfil=1";

			
        if(tipo == 1){
            call("pagingComentarios.php?MAP="+ id +"&pax=" + page + envioPerfil, this, callback_pasarPax);  
        }
        if(tipo == 2){
            call("pagingComentarios.php?LAYERS="+ id +"&pax=" + page + envioPerfil, this, callback_pasarPax);  
        }
        if(tipo == 3){
            call("pagingComentarios.php?iduser="+ id +"&pax=" + page + envioPerfil, this, callback_pasarPax);  
        }
        if(tipo == 4){
            call("pagingComentariosCanalesListas.php?idcanal="+ id +"&pax=" + page + envioPerfil, this, callback_pasarPax);  
        }
        if(tipo == 5){
            call("pagingComentariosCanalesListas.php?idlista="+ id +"&pax=" + page + envioPerfil, this, callback_pasarPax);  
        }
    }

    function callback_pasarPax(txtResposta)
    {
        document.getElementById('id_comentarios_usuarios').innerHTML = txtResposta;   
    }  

        
/*******************
*   Funcion para engadir ou non un novo mapa a edición.
*  Vai a empregar unha variable para comprobar se se pode subir o se ten que preguntar se se quere eliminar ao mapa anterior. 
*********/  
    function examinar_mapa_a_editar ( sua_id_mapa, num_capas,id_editando){
        /* Num capas é para nun futuro ter a oportunidade de decidir se as capas do mapa se engaden as que xa temos dentro.*/
        /*var capas_actuais = document.getElementById('num_capas_no_mapa').className;   //num_capas_x
		//if(id_editando!="")

        capas_actuais = capas_actuais.split('_');
        capas_actuais = capas_actuais[2];
        capas_actuais = capas_actuais *1;
        if (capas_actuais > 0 && id_editando!=sua_id_mapa){
            var mensaxe = vector_de_traduccion['com_editar_mapa_n'] + '<a href="eikimapa/' + sua_id_mapa + '">' + vector_de_traduccion['com_editar_mapa_a'] + '</a>';
        //vector_de_traduccion['com_editar_mapa_n']
        //vector_de_traduccion['com_editar_mapa_a']  
            alerta_aviso(mensaxe);
        }
        else{ */
            document.location.href= www_server + 'eikimapa/' + sua_id_mapa;
        //}
    }     
    
/*
    Funcións para añadir á sesión a capa do id id_capa
*/
	//var n_mapas_engadidos=0;

    function anadir_a_sesion(id_capa){
    	window.location.href="mapToikiMap/"+id_capa;
       /* var WEB_chamada='actualiza_sesion.php';
        var obxeto = Crea_obx_HttpRequest(); 
        var params = 'id_capa=' + id_capa + '&anadir=si';
        
		document.getElementById('id_mensaje_alert').style.visibility="hidden";
		document.getElementById('id_mensaje_alert').style.display="none";
		document.getElementById('id_mensaje_nota').style.visibility="hidden";
		document.getElementById('id_mensaje_nota').style.display="none";
		document.getElementById('id_mensaje_info').style.visibility="hidden";
		document.getElementById('id_mensaje_info').style.display="none";
		
        obxeto.open('POST', WEB_chamada, true); 
        obxeto.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8'"); 
        obxeto.setRequestHeader("Content-length", params.length); 
        obxeto.setRequestHeader("Connection", "close"); 
        
        obxeto.onreadystatechange = function(){ 
            if (obxeto.readyState == 4 ) {
                var datos_mensaxe = new Array();
                eval (obxeto.responseText);
                if ( document.getElementById('num_capas_no_mapa') != null){
                    document.getElementById('num_capas_no_mapa').className = datos_mensaxe[0]; 
                }
                if (datos_mensaxe[1]!= ''){

						alerta_info(datos_mensaxe[1]);
						document.getElementById("id_notificaciones").style.visibility="visible";

                }
                if (datos_mensaxe[2]!= ''){
                    alerta_aviso(datos_mensaxe[2]);
					document.getElementById("id_notificaciones").style.visibility="hidden";
					
                }
                if (datos_mensaxe[3]!= ''){
                    alerta_erro(datos_mensaxe[3]);
					document.getElementById("id_notificaciones").style.visibility="hidden";
                }   
				
				
            }
        }    
        try {obxeto.send(params); }
        catch(erro){alerta_erro(erro.description)}; */
    }
	
     function anadir_a_favoritos(id_elemento, id_usuario, tipo, id_boton)
	{
		
		if(document.getElementById(id_boton).className == "img_boton btn_anadir_favorito_sel")
		{
			var accion="eliminar";
			//alerta_aviso(aviso);
			document.getElementById(id_boton).alt="Añadir a favoritos";
			document.getElementById(id_boton).title="Añadir a favoritos";
		}
		else
		{
			var accion="insertar";			
			document.getElementById(id_boton).alt="Quitar de favoritos";
			document.getElementById(id_boton).title="Quitar de favoritos";
		}
		var WEB_chamada='anadir_favorito.php';
		var obxeto = Crea_obx_HttpRequest(); 
		var params = 'id_elemento=' + id_elemento + '&id_usuario='+id_usuario+'&tipo='+tipo+'&accion='+accion;
		
		obxeto.open('POST', WEB_chamada, true); 
		obxeto.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8'"); 
		obxeto.setRequestHeader("Content-length", params.length); 
		obxeto.setRequestHeader("Connection", "close"); 
		
		obxeto.onreadystatechange = function(){ 
			if (obxeto.readyState == 4 ) {
				if(obxeto.responseText=='BORRADO'){
					switch(tipo){
					case 0:
						alerta_info('El ikiMapa ha sido eliminado de favoritos');
					break;
					case 1:
						alerta_info('El mapa ha sido eliminado de favoritos');
					break;
					
					case 2:
						alerta_info('El canal ha sido eliminado de favoritos');
					break;
					
					case 3:
						alerta_info('La lista ha sido eliminada de favoritos');
					break;
						
					}
					//document.getElementById(id_boton).className="ffavoritos";	
					eval("document.getElementById('" + id_boton + "').className = 'img_boton btn_anadir_favorito';");
					//document.getElementById(id_boton).src="img_boton btn_anadir_favorito";	
				}
				if(obxeto.responseText=='OK'){
					switch(tipo){
					case 0:
						alerta_info('El ikiMapa ha sido añadido a favoritos');
					break;
					case 1:
						alerta_info('El mapa ha sido añadido a favoritos');
					break;
					
					case 2:
						alerta_info('El canal ha sido añadido a favoritos');
					break;
					
					case 3:
						alerta_info('La lista ha sido añadida a favoritos');
					break;
						
					}
					//document.getElementById(id_boton).className="ffavoritos_sel";
					eval("document.getElementById('" + id_boton + "').className = 'img_boton btn_anadir_favorito_sel';");
				}
									
			}
		}

		try {obxeto.send(params); }
		catch(erro){alerta_erro(erro.description)}; 
    }
	
	
	function anadir_a_favoritos2(id_elemento, id_usuario, tipo, id_boton)
	{
		
		if(document.getElementById(id_boton).className == "ffavoritos_sel")
		{
			var accion="eliminar";
			//alerta_aviso(aviso);
			document.getElementById(id_boton).alt="Añadir a favoritos";
			document.getElementById(id_boton).title="Añadir a favoritos";
		}
		else
		{
			var accion="insertar";			
			document.getElementById(id_boton).alt="Quitar de favoritos";
			document.getElementById(id_boton).title="Quitar de favoritos";
		}
		var WEB_chamada='anadir_favorito.php';
		var obxeto = Crea_obx_HttpRequest(); 
		var params = 'id_elemento=' + id_elemento + '&id_usuario='+id_usuario+'&tipo='+tipo+'&accion='+accion;
		
		obxeto.open('POST', WEB_chamada, true); 
		obxeto.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8'"); 
		obxeto.setRequestHeader("Content-length", params.length); 
		obxeto.setRequestHeader("Connection", "close"); 
		
		obxeto.onreadystatechange = function(){ 
			if (obxeto.readyState == 4 ) {
				if(obxeto.responseText=='BORRADO'){
					/*switch(tipo){
					case 0:
						alerta_info('El ikiMapa ha sido eliminado de favoritos');
					break;
					case 1:
						alerta_info('El mapa ha sido eliminado de favoritos');
					break;
					
					case 2:
						alerta_info('El canal ha sido eliminado de favoritos');
					break;
					
					case 3:
						alerta_info('La lista ha sido eliminada de favoritos');
					break;
						
					}*/
					//document.getElementById(id_boton).className="ffavoritos";	
					eval("document.getElementById('" + id_boton + "').className = 'ffavoritos';");
					//document.getElementById(id_boton).src="img_boton btn_anadir_favorito";	
				}
				if(obxeto.responseText=='OK'){
					/*switch(tipo){
					case 0:
						alerta_info('El ikiMapa ha sido añadido a favoritos');
					break;
					case 1:
						alerta_info('El mapa ha sido añadido a favoritos');
					break;
					
					case 2:
						alerta_info('El canal ha sido añadido a favoritos');
					break;
					
					case 3:
						alerta_info('La lista ha sido añadida a favoritos');
					break;
						
					}*/
					//document.getElementById(id_boton).className="ffavoritos_sel";
					eval("document.getElementById('" + id_boton + "').className = 'ffavoritos_sel';");
				}
									
			}
		}

		try {obxeto.send(params); }
		catch(erro){alerta_erro(erro.description)}; 
    }

    
    
    /******************************************************
     * Funcion para a busca con enter.
     *******************************************************/
    function buscaenter(myfield,e){
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        else return true;

        if (keycode == 13)
        {   
            if(myfield != ''){ 
                buscar(myfield.value);
            } 
            return false;
        }
        else
        return true;
    }
    
    /******************************************************
     * Funcion para a busca con enter.
     *******************************************************/
    function mostra_busq_enter(myfield,e){
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        else return true;

        if (keycode == 13)
        {
            valida_busq();
            return false;
        }
        else
        return true;
    }  
    
/*
    Funcion que descarga o kml dun mapa ou capa e o abre con google Earth
    tipo = 0 -> mapa
    tipo = 1 -> capa
*/
    function myGoogle_earth(id, tipo){  
        var winName='GoogleEarth'; 
        //var windowprops ="top=0,left=0,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no"; 
        var tope = screen.height / 2 - 100;
        var izqui = screen.width / 2 - 200;
        var opciones = 'width=400,height=200,scrollbars=yes,top=' + tope + ',left=' + izqui;                                      
         
        if(tipo == 1){
            window.open(www_server+'openlayers_kml.php?EXP=Y&LAYERS='+id, winName, opciones);
        }
        if(tipo == 0){
            window.open(www_server+'openlayers_kml.php?EXP=Y&MAP='+id, winName, opciones);    
        }
    } 
    
/*
*   Funcion que engade unha visita a un mapa ou capa ou usuario con id, 
    tipo -> corresponde con 0 se é un mapa, 1 se é unha capa, 2 se é un usuario 
*/
    function anadir_visitas(id, tipo){
        var WEB_chamada='anadir_v.php';
        var obxeto = Crea_obx_HttpRequest(); 
        var params = 'visita=1&id_obx=' + id +'&tipo=' + tipo;
                              
        obxeto.open('POST', WEB_chamada, true); 
        obxeto.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8'"); 
        obxeto.setRequestHeader("Content-length", params.length); 
        obxeto.setRequestHeader("Connection", "close"); 
        
        obxeto.onreadystatechange = function(){ 
            if (obxeto.readyState == 4 ) {  
               // alerta_erro(obxeto.responseText);    // DESCOMENTAR PARA VER RESULTADO
            }
        }    
        try {obxeto.send(params); }
        catch(erro){alerta_erro(erro.description)};
       
    }
    
/*
    Funcion para marcar os div das estrelas dos votos.
*/
    function marca_votos(num){
        if(document.getElementById('id_clasificacion_estrellas')!=null){ 
            document.getElementById('id_clasificacion_estrellas').className = 'clasificacion estrellas' + num;
        }
        
        for(var i=1;i<6;i++) {
            if(document.getElementById('btn_estrella_'+i)!=null){ 
                document.getElementById('btn_estrella_'+i).className=(i<=num?'over':'');
            }
        }
    }
	
    function desmarca_votos(){

        for(var i=1;i<6;i++) {
            if(document.getElementById('btn_estrella_'+i)!=null){ 
                document.getElementById('btn_estrella_'+i).className='';
            }
        }
    }
  
/*
    Funcion para ocultar o div da publicidade no mapa
*/
    function on_off_Publi(){
        var contenido = document.getElementById('mapa_publi_contenido'); 
        var cambio = false;
        if(contenido.style.display == 'none'){
            contenido.style.display = 'block';
            document.getElementById('mapa_publi').style.height = '120px'; 
            cambio = true;
        }
        if(contenido.style.display == 'block' && cambio==false){ 
            contenido.style.display = 'none';
            document.getElementById('mapa_publi').style.height = '20px'; 
        }
    }
    
    function pagingBusq_av(page){
        var num_pax = parseInt(document.f_busqueda.pax.value); 
        // rangos: 1-10 11-20 21-30 31-40 ...  
        var filas_paxina = 9;
        var max_paxinas = 10; 
        // rango : num_pax * max_paxinas - filas_paxina , num_pax * max_paxinas
        var rango = new Array(); 
        rango[0] = num_pax * max_paxinas - filas_paxina;
        rango[1] = num_pax * max_paxinas;
        if(page >= rango[0] && page <= rango[1]){
            // page dentro del rango
            page = (page-(rango[0]-1)).toString(); 
            resultados_busq(page);
        }
        else{
            if(page < rango [0]){
                // disminuimos un rango
                document.f_busqueda.pax.value = num_pax - 1;   
            }
            if(page > rango [1]){
                // aumentamos un rango
                document.f_busqueda.pax.value = num_pax + 1;
            }  
            if(page > 10){
                pax_busq = (page-rango[1]).toString();
            }
            else{
                pax_busq = page;
            }
            valida_busq_avnz();
        }
    }
    
    function borrar_mapa(id, pax, usuario_consulta, orden, vista){ 
        //var mensaxe = vector_de_traduccion['mns_borra_mapa']; 
		//TRADUCIR
        var mensaxe = '¿Estás seguro que quieres eliminar el ikiMapa?'; 
		id = id + '';
        if(confirm( mensaxe )){ 
			if(id != id_map_def_sis){ 
				var obxeto = Crea_obx_HttpRequest();
				obxeto.open('GET', 'borrar_mapa.php?MAP='+id, true);
				obxeto.onreadystatechange = function(){ 
					if (obxeto.readyState == 4 ) {
						var user_let = obxeto.responseText;
						carga_sus_mapas_nova(pax, usuario_consulta, orden, vista);  
					}
				}    
				try {obxeto.send(''); }
				catch(erro){alerta_erro(erro.description)};
				if(esExplorer() == true){
					document.getElementById('span_mapas').innerHTML = "" + (parseInt(document.getElementById('span_mapas').innerHTML) - 1) + "";
				}
				else{
					texto_anterior = document.getElementById('span_mapas').firstChild.nodeValue;
					texto_novo = (parseInt(texto_anterior) - 1 );
					while(document.getElementById('span_mapas').hasChildNodes()){
						document.getElementById('span_mapas').removeChild(document.getElementById('span_mapas').lastChild);
					}
					var nodoTexto = document.createTextNode(texto_novo);
					document.getElementById('span_mapas').appendChild(nodoTexto);
				}
			} 
		}
       
    }
	
	

    /*******************************************************************************************************************
    *   Funcions de control de errores e notificacións de eventos.
    */    
         
        function alerta_erro(mi_error){        
            if (document.getElementById('id_mensaje_alert') != null){
                var meu_txt = document.getElementById('id_mensaje_alert_p');
                meu_txt.innerHTML =  mi_error; 
				
				//-----------------------------------------------------------
                document.getElementById('id_mensaje_alert').style.visibility = ""; 
                document.getElementById('id_mensaje_alert').style.display = "";
				//-----------------------------------------------------------
				
				document.getElementById('id_mensaje_info').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_info').style.display = "none";
				
				document.getElementById('id_mensaje_nota').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_nota').style.display = "none";
				
				document.getElementById('id_mensaje_notificacion').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_notificacion').style.display = "none";
				
				document.getElementById('id_mensaje_disponible').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_disponible').style.display = "none";

            }
        }  
        function alerta_notificacion(mi_notificacion){        
            if (document.getElementById('id_mensaje_notificacion') != null){
                var meu_txt = document.getElementById('id_mensaje_notificacion_p');
                meu_txt.innerHTML =  mi_notificacion; 
				
				//-----------------------------------------------------------
                document.getElementById('id_mensaje_notificacion').style.visibility = ""; 
                document.getElementById('id_mensaje_notificacion').style.display = "";
				//-----------------------------------------------------------
				
				document.getElementById('id_mensaje_info').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_info').style.display = "none";
				
				document.getElementById('id_mensaje_nota').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_nota').style.display = "none";
				
				document.getElementById('id_mensaje_disponible').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_disponible').style.display = "none";
				
            }
        }  
        function alerta_aviso(mi_aviso){        
            if (document.getElementById('id_mensaje_nota') != null){
                var meu_txt = document.getElementById('id_mensaje_nota_p'); 
                meu_txt.innerHTML =  mi_aviso; 
				
				//-----------------------------------------------------------
                document.getElementById('id_mensaje_nota').style.visibility = ""; 
                document.getElementById('id_mensaje_nota').style.display = "";
				//-----------------------------------------------------------
				
				document.getElementById('id_mensaje_info').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_info').style.display = "none";
				
				document.getElementById('id_mensaje_alert').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_alert').style.display = "none";
				
				document.getElementById('id_mensaje_notificacion').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_notificacion').style.display = "none";
				
				document.getElementById('id_mensaje_disponible').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_disponible').style.display = "none";
            }
        }   
        function alerta_info(mi_info){        
            if (document.getElementById('id_mensaje_info') != null){
                var meu_txt = document.getElementById('id_mensaje_info_p'); 
                meu_txt.innerHTML =  mi_info; 
				
				//-----------------------------------------------------------
                document.getElementById('id_mensaje_info').style.visibility = ""; 
                document.getElementById('id_mensaje_info').style.display = "";
				//------------------------------------------------------------
				
				document.getElementById('id_mensaje_nota').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_nota').style.display = "none";
				
				document.getElementById('id_mensaje_alert').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_alert').style.display = "none";
				
				document.getElementById('id_mensaje_notificacion').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_notificacion').style.display = "none";
				
				document.getElementById('id_mensaje_disponible').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_disponible').style.display = "none";
            }
        }    
		
		function alerta_disponible(mi_info){        
            if (document.getElementById('id_mensaje_disponible') != null){
                var meu_txt = document.getElementById('id_mensaje_disponible_p'); 
                meu_txt.innerHTML =  mi_info; 
				
				//-----------------------------------------------------------
				document.getElementById('id_mensaje_disponible').style.visibility = ""; 
                document.getElementById('id_mensaje_disponible').style.display = "";
				//-----------------------------------------------------------
				
                document.getElementById('id_mensaje_info').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_info').style.display = "none";
				
				document.getElementById('id_mensaje_nota').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_nota').style.display = "none";
				
				document.getElementById('id_mensaje_alert').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_alert').style.display = "none";
				
				document.getElementById('id_mensaje_notificacion').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_notificacion').style.display = "none";
            }
        }  
        
        function pecha_alerta_erro(){ // Vai a ser a mesma función para pechar calquera das fiestras. (inicialmente).       
            if (document.getElementById('id_mensaje_alert') != null){
                var meu_txt = document.getElementById('id_mensaje_alert_p');
                meu_txt.innerHTML = '' ; 
                document.getElementById('id_mensaje_alert').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_alert').style.display = "none";
            }         
            if (document.getElementById('id_mensaje_nota') != null){
                var meu_txt = document.getElementById('id_mensaje_nota_p');
                meu_txt.innerHTML = '' ; 
                document.getElementById('id_mensaje_nota').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_nota').style.display = "none";
            }      
            if (document.getElementById('id_mensaje_info') != null){
                var meu_txt = document.getElementById('id_mensaje_info_p');
                meu_txt.innerHTML = '' ; 
                document.getElementById('id_mensaje_info').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_info').style.display = "none";
            }
			if (document.getElementById('id_mensaje_notificacion') != null){
                var meu_txt = document.getElementById('id_mensaje_notificacion_p');
                meu_txt.innerHTML = '' ; 
                document.getElementById('id_mensaje_notificacion').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_notificacion').style.display = "none";
            }
			if (document.getElementById('id_mensaje_disponible') != null){
                var meu_txt = document.getElementById('id_mensaje_disponible_p');
                meu_txt.innerHTML = '' ; 
                document.getElementById('id_mensaje_disponible').style.visibility = "hidden"; 
                document.getElementById('id_mensaje_disponible').style.display = "none";
            }
        }   

    /*******************************************************************************************************************
    *   Funcions de control das pestañas da web.
    */      function control_pestanhas_canales_listas(div_activar){
				switch(div_activar){
				case "listas":
					document.getElementById('caja_listas').style.display="block";
					document.getElementById('caja_canales').style.display="none";
					document.getElementById('pestanha_listas').style.backgroundColor="#336699";
					document.getElementById('pestanha_listas').style.color="white";
					document.getElementById('pestanha_listas').style.textDecoration="none";
					document.getElementById('pestanha_canales').style.backgroundColor="";
					document.getElementById('pestanha_canales').style.color="";
					document.getElementById('pestanha_canales').style.textDecoration="";
				break;
				case "canales":
					document.getElementById('caja_listas').style.display="none";
					document.getElementById('caja_canales').style.display="block";	
					document.getElementById('pestanha_canales').style.backgroundColor="#336699";
					document.getElementById('pestanha_canales').style.color="white";
					document.getElementById('pestanha_canales').style.textDecoration="none";
					document.getElementById('pestanha_listas').style.backgroundColor="";
					document.getElementById('pestanha_listas').style.color="";
					document.getElementById('pestanha_listas').style.textDecoration="";					
				break;
				}

			}	
        
            function control_pestanhas(pestanha_activa){
                if( document.getElementById(pestanha_activa) != null){     //display:block
                    if(document.getElementById('id_info_mapa')!=null){   
                        document.getElementById('id_info_mapa').style.visibility = 'hidden';
                        document.getElementById('id_info_mapa').style.display = 'none';  
                        
                        if(document.getElementById('span_' + 'id_info_mapa')!=null){
                            document.getElementById('span_' + 'id_info_mapa').style.color = '';
                            document.getElementById('span_' + 'id_info_mapa').style.textDecoration = '';
                            document.getElementById('span_' + 'id_info_mapa').style.backgroundColor = '';
                        }  
						// PESTANHAS
						if(document.getElementById('div_' + 'id_info_mapa')!=null)
							document.getElementById('div_' + 'id_info_mapa').className="inactive";
                    }                                                     
                    if(document.getElementById('div_capas_del_mapa')!=null){
                        document.getElementById('div_capas_del_mapa').style.visibility = 'hidden';
                        document.getElementById('div_capas_del_mapa').style.display = 'none';  
                        
                        if(document.getElementById('span_' + 'div_capas_del_mapa')!=null){
                            document.getElementById('span_' + 'div_capas_del_mapa').style.color = '';
                            document.getElementById('span_' + 'div_capas_del_mapa').style.textDecoration = '';
                            document.getElementById('span_' + 'div_capas_del_mapa').style.backgroundColor = '';
                        } 
						// PESTANHAS
						if(document.getElementById('div_' + 'div_capas_del_mapa')!=null)
							document.getElementById('div_' + 'div_capas_del_mapa').className="inactive";
                    }           
                    if(document.getElementById('id_mapa_base')!=null){
                        document.getElementById('id_mapa_base').style.visibility = 'hidden';
                        document.getElementById('id_mapa_base').style.display = 'none';  
                        
                        if(document.getElementById('span_' + 'id_mapa_base')!=null){
                            document.getElementById('span_' + 'id_mapa_base').style.color = '';
                            document.getElementById('span_' + 'id_mapa_base').style.textDecoration = '';
                            document.getElementById('span_' + 'id_mapa_base').style.backgroundColor = '';
                        } 
						// PESTANHAS
						if(document.getElementById('div_' + 'id_mapa_base')!=null)
							document.getElementById('div_' + 'id_mapa_base').className="inactive";
                    }                    
                    if(document.getElementById('id_capa_base')!=null){
                        document.getElementById('id_capa_base').style.visibility = 'hidden';
                        document.getElementById('id_capa_base').style.display = 'none';  
                        
                        if(document.getElementById('span_' + 'id_capa_base')!=null){
                            document.getElementById('span_' + 'id_capa_base').style.color = '';
                            document.getElementById('span_' + 'id_capa_base').style.textDecoration = '';
                            document.getElementById('span_' + 'id_capa_base').style.backgroundColor = '';
                        } 
						// PESTANHAS
						if(document.getElementById('div_' + 'id_capa_base')!=null)
							document.getElementById('div_' + 'id_capa_base').className="inactive";
                    }                    
                    if(document.getElementById('id_elementos_mapa')!=null){               
                        document.getElementById('id_elementos_mapa').style.visibility = 'hidden';
                        document.getElementById('id_elementos_mapa').style.display = 'none';
                        
                        if(document.getElementById('span_' + 'id_elementos_mapa')!=null){
                            document.getElementById('span_' + 'id_elementos_mapa').style.color = '';
                            document.getElementById('span_' + 'id_elementos_mapa').style.textDecoration = '';
                            document.getElementById('span_' + 'id_elementos_mapa').style.backgroundColor = '';
                        } 
                    }  
                    if(document.getElementById('id_info_mapa_total')!=null){ 
                        document.getElementById('id_info_mapa_total').style.visibility = 'hidden';
                        document.getElementById('id_info_mapa_total').style.display = 'none';
                        
                        if(document.getElementById('span_' + 'id_info_mapa_total')!=null){
                            document.getElementById('span_' + 'id_info_mapa_total').style.color = '';
                            document.getElementById('span_' + 'id_info_mapa_total').style.textDecoration = '';
                            document.getElementById('span_' + 'id_info_mapa_total').style.backgroundColor = '';
                        }  
                    }
                    if(document.getElementById('id_info_capa_total')!=null){ 
                        document.getElementById('id_info_capa_total').style.visibility = 'hidden';
                        document.getElementById('id_info_capa_total').style.display = 'none'; 
                        
                        if(document.getElementById('span_' + 'id_info_capa_total')!=null){
                            document.getElementById('span_' + 'id_info_capa_total').style.color = '';
                            document.getElementById('span_' + 'id_info_capa_total').style.textDecoration = '';
                            document.getElementById('span_' + 'id_info_capa_total').style.backgroundColor = '';
                        }   
                    }
                    /*if(document.getElementById('id_capas_mapa')!=null){
                        document.getElementById('id_capas_mapa').style.visibility = 'hidden';
                        document.getElementById('id_capas_mapa').style.display = 'none'; 
                        
                        if(document.getElementById('span_' + 'id_capas_mapa')!=null){
                            document.getElementById('span_' + 'id_capas_mapa').style.color = '';
                            document.getElementById('span_' + 'id_capas_mapa').style.textDecoration = '';
                            document.getElementById('span_' + 'id_capas_mapa').style.backgroundColor = '';
                        }
						// PESTANHAS 
						if(document.getElementById('div_' + 'id_capas_mapa')!=null)
							document.getElementById('div_' + 'id_capas_mapa').className="inactive";
                    }    */
                    if(document.getElementById('id_busca_capas')!=null){
                        document.getElementById('id_busca_capas').style.visibility = 'hidden';
                        document.getElementById('id_busca_capas').style.display = 'none'; 
                        
                        if(document.getElementById('span_' + 'id_busca_capas')!=null){
                            document.getElementById('span_' + 'id_busca_capas').style.color = '';
                            document.getElementById('span_' + 'id_busca_capas').style.textDecoration = '';
                            document.getElementById('span_' + 'id_busca_capas').style.backgroundColor = '';
                        } 
                    }  
                    if(document.getElementById('bloque_lista_mapas')!=null){
                        document.getElementById('bloque_lista_mapas').style.visibility = 'hidden';
                        document.getElementById('bloque_lista_mapas').style.display = 'none';
                        
                        if(document.getElementById('span_' + 'bloque_lista_mapas')!=null){
                            document.getElementById('span_' + 'bloque_lista_mapas').style.color = '';
                            document.getElementById('span_' + 'bloque_lista_mapas').style.textDecoration = '';
                            document.getElementById('span_' + 'bloque_lista_mapas').style.backgroundColor = '';
                        }  
                    }  
                    if(document.getElementById('bloque_lista_capas')!=null){
                        document.getElementById('bloque_lista_capas').style.visibility = 'hidden';
                        document.getElementById('bloque_lista_capas').style.display = 'none';
                        
                        if(document.getElementById('span_' + 'bloque_lista_capas')!=null){
                            document.getElementById('span_' + 'bloque_lista_capas').style.color = '';
                            document.getElementById('span_' + 'bloque_lista_capas').style.textDecoration = '';
                            document.getElementById('span_' + 'bloque_lista_capas').style.backgroundColor = '';
                        }  
                    }  
                    if(document.getElementById(pestanha_activa)!=null){
                        document.getElementById(pestanha_activa).style.visibility = '';
                        document.getElementById(pestanha_activa).style.display = 'block';
                    }
                    if(document.getElementById('span_' + pestanha_activa)!=null){
                        
						//document.getElementById('span_' + pestanha_activa).style.color = '#336699';
						
						document.getElementById('span_' + pestanha_activa).style.color = '#FFFFFF';
                        document.getElementById('span_' + pestanha_activa).style.textDecoration = 'none';
                        document.getElementById('span_' + pestanha_activa).style.backgroundColor = '#336699';
                    }   
                    if(document.getElementById('div_' + pestanha_activa)!=null){   
						document.getElementById('div_' + pestanha_activa).className="active";
					}
                    if (document.getElementById('titulo_azul') != null){
                        document.getElementById('titulo_azul').innerHTML = vector_de_traduccion[pestanha_activa];
                    } 
                    
                    if (pestanha_activa == 'id_elementos_mapa'){
                        if(document.getElementById('li_' + 'id_elementos_mapa')!=null){              
                            document.getElementById('li_' + 'id_elementos_mapa').style.visibility = 'visible';
                            document.getElementById('li_' + 'id_elementos_mapa').style.display = '';
                        }
                    }
                }
            }   
                         
                          
    /*
        Función para mostrar o div que terá o listado das capas dun usuario
    */ 
        function carga_sus_capas(pax, usuario_consulta){ 
            var WEB_chamada='cargaSusCapas.php?pax=' + pax + '&verUser=' + usuario_consulta;   
            var obxeto_lista_mapas = Crea_obx_HttpRequest(); 
                
            obxeto_lista_mapas.open('GET', WEB_chamada, true); 
            obxeto_lista_mapas.onreadystatechange = function(){ 
                if (obxeto_lista_mapas.readyState == 4 ) {   
                    document.getElementById('bloque_lista_capas').innerHTML = obxeto_lista_mapas.responseText;  
                }
            }    
            try {obxeto_lista_mapas.send(''); }
            catch(erro){alerta_erro(erro.description)}; 
        } 
               
    /*
        Función para mostrar o div que terá o listado dos mapas dun usuario
    */ 
        function carga_sus_mapas(pax, usuario_consulta){
            var WEB_chamada='cargaSusMapas.php?pax=' + pax + '&verUser=' + usuario_consulta;
            var obxeto_lista_capas = Crea_obx_HttpRequest();
                
            obxeto_lista_capas.open('GET', WEB_chamada, true); 
            obxeto_lista_capas.onreadystatechange = function(){ 
                if (obxeto_lista_capas.readyState == 4 ) {   
                    document.getElementById('bloque_lista_mapas').innerHTML = obxeto_lista_capas.responseText;  
                }
            }    
            try {obxeto_lista_capas.send(''); }
            catch(erro){alerta_erro(erro.description)};
        } 
        
	/*
		Funcion para añadir/borrar elementos de una lista
	*/
	
		function despliega_replega_listados(){
			if(document.getElementById('caja_canales_listas').style.display=='block'){
			
				//document.getElementById('bloque_azul_opciones').className="bloque_azul";
				document.getElementById('caja_canales_listas').style.display='none';
			}
			else{	
			//document.getElementById('bloque_azul_opciones').className="bloque_azul2";
				document.getElementById('caja_canales_listas').style.display='block';


			}
		
		
		}
	
		/*function anadir_borrar_lista(elemento){
			var elementos=elemento.id.split("_");
			var id_lista=elementos[1];
			var id_obxecto=elementos[2];
			var tipo=elementos[3];

			
			
			
			if(elemento.className=="elemento_lista_canal"){
				elemento.className="elemento_lista_canal_cargando";
				var WEB_chamada='anadir_borrar_da_lista.php?id_lista='+id_lista+'&id_obxecto='+id_obxecto+'&tipo='+tipo+'&accion=anadir';
				var obxecto = Crea_obx_HttpRequest();			
				obxecto.open('GET', WEB_chamada, true); 
				obxecto.onreadystatechange = function(){ 
					if (obxecto.readyState == 4 ) {   
						document.getElementById(obxecto.responseText).className="elemento_lista_canal_si";
						
					}
				}    
				try {obxecto.send(''); }
				catch(erro){alerta_erro(erro.description)};		
			}
			else{			
				elemento.className="elemento_lista_canal_cargando";
				var WEB_chamada='anadir_borrar_da_lista.php?id_lista='+id_lista+'&id_obxecto='+id_obxecto+'&tipo='+tipo+'&accion=borrar';
				var obxecto = Crea_obx_HttpRequest();
				obxecto.open('GET', WEB_chamada, true); 
				obxecto.onreadystatechange = function(){ 
					if (obxecto.readyState == 4 ) {   
						document.getElementById(obxecto.responseText).className="elemento_lista_canal";
					}
				}    
				try {obxecto.send(''); }
				catch(erro){alerta_erro(erro.description)};				
			
			}
		}*/
		function anadir_a_novo_canal(id_obxecto,tipo){
			//var id_canal=document.getElementById('nome_canal_hidden').value;
			var nome_canal=document.getElementById('nome_canal').value;
			nome_canal = nome_canal.replace(/^\s*|\s*$/g,"");
			if(nome_canal!="" && nome_canal.length>2){
				var WEB_chamada='anadir_borrar_do_canal.php?id_obxecto='+id_obxecto+'&tipo='+tipo+'&nome='+nome_canal+'&accion=crear';
				var obxecto = Crea_obx_HttpRequest();			
				obxecto.open('GET', WEB_chamada, true); 
				obxecto.onreadystatechange = function(){ 
					if (obxecto.readyState == 4 ) {   
						document.getElementById('texto_confirmacion_canal').innerHTML=obxecto.responseText;
						document.getElementById('texto_confirmacion_canal').style.display="block";
						document.getElementById('nome_canal').value="";
						//document.getElementById('nome_canal_hidden').value="";
					}
				}    
				try {obxecto.send(''); }
				catch(erro){alerta_erro(erro.description)};		
			}

		}		
		function anadir_borrar_canal(elemento){
			var elementos=elemento.id.split("_");
			var id_canal=elementos[1];
			var id_obxecto=elementos[2];
			var tipo=elementos[3];

			
			

			if(elemento.className=="elemento_canal_inactivo"){
				//elemento.className="elemento_lista_canal_cargando";
				var WEB_chamada='anadir_borrar_do_canal.php?id_canal='+id_canal+'&id_obxecto='+id_obxecto+'&tipo='+tipo+'&accion=anadir';
				var obxecto = Crea_obx_HttpRequest();			
				obxecto.open('GET', WEB_chamada, true); 
				obxecto.onreadystatechange = function(){ 
					if (obxecto.readyState == 4 ) {   
						//document.getElementById(obxecto.responseText).className="elemento_canal_activo";
						elemento.className="elemento_canal_activo";
					}
				}    
				try {obxecto.send(''); }
				catch(erro){alerta_erro(erro.description)};		
			}
			else{			
				//elemento.className="elemento_lista_canal_cargando";
				var WEB_chamada='anadir_borrar_do_canal.php?id_canal='+id_canal+'&id_obxecto='+id_obxecto+'&tipo='+tipo+'&accion=borrar';
				var obxecto = Crea_obx_HttpRequest();
				obxecto.open('GET', WEB_chamada, true); 
				obxecto.onreadystatechange = function(){ 
					if (obxecto.readyState == 4 ) {   
						//document.getElementById(obxecto.responseText).className="elemento_canal_inactivo";
						elemento.className="elemento_canal_inactivo";
					}
				}    
				try {obxecto.send(''); }
				catch(erro){alerta_erro(erro.description)};				
			
			}
		}
		
    /*
        Función para bloqueo de enlaces
    */ 
        function enlace_stop(){
        }
        
  
    /*
        Función para index.php para recoller as capas/mapas preferentes, e amosalos no lateral.
    */        
        var busca_por_intereses = null;
        var tipo_interes        = null;
        var paxina_interes      = null;
        var obxeto_top          = null;
                             
   
    /*
        Función para mostrar paxinados os resultados da busca por interes
    */
        
             
        
    /*
    *   Función para mostrar a imaxen de espera ou eliminala.
    */
        function espera_div_on_off (div_espera, esperar_si_no){
            if(esperar_si_no == 1){ // Caso de engadir a espera ao DIV.
                if(document.getElementById(div_espera) != null){ // Vemos se o div existe .
                    document.getElementById(div_espera).innerHTML= '';
                    var Nome_clases = document.getElementById(div_espera).className;
                    Nome_clases = Nome_clases + ' espera';
                    document.getElementById(div_espera).className =  Nome_clases;
                }
            }
            if(esperar_si_no == 0){ // Caso de engadir a espera ao DIV.
                if(document.getElementById(div_espera) != null){ // Vemos se o div existe .
                    var Nome_clases = document.getElementById(div_espera).className;
                    Nome_clases = Nome_clases + ' espera';
                    Nome_clases = troca_dato(Nome_clases, " espera", "");
                    Nome_clases = troca_dato(Nome_clases, "espera ", "");
                    Nome_clases = troca_dato(Nome_clases, "espera", "");
                    document.getElementById(div_espera).className =  Nome_clases;
                }
            }
        }
        
        
    /*
    *   Funcións para os mapas extendidos.
    */
        function control_abrir_cerrar_menu (abrir_pechar){
            if(abrir_pechar == 1){ // 1 -> abriomos 0 -> pechamos.
                if(document.getElementById('contenedor_titulo_maxi') != null){ 
                    document.getElementById('contenedor_titulo_maxi').style.display = '';
                }
                if(document.getElementById('contenedor_acciones_maxi') != null){ 
                    document.getElementById('contenedor_acciones_maxi').style.display = '';
                }
                if(document.getElementById('contenedor') != null){ 
                    document.getElementById('contenedor').style.display = '';
                }
				document.getElementById('enl_cerrar').style.display = '';
				document.getElementById('enl_abrir').style.display = 'none';
				document.getElementById('icono_abrir').display = 'none';
				document.getElementById('icono_cerrar').display = '';
            }
            else{
                if(document.getElementById('contenedor_titulo_maxi') != null){ 
                    document.getElementById('contenedor_titulo_maxi').style.display = 'none';
                }
                if(document.getElementById('contenedor_acciones_maxi') != null){ 
                    document.getElementById('contenedor_acciones_maxi').style.display = 'none';
                }
                if(document.getElementById('contenedor') != null){ 
                    document.getElementById('contenedor').style.display = 'none';
                }
				document.getElementById('enl_cerrar').style.display = 'none';
				document.getElementById('enl_abrir').style.display = '';
				document.getElementById('icono_abrir').display = '';
				document.getElementById('icono_cerrar').display = 'none';
            }
        }
        
            function inicio_pantalla_maxi (){
                var navegador = '';   
                var ancho_pantalla = 0;
                var alto_pantalla =  0;
                if (typeof( window.innerWidth ) == 'number'){
                        //navegadores basados en mozilla   
                        ancho_pantalla = window.innerWidth;
                        alto_pantalla =  window.innerHeight;
                        navegador = 'firefox';
                } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
                        //navegadores basados en IExplorer
                        ancho_pantalla = document.documentElement.clientWidth;
                        alto_pantalla =  document.documentElement.clientHeight;
                        navegador = 'explorer';
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 
                        ancho_pantalla = document.body.clientWidth;
                        alto_pantalla =  document.body.clientHeight;
                        navegador = 'outros';
                } 
                
                if(alto_pantalla<550)
            		alto_pantalla_aux=550;
            	else
            		alto_pantalla_aux=alto_pantalla;
                if (document.getElementById('contenedor_mapa_dim') != null){
                    document.getElementById('contenedor_mapa_dim').style.height = (alto_pantalla_aux - 21) + 'px';
                }    //map 
                //maxi_cuerpo 
                if (document.getElementById('maxi_cuerpo') != null){
                    document.getElementById('maxi_cuerpo').style.width = (ancho_pantalla - 625) + 'px';
                } 
                if (document.getElementById('map') != null){
                    document.getElementById('map').style.height = '100%';
                    document.getElementById('map').style.width = '100%';
                }
            }    
				
		

		function carga_sus_canales(pax, canal_consulta){ 
            var orden=document.getElementById('sel_orden_miniC').value;
			var vista=document.getElementById('sel_vista_miniC').value;
			var WEB_chamada='cargaElementosCanales.php?pax=' + pax + '&idcanal=' + canal_consulta + "&orden="+orden+"&vista="+vista;   
            var obxeto_lista_mapas = Crea_obx_HttpRequest(); 
                
            obxeto_lista_mapas.open('GET', WEB_chamada, true); 
            obxeto_lista_mapas.onreadystatechange = function(){ 
                if (obxeto_lista_mapas.readyState == 4 ) {   
                    document.getElementById('bloque_lista_listas').innerHTML = obxeto_lista_mapas.responseText;  
                }
            }    
            try {obxeto_lista_mapas.send(''); }
            catch(erro){alerta_erro(erro.description)}; 
        }

 /*
        Función para mostrar o div que terá o listado das capas dun usuario
    */ 
        function carga_sus_listas(pax, lista_consulta){ 
			var orden=document.getElementById('sel_orden_miniC').value;
			var vista=document.getElementById('sel_vista_miniC').value;
            var WEB_chamada='cargaElementosListas.php?pax=' + pax + '&idlista=' + lista_consulta + "&orden="+orden+"&vista="+vista;   
            var obxeto_lista_mapas = Crea_obx_HttpRequest(); 
                
            obxeto_lista_mapas.open('GET', WEB_chamada, true); 
            obxeto_lista_mapas.onreadystatechange = function(){ 
                if (obxeto_lista_mapas.readyState == 4 ) {   
                    document.getElementById('bloque_lista_listas').innerHTML = obxeto_lista_mapas.responseText;  
                }
            }    
            try {obxeto_lista_mapas.send(''); }
            catch(erro){alerta_erro(erro.description)}; 
        }
		

		
	/*function gardar_mapa_sesion(existe){
		if(existe=="si"){
			if(confirm(vector_de_traduccion['aviso_garda_mapa'])){
				var WEB_chamada="gardar_mapa_sesion.php";
				var obxeto_garda_mapa = Crea_obx_HttpRequest();
				obxeto_garda_mapa.open("POST", WEB_chamada, true);
				obxeto_garda_mapa.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
				obxeto_garda_mapa.setRequestHeader("Content-length", 50);
				obxeto_garda_mapa.setRequestHeader("Connection", "close");
				obxeto_garda_mapa.onreadystatechange = function(){
					if (obxeto_garda_mapa.readyState == 4 ) {
						var error = '';
						if(obxeto_garda_mapa.status==200){
							if (document.getElementById("id_mensaje_nota") != null){
								var datos_devoltos = obxeto_garda_mapa.responseText;
								document.getElementById('id_mensaje_guardado').className="mensaje_guardado";
								document.getElementById('id_capa_engadida').innerHTML="";
								document.getElementById('imaxendegardado').style.visibility="hidden";

							}
						}
						else if(obxeto_garda_mapa.status==404){
							if (document.getElementById("id_mensaje_nota") != null){
								error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + ' </strong>' + vector_de_traduccion['mns_erro_404_c'];
								alerta_erro(error);
							}
						}
						else{
							if (obxeto_garda_mapa.getElementById("id_mensaje_nota") != null){
								error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + ' </strong>' + vector_de_traduccion['mns_erro_x'] + ' "' + obxeto_garda_mapa.status + '"';
								alerta_erro(error);
							}
						}
					}
				}
				try {obxeto_garda_mapa.send("gardar=si");}
				catch(erro){
				error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + ' </strong>' + vector_de_traduccion['mns_erro_x'] + ' "' + erro.description + '"';
				alerta_erro(error);
				};
			}
		}
		else{
		
			if(confirm(vector_de_traduccion['pregunta_ir_a_mapa'])){
			//if(confirm(vector_de_traduccion['mns_erro_404_a'])){
				window.location.href='eikimapa';
			
			
			}
		
		
		}


	}	*/
	
	
	function enviaInvitacion(id_invitador){
		var correo=document.getElementById('correo_invitado').value;
		var todoOK=false;
		
		var correo2=correo.split('@');
		if(correo2.length==2){
			var correo3=correo2[1].split(".");
			if(correo3.length>1){
				todoOK=true;
			}
		}
		
		if(todoOK){
			document.getElementById('img_confirma_correo').src="web_ikiMap/css/img/loader_azul.gif";
			document.getElementById('img_confirma_correo').style.visibility="visible";
			var WEB_chamada="enviaInvitacionUsuario.php?invitador="+id_invitador+"&correo="+correo;
			var obxeto_envia_Invitacion = Crea_obx_HttpRequest();
			obxeto_envia_Invitacion.open("GET", WEB_chamada, true);
			obxeto_envia_Invitacion.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
			obxeto_envia_Invitacion.setRequestHeader("Content-length", 50);
			obxeto_envia_Invitacion.setRequestHeader("Connection", "close");
			obxeto_envia_Invitacion.onreadystatechange = function(){
				if (obxeto_envia_Invitacion.readyState == 4 ) {
					var error = '';
					if(obxeto_envia_Invitacion.status==200){
						if(obxeto_envia_Invitacion.responseText=="OK"){
							document.getElementById('img_confirma_correo').style.visibility="hidden";
							if(document.getElementById('span_nInvitaciones').innerHTML!="1"){
								document.getElementById('span_nInvitaciones').innerHTML=parseInt(document.getElementById('span_nInvitaciones').innerHTML) -1;
								alerta_info("Se ha enviado correctamente la invitación a " + correo );
								document.getElementById('correo_invitado').value="";
							}
							else{
								document.getElementById('div_invitaciones_contido').innerHTML="Ya has agotado todas tus invitaciones";
								alerta_info("Se ha enviado correctamente la invitación a " + correo );
								document.getElementById('correo_invitado').value="";
							}
						}
						else{
							document.getElementById('img_confirma_correo').src='imaxes/paneis/desmarca.png';
						}
					}
					else if(obxeto_envia_Invitacion.status==404){
						document.getElementById('img_confirma_correo').src='imaxes/paneis/desmarca.png';
					}
					else{
						document.getElementById('img_confirma_correo').src='imaxes/paneis/desmarca.png';
					}
				}
			}
			try {obxeto_envia_Invitacion.send("gardar=si");}
			catch(erro){
				document.getElementById('img_confirma_correo').src='imaxes/paneis/desmarca.png';
			};
		}
		else{
			alerta_aviso("La dirección de correo escrita no es válida. Debe tener un formato correcto. Ejemplo: \"info@ikimap.com\"");
		}
	}
	
	function marcarComoVista(id_usuario,id_notificacion){
		var WEB_chamada="marca_como_visto.php?id_usuario="+id_usuario+"&id_notificacion="+id_notificacion;
		var obxeto_marca_notificacion = Crea_obx_HttpRequest();
		obxeto_marca_notificacion.open("GET", WEB_chamada, true);
		obxeto_marca_notificacion.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8");
		obxeto_marca_notificacion.setRequestHeader("Content-length", 50);
		obxeto_marca_notificacion.setRequestHeader("Connection", "close");
		obxeto_marca_notificacion.onreadystatechange = function(){
			if (obxeto_marca_notificacion.readyState == 4 ) {
				if(obxeto_marca_notificacion.status==200){

				}
				
			}
		}
		try {obxeto_marca_notificacion.send("gardar=si");}
		catch(erro){
		error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + ' </strong>' + vector_de_traduccion['mns_erro_x'] + ' "' + erro.description + '"';
		alerta_erro(error);
		};
	
	
	}
	if(document.getElementById('enlace_maxi'))
		var enlace_a_p_completa=document.getElementById('enlace_maxi').href;
	if(document.getElementById('enlace_mini'))
		var enlace_a_p_normal=document.getElementById('enlace_mini').href;
	
	var getBBOX="";
	var getBASE="";
	
	function recogerBBOX(){
		var bounds=map.getExtent();
		bounds.transform (new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
		var BBOXtoMaxi=bounds.toBBOX();
		getBBOX=BBOXtoMaxi;
		
		if(document.getElementById('enlace_maxi')){
			document.getElementById('enlace_maxi').href=enlace_a_p_completa+BBOXtoMaxi+'&BASE='+getBASE;
			//enlace_a_p_completa=document.getElementById('enlace_maxi').href;
		}
		if(document.getElementById('enlace_mini')){
			document.getElementById('enlace_mini').href=enlace_a_p_normal+'&BBOX='+BBOXtoMaxi+'&BASE='+getBASE;
			//enlace_a_p_completa=document.getElementById('enlace_mini').href;
		}
	
	
	}
	
	
	function despliega_avisos(tipo){
		if(document.getElementById('div_aviso_voto'))
			document.getElementById('div_aviso_voto').style.display="none";
		if(document.getElementById('div_aviso_favorito'))
			document.getElementById('div_aviso_favorito').style.display="none";
		if(document.getElementById('div_aviso_engadir'))
			document.getElementById('div_aviso_engadir').style.display="none";
		if(document.getElementById('div_aviso_exportar'))
			document.getElementById('div_aviso_exportar').style.display="none";
		if(document.getElementById('div_aviso_engadirI'))
			document.getElementById('div_aviso_engadirI').style.display="none";
		switch(tipo){
			case "voto":	document.getElementById('div_aviso_voto').style.display="block";	break;
			case "favorito":document.getElementById('div_aviso_favorito').style.display="block";	break;
			case "engadir":	document.getElementById('div_aviso_engadir').style.display="block";	break;
			case "exportar":document.getElementById('div_aviso_exportar').style.display="block";	break;
			case "engadirI":document.getElementById('div_aviso_engadirI').style.display="block";	break;
		}
		if(document.getElementById('div_denuncia'))
			document.getElementById('div_denuncia').style.display="none";
		if(document.getElementById('div_listas_canales'))
			document.getElementById('div_listas_canales').style.display="none";
	
	}

	
	function despliega_denuncia(){
		document.getElementById('div_listas_canales').style.display="none";
		document.getElementById('div_sharethis').style.display="none";
		if(document.getElementById('div_denuncia').style.display=="block")
			document.getElementById('div_denuncia').style.display="none";
		else
			document.getElementById('div_denuncia').style.display="block";
	
	}
	function despliega_listascanales(){
		document.getElementById('div_denuncia').style.display="none";
		document.getElementById('div_sharethis').style.display="none";
		if(document.getElementById('div_listas_canales').style.display=="block")
			document.getElementById('div_listas_canales').style.display="none";
		else
			document.getElementById('div_listas_canales').style.display="block";
	
	}	
	
	function despliega_sharethis(){
		document.getElementById('div_denuncia').style.display="none";
		document.getElementById('div_listas_canales').style.display="none";
		if(document.getElementById('div_sharethis').style.display=="block")
			document.getElementById('div_sharethis').style.display="none";
		else
			document.getElementById('div_sharethis').style.display="block";
	
	}	
	function enviar_denuncia(id_usuario,id_obxecto,tipo_obxecto){
		if(document.getElementById('texto_denuncia').value!=""){
			document.getElementById('texto_denuncia').style.border="1px solid #336699";
			//document.getElementById('cargando_denuncia').style.display="inline";
			var texto_denuncia=document.getElementById('texto_denuncia').value;
			texto_denuncia = texto_denuncia.split("&").join("%26");
			
			var params = "id_usuario="+id_usuario+"&id_obxecto="+id_obxecto+"&tipo_obxecto="+tipo_obxecto+"&texto="+texto_denuncia;  
			var WEB_chamada="enviar_denuncia.php?" + params;

			call(WEB_chamada,null,recollerDenuncia,'POST')

		}
		else{
			document.getElementById('texto_denuncia').style.border="1px solid red";
			document.getElementById('texto_confirmacion_denuncia').style.display="none";
		}
	}
	
	function recollerDenuncia(html){
		if(html=="OK"){
			document.getElementById('texto_confirmacion_denuncia').style.display="inline";
			document.getElementById('texto_denuncia').value="";
			//document.getElementById('cargando_denuncia').style.display="none";
		}	
	
	}
	
	function cambia_idioma(idioma,iduser){
		var id_usuario=iduser;
		var pax_actual=document.location.href;
		var params = "id_usuario="+id_usuario+"&idioma="+idioma;  
		var WEB_chamada="cambiar_idioma.php?" + params;
		var obxeto_idioma = Crea_obx_HttpRequest();
		obxeto_idioma.open("POST", WEB_chamada, true);
		obxeto_idioma.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8"); 
		obxeto_idioma.setRequestHeader("Content-length", params.length); 
		obxeto_idioma.setRequestHeader("Connection", "close");  
		obxeto_idioma.onreadystatechange = function(){
			if (obxeto_idioma.readyState == 4 ) {
				if(obxeto_idioma.status==200){
					document.location.reload();
				}
				
			}
		}
		try {obxeto_idioma.send(params);}
		catch(erro){
		error = '<br/><strong>' + vector_de_traduccion['mns_erro_404_a'] + ' </strong>' + vector_de_traduccion['mns_erro_x'] + ' "' + erro.description + '"';
		alerta_erro(error);
		};
	
	}
	
	
	function cambiar_mini_vista(pulsado)
	{
		switch(pulsado){
			case 'div_visitados':
				document.getElementById("pestanha_puntuacion").style.backgroundColor="";
				document.getElementById("pestanha_puntuacion").style.color="";
				document.getElementById("pestanha_puntuacion").style.textDecoration="";
				
				document.getElementById("pestanha_visitas").style.backgroundColor="#336600";
				document.getElementById("pestanha_visitas").style.color="#ffffff";
				document.getElementById("pestanha_visitas").style.textDecoration="none";
				
				document.getElementById("div_puntuados").style['visibility'] = 'hidden';
				document.getElementById("div_visitados").style['visibility'] = 'visible';			
			
			break;
			case 'div_puntuados':
				document.getElementById("pestanha_visitas").style.backgroundColor="";
				document.getElementById("pestanha_visitas").style.color="";
				document.getElementById("pestanha_visitas").style.textDecoration="";
				
				document.getElementById("pestanha_puntuacion").style.backgroundColor="#336600";
				document.getElementById("pestanha_puntuacion").style.color="#ffffff";
				document.getElementById("pestanha_puntuacion").style.textDecoration="none";
				
				document.getElementById("div_visitados").style['visibility'] = 'hidden';
				document.getElementById("div_puntuados").style['visibility'] = 'visible';			
			break;
			case 'div_seguidores':
				document.getElementById("pestanha_seguidores").className="inactive";
				document.getElementById("pestanha_seguidos").className="active";
				if(document.getElementById("pestanha_buscador"))
					document.getElementById("pestanha_buscador").className="active";
				document.getElementById("div_seguidos").style['visibility'] = 'hidden';
				document.getElementById("div_seguidores").style['visibility'] = 'visible';	
				if(document.getElementById("div_buscador"))	
					document.getElementById("div_buscador").style['visibility'] = 'hidden';					
			
			break;
			case 'div_seguidos':
				document.getElementById("pestanha_seguidores").className="active";
				document.getElementById("pestanha_seguidos").className="inactive";
				if(document.getElementById("pestanha_buscador"))
					document.getElementById("pestanha_buscador").className="active";
				document.getElementById("div_seguidos").style['visibility'] = 'visible';
				document.getElementById("div_seguidores").style['visibility'] = 'hidden';
				if(document.getElementById("div_buscador"))				
					document.getElementById("div_buscador").style['visibility'] = 'hidden';	
			
			break;
			case 'div_buscador':
				document.getElementById("pestanha_seguidores").className="active";
				document.getElementById("pestanha_seguidos").className="active";
				document.getElementById("pestanha_buscador").className="inactive";
				document.getElementById("div_seguidos").style['visibility'] = 'hidden';
				document.getElementById("div_seguidores").style['visibility'] = 'hidden';			
				document.getElementById("div_buscador").style['visibility'] = 'visible';	
				document.getElementById("inp_busca_amigos").focus();
			break;
		}
		
	}
	
	
	function cambioVistaUsuarios(datos,vista,usuario,pagina){
		var params = '';
		
		
		
		var WEB_chamada='amigos_seguidos.php?pax=1&verUser='+usuario+'&vista='+vista+'&datos='+datos+'&pax='+pagina;
		var obxeto = Crea_obx_HttpRequest();  
		obxeto.open('GET', WEB_chamada, true);             
		obxeto.onreadystatechange = function()
		{ 
			if (obxeto.readyState == 4 ) 
			{                        
				
				 document.getElementById('div_'+datos).innerHTML = obxeto.responseText;      
			}
		}    
		try 
		{
			obxeto.send(params);
		}
		catch(erro)
		{
			alert(erro.description)
		};
	}	
	
	function des_hacer_seguidor(estado,id_usuario_a_seguir,id_usuario){
		var params = '';
		
		
		var WEB_chamada='des_hacer_seguidor.php?estado='+estado+'&id_usuario_a_seguir='+id_usuario_a_seguir+'&id_usuario='+id_usuario;
		document.getElementById('div_seguidor').innerHTML="";
		var obxeto = Crea_obx_HttpRequest();  
		obxeto.open('GET', WEB_chamada, true);             
		obxeto.onreadystatechange = function()
		{ 
			if (obxeto.readyState == 4 ) 
			{                        
				
				
				/*if(estado=="KO")
					document.getElementById('div_seguidor').className="noeres_seguidor";
				else*/
					//document.getElementById('div_seguidor').className="noeres_seguidor";
					
				document.getElementById('div_seguidor').innerHTML = obxeto.responseText;  
			}
		}    
		try 
		{
			obxeto.send(params);
		}
		catch(erro)
		{
			alert(erro.description)
		};
	}
	
	function borrarComentario(id_comentario){
		var params = '';
		
		if(confirm(vector_de_traduccion['confirma_borrado_comentario'])){
			var WEB_chamada='borrar_comentario.php?id_comentario='+id_comentario;
			var obxeto = Crea_obx_HttpRequest();  
			obxeto.open('GET', WEB_chamada, true);             
			obxeto.onreadystatechange = function()
			{ 
				if (obxeto.readyState == 4 ) 
				{                        
					var resposta=obxeto.responseText.split('@@@');
					
					if(resposta[0]=="OK"){
						document.getElementById('comentario_'+id_comentario).style.background="#FFCCCC";

						document.getElementById('comentario_'+id_comentario).className="texto_bocadillo_borrado";
						document.getElementById('comentario_texto_'+id_comentario).innerHTML=resposta[1];
						document.getElementById('comentario_avatar_'+id_comentario).className="usuario_avatar_borrado";
						document.getElementById('comentario_imaxen_'+id_comentario).display="none";
					}
				}
			}    
			try 
			{
				obxeto.send(params);
			}
			catch(erro)
			{
				alert(erro.description)
			};	
		}
	}
	
	function buscaenterAmigos(myfield,e){
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        else return true;

        if (keycode == 13)
        {   
            if(myfield != ''){ 
                buscarAmigos(myfield.value);
            } 
            return false;
        }
        else
        return true;
    }
	
	function buscarAmigos(cadena,vista,pagina){
		var params='';
		if(vista && vista!="")
			tipo_vista=vista;
		else
			tipo_vista='detalle';
		
		if(cadena && cadena!="")
			var texto=cadena;
		else
			var texto=document.getElementById('inp_busca_amigos').value;
		
		if(pagina && pagina!="")
			pagina=pagina;
		else
			pagina=1;
		var WEB_chamada='buscador_amigos.php?cadena='+texto+'&tipo_vista='+tipo_vista+'&pax='+pagina;
		var obxeto = Crea_obx_HttpRequest();  
		obxeto.open('GET', WEB_chamada, true);             
		obxeto.onreadystatechange = function()
		{ 
			if (obxeto.readyState == 4 ) 
			{                        
				

				document.getElementById('div_buscador').innerHTML=obxeto.responseText;
				document.getElementById('inp_busca_amigos').focus();
				/*document.getElementById('comentario_texto_'+id_comentario).innerHTML=resposta[1];
				document.getElementById('comentario_avatar_'+id_comentario).className="usuario_avatar_borrado";
				document.getElementById('comentario_imaxen_'+id_comentario).display="none";*/
			}
		}    
		try 
		{
			obxeto.send(params);
		}
		catch(erro)
		{
			alert(erro.description)
		};	

	
	
	
	}
	
	function eliminarAvatar(tipo){
		document.getElementById("avatar_oculto").value="";
		if(tipo=="user")
			document.getElementById("img_avatar").src="imaxes/usuarios/user.png";
		else
			document.getElementById("img_avatar").src="imaxes/usuarios/nodisponible.png";
	
	}
	
	function notificar_mail(td_id_notificacion){
		var aNotificacion=td_id_notificacion.id.split("td_");
		var id_notificacion="notif_"+aNotificacion[1];
		if(document.getElementById(id_notificacion).value==0){
			document.getElementById(id_notificacion).value=1;
			td_id_notificacion.className="elemento_canal_activo";
		}
		else{
			document.getElementById(id_notificacion).value=0;
			td_id_notificacion.className="elemento_canal_inactivo";
		}
	
	}