//variables globales
var opcionBusqueda= ''; //apartado en el que se esta trabajando (pyr1, pyr2, pyr3)
var subSeccion='';  //span en el que vamos a meter datos

//flag para saber si se puede acceder a la BD mediante AJAX. Para guardar/recuperar origen y destino de la ruta.
//Se activa en los tabs. Solo sera positivo si esta el tab de "Como ir a...", en el resto sera 0
var flagBD = 0;

function newStreet(streetName, numeroPolicia, x, y, codvia){
    firstStreet=new Object();
    firstStreet.streetName=streetName;
    firstStreet.numeroPolicia=numeroPolicia;
    firstStreet.x=x;
    firstStreet.y=y;
    firstStreet.codvia=codvia;
    return firstStreet;
}


function rectangleMap() {
    var data="?sec=map";
        
    var coords=document.getElementById("combobox").value;
    var last=coords.length;
    
    for(i=0;i<4;i++){
        if(i!=3) pos=coords.indexOf(',');
        if(i==0) minxString=coords.substring(0,pos);
        else if(i==1) minyString=coords.substring(0,pos);
        else if(i==2) maxxString=coords.substring(0,pos);
        else if(i==3) maxyString=coords.substring(0,last);
        coords=coords.substring(pos+1,last);
    }
    
    var minx = parseFloat(minxString);
    var miny = parseFloat(minyString);
    var maxx = parseFloat(maxxString);
    var maxy = parseFloat(maxyString);
    
    
    data+="&height="+document.getElementById("alto").value;
    data+="&width="+document.getElementById("ancho").value;
    data+="&rminx="+minx;
    data+="&rminy="+miny;
    data+="&rmaxx="+maxx;
    data+="&rmaxy="+maxy;
    
    data+="&layers=";
    filter_options="&filter=";
    leyenda_checks = getElementsByClass("checkleyendalineas");
    if (leyenda_checks!=null){
        for (i=0; i<leyenda_checks.length; i++){
            if (leyenda_checks[i].checked){
                filter_options=filter_options+leyenda_checks[i].name+"|";
            }
        }
    }
    data=data+filter_options;
    
    filter2_options="&filter2=";
    leyenda_checks = getElementsByClass("checkleyendaparadas");
    if (leyenda_checks!=null){
        for (i=0; i<leyenda_checks.length; i++){
            if (leyenda_checks[i].checked){
                filter2_options=filter2_options+leyenda_checks[i].name+"|";
            }
        }
    }
    data=data+filter2_options;
    
    filterPoi_options="&filterPoi=";
    leyenda_checks = getElementsByClass("checkleyendaPoi");
    if (leyenda_checks!=null){
        for (i=0; i<leyenda_checks.length; i++){
            if (leyenda_checks[i].checked){
                filterPoi_options=filterPoi_options+leyenda_checks[i].name+"|";
            }
        }
    }
    data=data+filterPoi_options;
    
    mostrar_ruta=document.getElementById("mostrar_ruta").checked;
    
    filterRutas_options="&filterRutas=";

    if (mostrar_ruta){
        var equisemeele=objetusRuta;
        gids=equisemeele.getElementsByTagName("gids");
        for (i=0; i<gids.length; i++){
            filterRutas_options=filterRutas_options+gids.item(i).firstChild.data+"|";
        }
    }
    
    data=data+filterRutas_options;
    
    
    carga_mapa(data, false);
}

/**
*Asigna los puntos de posicion, o extent (segun caso), a los campos hidden relativos a cada caso. Asi posteriormente se pueden hacer los centrados segun posicion o extent.
*/
function asignarPuntos(combo, combo2)
{
    if(opcionBusqueda=='pyr1_origen' || opcionBusqueda=='pyr1_destino' || opcionBusqueda=='pyr2_origen' || opcionBusqueda=='pyr3_origen') 
        var punto = document.getElementById(combo)[document.getElementById(combo).selectedIndex].value;
    
    
    if(combo2!= null){
        var lugar= document.getElementById(combo2)[document.getElementById(combo2).selectedIndex].title+' con '+document.getElementById(combo)[document.getElementById(combo).selectedIndex].title;
    }
    else
        var lugar= document.getElementById(combo)[document.getElementById(combo).selectedIndex].title;


    //Punto normal
    arrai= punto.split(',')
    
    //Explicacion: no usar opcionBusqueda(usar combo.indexOf), pq se queda activado con el ultimo panel que ha creado,
    //y el que hay que usar es el que llega en el parametro combo.
    if(combo.indexOf('pyr1_origen')+1){
        
        document.getElementById('origenX').value= arrai[0];
        document.getElementById('origenY').value= arrai[1];
        
        //cambiar imagenes de control de puntos seleccionados
        document.getElementById('origen_XV').src='../EMT/imagenes/origen_V.gif';
        document.getElementById('origen_XV').title= titleImagenOrigenSeleccionada[idioma];
        document.getElementById('origenText').value= lugar;
        document.getElementById('tabLugarOrigen').innerHTML= lugar.substr(0, 40);
    }
    else if(combo.indexOf('pyr1_destino')+1){

        document.getElementById('destinoX').value= arrai[0]
        document.getElementById('destinoY').value= arrai[1]
        
        //cambiar imagenes de control de puntos seleccionados
        document.getElementById('destino_XV').src='../EMT/imagenes/destino_V.gif';
        document.getElementById('destino_XV').title= titleImagenDestinoSeleccionada[idioma];
        document.getElementById('destinoText').value= lugar;
        document.getElementById('tabLugarDestino').innerHTML= lugar.substr(0, 40);
    }
    else if((combo.indexOf('pyr2_origen')+1) || (combo.indexOf('pyr3_origen')+1)){ 
        document.getElementById('puntitoX').value= arrai[0]
        document.getElementById('puntitoY').value= arrai[1]
    }
	
}


/**
* Convierte los datos del extent a un array de calles, para poder mostrarlas en los menus.
*/
function segmentsToStreets(xmldata){

	var num = parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);
    var streets = new Array();
    
    for(i=0; i<num; i++){
        var streetName = xmldata.getElementsByTagName('streetname').item(i).firstChild.data;
        var numeroPolicia = xmldata.getElementsByTagName('numeroPolicia').item(i).firstChild.data;

        var node = xmldata.getElementsByTagName('mappoint').item(i)
        var xx = parseFloat(node.attributes[0].nodeValue);
        var yy = parseFloat(node.attributes[1].nodeValue);

        var codvia= parseInt(xmldata.getElementsByTagName('codvia').item(i).firstChild.data);

        var firstStreet=newStreet(streetName, numeroPolicia, xx, yy, codvia);   

        streets[i]=firstStreet;
    }

    return streets;
}



/**
* Inserta en un array las calles que intersectan para poder mostrarlas en los menus
*/
function streetsToIntersect(xmldata)
{
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

    var streets=new Array();
    
    for(i=0; i<num; i++){
        var streetName=xmldata.getElementsByTagName('streetname').item(i).firstChild.data;

        var codvia=xmldata.getElementsByTagName('codvia').item(i).firstChild.data;
        
        var firstStreet=newStreet(streetName, null, 0, 0, codvia);
    
        streets[i]=firstStreet;
    }

    return streets;
}

function comprobarDatosCalles(opcion){
	
    switch(opcion){
        case "pyr3_origen":
            if($(opcion+'_validStreets')[$(opcion+'_validStreets').selectedIndex].value!='-') findStreetAndNumberTXT(null);
            else{
                $(opcion+'_combo3').innerHTML='<br />'+txtSeleccioneCalleDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
        case "pyr2_origen":
            if($(opcion+'_validStreets')[$(opcion+'_validStreets').selectedIndex].value!='-') centerMapS(1);
            else{
                $(opcion+'_combo3').innerHTML='<br />'+txtSeleccioneCalleDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
    }
}
function comprobarDatosEsquinas(opcion){
    
	switch(opcion){
        case "pyr3_origen":
            if($(opcion+'_validStreets2')[$(opcion+'_validStreets2').selectedIndex].value!='-') findCornerTXT(null);
            else{
                $(opcion+'_combo3').innerHTML='<br />'+txtSeleccioneCalleDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
        case "pyr2_origen":
            if($(opcion+'_validStreets2')[$(opcion+'_validStreets2').selectedIndex].value!='-') centerMapS(1);
            else{
                $(opcion+'_combo3').innerHTML='<br />'+txtSeleccioneCalleDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
    }
}
function comprobarDatosLugaresInteres(opcion){

	switch(opcion){
        case "pyr3_origen":
            if($(opcion+'_validPoints')[$(opcion+'_validPoints').selectedIndex].value!='-') findLugarInteresTXT(null);
            else{
                $(opcion+'_combo3').innerHTML='<br />'+txtSeleccioneLugarInteresDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
        case "pyr2_origen":
            if($(opcion+'_validPoints')[$(opcion+'_validPoints').selectedIndex].value!='-') centerMapS(1);
            else{
                $(opcion+'_combo3').innerHTML='<br />'+txtSeleccioneLugarInteresDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
    }
}
function comprobarDatosParadas(opcion){

    switch(opcion){
        case "pyr3_origen":
            if($(opcion+'_parada')[$(opcion+'_parada').selectedIndex].value!='-') findBusStopTXT(null);
            else{
                $(opcion+'_combo3').innerHTML=txtSeleccioneParadaDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
        case "pyr2_origen":
            if($(opcion+'_parada')[$(opcion+'_parada').selectedIndex].value!='-') centerMapS(1);
            else{
                $(opcion+'_combo3').innerHTML=txtSeleccioneParadaDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
    }
}

function comprobarDatosCalle(opcion){

    switch(opcion){
        case "pyr3_origen":
            if($(opcion+'_validStreets')[$(opcion+'_validStreets').selectedIndex].value!='-') findBusStopTXT(null);
            else{
                $(opcion+'_combo3').innerHTML=txtSeleccioneParadaDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
        case "pyr2_origen":
            if($(opcion+'_validStreets')[$(opcion+'_validStreets').selectedIndex].value!='-') centerMapS(1);
            else{
                $(opcion+'_combo3').innerHTML=txtSeleccioneParadaDesplegable[idioma]+'.'
                setTimeout("document.getElementById(\""+opcion+"_combo3\").innerHTML='';", 3000);
            }
        break;
    }
}


/**
*
*/
function marcarTipoOrigenDestinoSeleccionado(tipo){
	//alert('marcarTipoOrigenDestinoSeleccionado');
	switch(tipo){
		case 1: if(opcionBusqueda=="pyr1_origen")
					document.getElementById("tipoOrigen").value= 1;
				else if(opcionBusqueda=="pyr1_destino")
					document.getElementById("tipoDestino").value= 1;
				break;
		case 2: if(opcionBusqueda=="pyr1_origen")
					document.getElementById("tipoOrigen").value= 2;
				else if(opcionBusqueda=="pyr1_destino")
					document.getElementById("tipoDestino").value= 2;
				break;
		case 3: if(opcionBusqueda=="pyr1_origen")
					document.getElementById("tipoOrigen").value= 3;
				else if(opcionBusqueda=="pyr1_destino")
					document.getElementById("tipoDestino").value= 3;
				break;
		case 4: if(opcionBusqueda=="pyr1_origen")
					document.getElementById("tipoOrigen").value= 4;
				else if(opcionBusqueda=="pyr1_destino")
					document.getElementById("tipoDestino").value= 4;
				break;
		case 5: if(opcionBusqueda=="pyr1_origen")
					document.getElementById("tipoOrigen").value= 5;
				else if(opcionBusqueda=="pyr1_destino")
					document.getElementById("tipoDestino").value= 5;
				break;
	}
}


function showStreetList(xmldata)
{	
	//alert(showStreetList);
    var streets=segmentsToStreets(xmldata);

    if(streets.length>0){
        var htmlText='<select name="'+opcionBusqueda+'_validStreets" id="'+opcionBusqueda+'_validStreets" style="margin-top: 2px;" onchange="marcarTipoOrigenDestinoSeleccionado(1); asignarPuntos(\''+opcionBusqueda+'_validStreets\', null); setUserRoute();">';
        htmlText+='<option value="-">'+comboSeleccioneUnaCalle[idioma]+'</option>';
        //relleno el select con los puntos y nombres de las calles.
        for(i=0;i<streets.length;i++){
            var X=streets[i].x;
            var Y=streets[i].y;
            var texto= streets[i].streetName+', '+streets[i].numeroPolicia;
            htmlText+='<option value="'+X+','+Y+'" title="'+texto+'">';

			if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
            htmlText+=texto
            htmlText+='</option>';
        }
        htmlText+='</select>';

        var htmlText2='';
        if(opcionBusqueda== 'pyr3_origen')
            htmlText2+='&nbsp;<input type="text" size="3" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="rectangleMap" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" class="boton" onclick="$(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); comprobarDatosCalles(\''+opcionBusqueda+'\');" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
        if(opcionBusqueda== 'pyr2_origen')
            htmlText2+='&nbsp;<input name="centerMap" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" class="boton" onclick="comprobarDatosCalles(\''+opcionBusqueda+'\');" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" />';

        document.getElementById(opcionBusqueda+"_combo1").innerHTML=htmlText;
        document.getElementById(opcionBusqueda+"_combo2").innerHTML=htmlText2;
        
        if(opcionBusqueda!="pyr4")
			procedencia(opcionBusqueda+'_validStreets');		
        
    }
    else document.getElementById(opcionBusqueda+"_street").value= txtNoHayCoincidencias[idioma];
}


function showPointList(xmldata) {
	//alert('showPointList');
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

    if(num>0){
        var htmlText='<select name="'+opcionBusqueda+'_validPoints" id="'+opcionBusqueda+'_validPoints" onchange="marcarTipoOrigenDestinoSeleccionado(3); asignarPuntos(\''+opcionBusqueda+'_validPoints\', null); setUserRoute();" style="margin-top: 2px;">';
        htmlText+='<option value="-">'+comboSeleccioneLugarInteres[idioma]+'</option>';
        
        for(i=0;i<num;i++)
        {
            //mappoint x y
            var node= xmldata.getElementsByTagName('mappoint').item(i)
            var equis = parseFloat(node.attributes[0].nodeValue);
            var ygriega = parseFloat(node.attributes[1].nodeValue);
			
            var categoria= xmldata.getElementsByTagName('categoria').item(i).firstChild.data;
            var texto= xmldata.getElementsByTagName('name').item(i).firstChild.data;

            htmlText+='<option value="'+equis+','+ygriega+','+categoria+'" title="'+texto+'">';
            
            if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
            htmlText+=texto
            htmlText+='</option>';
        }
        htmlText+='</select>';
        
        if(opcionBusqueda== 'pyr3_origen')
			htmlText+='&nbsp;<input type="text" size="3" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="centerMap" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" onclick="$(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); comprobarDatosLugaresInteres(\''+opcionBusqueda+'\');" class="boton" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
        if(opcionBusqueda== 'pyr2_origen')
            htmlText+='&nbsp;<input name="centerMap" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" onclick="comprobarDatosLugaresInteres(\''+opcionBusqueda+'\');" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" />';
        
        ocultar_todo_pyr_pie_menu_origen(opcionBusqueda);
        $(opcionBusqueda+"_puntosInteres").style.display="inline"
        $(opcionBusqueda+"_spanLugarInteres2").innerHTML=htmlText;
     
		procedencia(opcionBusqueda+'_validPoints');
    }
    else{
		$(opcionBusqueda+"_lugarInteres").value= txtNoHayCoincidencias[idioma];
		$(opcionBusqueda+"_spanLugarInteres2").innerHTML="";
	}
}

/**
* Si se procede desde esquemas y hay que cargar algun tab, se ejecutara en orden cada una de las fucniones necesarias para cumplir el mandato de la parte de esquemas.
* Marca los puntos y ejecuta el centrado de plano y carga de puntos cercanos.
* 
*/
function procedencia(procedencia){

//alert('procedencia: '+procedencia);

var poiString= opcionBusqueda+'_validPoints';
var paradaString= opcionBusqueda+'_parada';
var calleString= opcionBusqueda+'_validStreets';

	if($('llamadaDesdeEsquemaLineas') && $('llamadaDesdeEsquemaLineas').value!='NADA'){
		if($('llamadaDesdeEsquemaLineas').value=="POI"){
			$('llamadaDesdeEsquemaLineas').value = "NADA";
			//comprobamos si se ha creado el combo de resultados (puede darse el caso de que no haya resultado (no hay coincidencias)
			//alert(opcionBusqueda+'_validPoints');
			if($(opcionBusqueda+'_validPoints')){
				//$(opcionBusqueda+'_validPoints')[1].selected= 'selected';
				for (i = 1; i < $(opcionBusqueda+'_validPoints').length; i++) {
					if ($(opcionBusqueda+'_validPoints')[i].title == $('nombre').value) {
         				$(opcionBusqueda+'_validPoints')[i].selected = "selected";
         				break;
      				}
   				}
				
				mostrarRadio();
				
				marcarTipoOrigenDestinoSeleccionado(3);
				asignarPuntos(opcionBusqueda+'_validPoints', null);
				
				$('selectTodosPoi').checked='true';
				selectTodosPoi();
				comprobarDatosLugaresInteres(opcionBusqueda);
			}
		}else if($('llamadaDesdeEsquemaLineas').value=="PARADA"){
			$('llamadaDesdeEsquemaLineas').value = "NADA";
			//comprobamos si se ha creado el combo de resultados (puede darse el caso de que no haya resultado (no hay coincidencias)
			if($(opcionBusqueda+'_parada')){
				$(opcionBusqueda+'_parada')[1].selected= 'selected';
				
				 mostrarRadio();
				
				marcarTipoOrigenDestinoSeleccionado(4);
				asignarPuntos(opcionBusqueda+'_parada', null);
				
				$('selectTodosPoi').checked='true';
				selectTodosPoi();
				comprobarDatosParadas(opcionBusqueda);
			}
		}
		else if($('llamadaDesdeEsquemaLineas').value=="CALLE"){
				$('llamadaDesdeEsquemaLineas').value = "NADA";
				//$(opcionBusqueda+'_validStreets')[1].selected= 'selected';		
				for (i = 1; i < $(opcionBusqueda+'_validStreets').length; i++) {
					if ($(opcionBusqueda+'_validStreets')[i].title == $('nombre').value) {
         				$(opcionBusqueda+'_validStreets')[i].selected = "selected";
         				break;
      				}
   				}
				
				
				mostrarRadio();
				
				marcarTipoOrigenDestinoSeleccionado(4);
				asignarPuntos(opcionBusqueda+'_validStreets', null);
				
				$('selectTodosPoi').checked='true';
				selectTodosPoi();
				comprobarDatosCalle(opcionBusqueda);
		}
		else if($('llamadaDesdeEsquemaLineas').value=="ESQUINA"){
			if($(opcionBusqueda+'_validStreets1')) {
				$('llamadaDesdeEsquemaLineas').value = "ESQUINA2";
				//$(opcionBusqueda+'_validStreets1')[1].selected= 'selected';
				for (i = 1; i < $(opcionBusqueda+'_validStreets1').length; i++) {
					if ($(opcionBusqueda+'_validStreets1')[i].title == $('nombre').value) {
         				$(opcionBusqueda+'_validStreets1')[i].selected = "selected";
         				break;
      				}
   				}
				findCorner2('pyr2_origen');
			}
		}
		else if($('llamadaDesdeEsquemaLineas').value=="ESQUINA2"){
			if($(opcionBusqueda+'_validStreets2')) {
				$('llamadaDesdeEsquemaLineas').value = "NADA";
				
				for (i = 1; i < $(opcionBusqueda+'_validStreets2').length; i++) {
					if ($(opcionBusqueda+'_validStreets2')[i].title == $('nombre2').value) {
         				$(opcionBusqueda+'_validStreets2')[i].selected = "selected";
         				break;
      				}
   				}

				mostrarRadio();
				
				marcarTipoOrigenDestinoSeleccionado(4);
				asignarPuntos(opcionBusqueda+'_validStreets2', null);
				
				$('selectTodosPoi').checked='true';
				selectTodosPoi();
				comprobarDatosEsquinas(opcionBusqueda);
			}
		}	
	}
	//Autoejecuta la busqueda y centrado desde div de info del plano
	else if(procedencia==poiString){

		$(opcionBusqueda+'_validPoints')[1].selected= 'selected';
		
		mostrarRadio();
		
		marcarTipoOrigenDestinoSeleccionado(3);
		asignarPuntos(opcionBusqueda+'_validPoints', null);
		
		//Para estos casos no deben activarse los checks de lugares de interes
		if(procedencia!="pyr1_origen_validPoints" && procedencia!="pyr1_destino_validPoints"){

			checkCategoriaPOI(opcionBusqueda+'_validPoints');
		}
		comprobarDatosLugaresInteres(opcionBusqueda);
	}
	//Autoejecuta la busqueda y centrado de paradas desde div de info del plano
	else if(procedencia==paradaString){
	
		$(opcionBusqueda+'_parada')[1].selected= 'selected';
		
		 mostrarRadio();
		
		marcarTipoOrigenDestinoSeleccionado(4);
		asignarPuntos(opcionBusqueda+'_parada', null);
		
		//Para estos casos no deben activarse los checks de lugares de interes
		if(procedencia!="pyr1_origen_parada" && procedencia!="pyr1_destino_parada" && procedencia!="pyr2_origen_parada"){
			$('selectTodosPoi').checked='true';
			selectTodosPoi();
		}
		comprobarDatosParadas(opcionBusqueda);
	}
	
}

function showLugarInteresPorClase(xmldata) 
{
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

    if(num>0){
        var htmlText='<select name="'+opcionBusqueda+'_validPoints" id="'+opcionBusqueda+'_validPoints" style="margin-top: 2px;" onchange="marcarTipoOrigenDestinoSeleccionado(3); asignarPuntos(\''+opcionBusqueda+'_validPoints\', null); setUserRoute();">';
        
        for(i=0;i<num;i++)
        {
            //mappoint x y
            var node= xmldata.getElementsByTagName('mappoint').item(i)
            var equis = parseFloat(node.attributes[0].nodeValue);
            var ygriega = parseFloat(node.attributes[1].nodeValue);
            
			var categoria= xmldata.getElementsByTagName('categoria').item(i).firstChild.data;
            var texto= xmldata.getElementsByTagName('name').item(i).firstChild.data;

            htmlText+='<option value="'+equis+','+ygriega+','+categoria+'" title="'+texto+'">';
            
			if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
            htmlText+=texto
            htmlText+='</option>';
        }
        htmlText+='</select>';

		if(opcionBusqueda== 'pyr1_origen' || opcionBusqueda== 'pyr1_destino')
			marcarTipoOrigenDestinoSeleccionado(3);
        if(opcionBusqueda== 'pyr3_origen')
            htmlText+='&nbsp;<input type="text" size="2" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="centerMap" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" onclick="document.getElementById(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); findLugarInteresTXT(null);" class="boton" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
        if(opcionBusqueda== 'pyr2_origen')
            htmlText+='&nbsp;<input name="centerMap" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" onclick="centerMapS(1)" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" />';
            
        document.getElementById(opcionBusqueda+'_spanLugarInteres2').innerHTML=htmlText;
        asignarPuntos(opcionBusqueda+'_validPoints', null);
        
		procedencia(opcionBusqueda+'_validPoints');
    }
    else
        document.getElementById(opcionBusqueda+"_lugarInteres").value= txtNoHayCoincidencias[idioma];
}

function showBusStopOrRoutesList(xmldata) {
	//HAY VARIAS RUTAS PARA ESTA LINEA, CON LO QUE SE DA LA OPCION DE ELEGIR ENTRE ELLAS.
	if(xmldata.getElementsByTagName("findRutas").item(0)!=null){
		
	    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

	    if(num>0){
            var htmlText='<br /><select name="'+opcionBusqueda+'_ruta" id="'+opcionBusqueda+'_ruta" style="margin-top: 2px;">';
            htmlText+='<option value="-">'+comboSeleccioneRuta[idioma]+'</option>';

	        for(i=0; i<num; i++)
	        {
				var idLinea= xmldata.getElementsByTagName('idLinea').item(i).firstChild.data;
				var idRuta= xmldata.getElementsByTagName('idRuta').item(i).firstChild.data;
	            var denominacion= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data;
	            
	            var texto= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data
	    
                htmlText+='<option value="'+idLinea+','+idRuta+'" title="'+idLinea+' - '+denominacion+'">';
	            
				if(texto.length>45){
					if(texto.length>48){
						var iniTexto= texto.substring(0,22);
						var finTexto= texto.substring((texto.length-23), texto.length);
						texto= iniTexto+" ... "+finTexto;
					}
				}
	            htmlText+= idLinea+' - '+texto
	            htmlText+='</option>';
	        }
	        htmlText+='</select>';
	        
			htmlText+='&nbsp;<input name="paradasFromRuta" type="button" value="'+butObtenerParadas[idioma]+'" style="margin-top: 2px;" onclick="findBusStopsForThisRoute(\''+opcionBusqueda+'\')" class="boton" title="'+titleObtenerParadas[idioma]+'" /><br />';
				
	        $(opcionBusqueda+'_spanBusquedaParadas2').innerHTML=htmlText;
			$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML="";
	    }
	    else
	        $(opcionBusqueda+"_BusquedaParada").value= txtNoHayCoincidencias[idioma]
	}
	else{

	    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

	    if(num>0){
	        if(opcionBusqueda=="pyr4"){
	            var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;">';
			}
	        else{ 
	            var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;" onchange="marcarTipoOrigenDestinoSeleccionado(4); asignarPuntos(\''+opcionBusqueda+'_parada\', null); setUserRoute();">';
	            htmlText+='<option value="-">'+comboSeleccioneParada[idioma]+'</option>';
	        }
	        for(i=0; i<num; i++)
	        {
				var idparada= xmldata.getElementsByTagName('id').item(i).firstChild.data;
	            var denominacion= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data;
	            //mappoint x y
	            var node= xmldata.getElementsByTagName('mappoint').item(i)
	            var equis = parseFloat(node.attributes[0].nodeValue);
	            var ygriega = parseFloat(node.attributes[1].nodeValue);
	            
	            var texto= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data
	    
	            if(opcionBusqueda=="pyr4"){
	                //consulta horarios
	                htmlText+='<option value="'+idparada+'" title="'+idparada+' - '+denominacion+'">';
	            }
	            else
	                htmlText+='<option value="'+equis+','+ygriega+'" title="'+idparada+' - '+denominacion+'">';
	            
				if(texto.length>45){
					if(texto.length>48){
						var iniTexto= texto.substring(0,22);
						var finTexto= texto.substring((texto.length-23), texto.length);
						texto= iniTexto+" ... "+finTexto;
					}
				}
	            htmlText+= idparada +' - '+texto
	            htmlText+='</option>';
	        }
	        htmlText+='</select>';
	        
	        if(opcionBusqueda== 'pyr3_origen')
	            htmlText+='&nbsp;<input type="text" size="3" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="centerMap" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" onclick="$(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); comprobarDatosParadas(\''+opcionBusqueda+'\');" class="boton" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
	        if(opcionBusqueda== 'pyr2_origen')
	            htmlText+='&nbsp;<input name="centerMap" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" onclick="comprobarDatosParadas(\''+opcionBusqueda+'\');" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" /><br />';
	        if(opcionBusqueda=="pyr4")
	            htmlText+='&nbsp;<input type="button" value="'+butConsultarHorarios[idioma]+'" style="margin-top: 2px;" onclick="getSAE(\'horariosParada\');" class="boton" title="'+butConsultarHorarios[idioma]+'" /><input type="checkbox" id="chkAdaptados">'+titleSoloAutobusesAdaptados[idioma]+'<br />';

	        $(opcionBusqueda+'_spanBusquedaParadas2').innerHTML="";
	        $(opcionBusqueda+'_spanBusquedaParadas3').innerHTML=htmlText;

			if(opcionBusqueda!="pyr4")
				procedencia(opcionBusqueda+'_parada');		
	    }
	    else{
	        $(opcionBusqueda+"_BusquedaParada").value= txtNoHayCoincidencias[idioma];
			$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML="";
		}
	}
    
}

function showBusStopList(xmldata) {

	var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

	if(num>0){
		if(opcionBusqueda=="pyr4"){
			var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;">';
		}
		else{ 
			var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;" onchange="marcarTipoOrigenDestinoSeleccionado(4); asignarPuntos(\''+opcionBusqueda+'_parada\', null); setUserRoute();">';
			htmlText+='<option value="-">'+comboSeleccioneParada[idioma]+'</option>';
		}
		for(i=0; i<num; i++)
		{
			var idparada= xmldata.getElementsByTagName('id').item(i).firstChild.data;
			var denominacion= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data;
			//mappoint x y
			var node= xmldata.getElementsByTagName('mappoint').item(i)
			var equis = parseFloat(node.attributes[0].nodeValue);
			var ygriega = parseFloat(node.attributes[1].nodeValue);
			
			var texto= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data
	
			if(opcionBusqueda=="pyr4"){
				//consulta horarios
				htmlText+='<option value="'+idparada+'" title="'+idparada+' - '+denominacion+'">';
			}
			else
				htmlText+='<option value="'+equis+','+ygriega+'" title="'+idparada+' - '+denominacion+'">';
			
			if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
			htmlText+= idparada +' - '+texto
			htmlText+='</option>';
		}
		htmlText+='</select>';
		
		if(opcionBusqueda== 'pyr3_origen')
			htmlText+='&nbsp;<input type="text" size="3" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="centerMap" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" onclick="$(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); comprobarDatosParadas(\''+opcionBusqueda+'\');" class="boton" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
		if(opcionBusqueda== 'pyr2_origen')
			htmlText+='&nbsp;<input name="centerMap" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" onclick="comprobarDatosParadas(\''+opcionBusqueda+'\');" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" /><br />';
		if(opcionBusqueda=="pyr4")
			htmlText+='&nbsp;<input type="button" value="'+butConsultarHorarios[idioma]+'" style="margin-top: 2px;" onclick="getSAE(\'horariosParada\');" class="boton" title="'+butConsultarHorarios[idioma]+'" /><input type="checkbox" id="chkAdaptados">'+titleSoloAutobusesAdaptados[idioma]+'<br />';

		
		$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML=htmlText;

		if(opcionBusqueda!="pyr4")
			procedencia(opcionBusqueda+'_parada');		
	}
	else{
		$(opcionBusqueda+"_BusquedaParada").value= txtNoHayCoincidencias[idioma];
		$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML="";
	}
}

function showGetLinesList(xmldata)
{
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);
    var htmlText='';
	//if(opcionBusqueda=="pyr4")
		//htmlText='<select name="'+opcionBusqueda+'_lineas" id="'+opcionBusqueda+'_lineas" style="margin-top: 2px;" onchange="document.getElementById(\''+opcionBusqueda+'_combo1\').innerHTML=\'\'; findBusStop(\''+opcionBusqueda+'\');">';
	//else
		htmlText='<select name="'+opcionBusqueda+'_lineas" id="'+opcionBusqueda+'_lineas" style="margin-top: 2px;" onchange="findBusStopOrRoutes(\''+opcionBusqueda+'\');">';
    
    htmlText+='<option value="-">'+comboSeleccioneLinea[idioma]+'</option>';
    for(i=0;i<num;i++){
        var ide= parseInt(xmldata.getElementsByTagName('id').item(i).firstChild.data);
        var numero= xmldata.getElementsByTagName('numero').item(i).firstChild.data;
        var denominacion= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data;
        
        htmlText+='<option value="'+ide+'" title="'+denominacion+'">';
		if(denominacion.length>50){
			if(texto.length>53){
				var iniTexto= denominacion.substring(0,30);
				var finTexto= denominacion.substring((denominacion.length-20), denominacion.length);
				denominacion= iniTexto+" ... "+finTexto;
			}
		}
		
        htmlText+= numero+' - '+denominacion
        htmlText+='</option>';
    }
    htmlText+='</select>';

	//Si aun sigue activa esa pesta�a, se muestra el mensaje, en caso contrario, se descarta. (por si han activado otra, que ya no aparezca el mensaje pq llega con retardo de la llamada ajax)
	if($(opcionBusqueda+'_flecha_tdBusquedaParada2').style.visibility== 'visible')
		document.getElementById(opcionBusqueda+'_spanBusquedaParadas').innerHTML=htmlText;
}

function showCorner1StreetList(xmldata)
{   
    var streets=streetsToIntersect(xmldata);

    if(streets.length>0)
    {
		var htmlText='<select name="'+opcionBusqueda+'_validStreets1" id="'+opcionBusqueda+'_validStreets1" onchange="findCorner2(\''+opcionBusqueda+'\')" style="margin-top: 2px;">';
		htmlText+='<option value="-">'+comboSeleccionePrimeraCalle[idioma]+'</option>';
		
		for(i=0;i<streets.length;i++){
			var htmlCodvia=streets[i].codvia;
			var texto= streets[i].streetName;
			htmlText+='<option value="'+htmlCodvia+'" title="'+texto+'">';
			if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
			htmlText+=texto
			htmlText+='</option>';
		}
		htmlText+='</select>&nbsp;';
		var htmlText2='<br /><span id="'+opcionBusqueda+'_spanEsquina"></span>';
	
		ocultar_todo_pyr_pie_menu_origen(opcionBusqueda);
		
		document.getElementById(opcionBusqueda+"_combo1").innerHTML=htmlText;
		document.getElementById(opcionBusqueda+"_combo2").innerHTML=htmlText2;
		
		if(opcionBusqueda!="pyr4") {
			procedencia(opcionBusqueda+'_validStreets1');
		}		
		
    }
    else document.getElementById(opcionBusqueda+"_street1").value= txtNoHayCoincidencias[idioma];
}

//aqui debo recibir la lista de calles que intersectan y mostrar el combo para que elijan.
function showCorner2StreetList(xmldata){

    var streets=segmentsToStreets(xmldata);
	
	var htmlText='<select name="'+opcionBusqueda+'_validStreets2" id="'+opcionBusqueda+'_validStreets2" style="margin-top: 2px;" onchange="marcarTipoOrigenDestinoSeleccionado(2); asignarPuntos(\''+opcionBusqueda+'_validStreets2\', \''+opcionBusqueda+'_validStreets1\'); setUserRoute();">';
	htmlText+='<option value="-">'+comboSeleccioneSegundaCalle[idioma]+'</option>';
	
	for(i=0;i<streets.length;i++){
		var X=streets[i].x;
		var Y=streets[i].y;
		var texto= streets[i].streetName;
		htmlText+='<option value="'+X+','+Y+'" title="'+texto+'">';
		if(texto.length>45){
			if(texto.length>48){
				var iniTexto= texto.substring(0,22);
				var finTexto= texto.substring((texto.length-23), texto.length);
				texto= iniTexto+" ... "+finTexto;
			}
		}
		htmlText+=texto
		htmlText+='</option>';
	}
	htmlText+='</select>&nbsp;';
	
	if(opcionBusqueda== 'pyr3_origen')
		htmlText+='&nbsp;<input type="text" size="3" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="centrarMapa" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" onclick="document.getElementById(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); comprobarDatosEsquinas(\''+opcionBusqueda+'\');" class="boton" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
	if(opcionBusqueda== 'pyr2_origen')
		htmlText+='&nbsp;<input name="centrarMapa" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" onclick="comprobarDatosEsquinas(\''+opcionBusqueda+'\');" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" />';

	document.getElementById(opcionBusqueda+"_combo2").innerHTML=htmlText;
	
	if(opcionBusqueda!="pyr4") {
		procedencia(opcionBusqueda+'_validStreets2');
	}		
}

function showStreetsWithBusStops(xmldata)
{   
	var streets=streetsToIntersect(xmldata);

    if(streets.length>0){
		var htmlText='<br /><select name="'+opcionBusqueda+'_streetsWithBusStops" id="'+opcionBusqueda+'_streetsWithBusStops" style="margin-top: 2px;">';
        htmlText+='<option value="-">'+comboSeleccioneUnaCalle[idioma]+'</option>';

        for(i=0; i<streets.length; i++){
			var htmlCodvia=streets[i].codvia;
			var texto= streets[i].streetName;
			htmlText+='<option value="'+htmlCodvia+'" title="'+texto+'">';
			if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
			htmlText+=texto
			htmlText+='</option>';
		}
		htmlText+='</select>&nbsp;';
        
        htmlText+='&nbsp;<input type="button" value="'+butMostrarParadasCalle[idioma]+'" style="margin-top: 2px;" onclick="findParadaPorCalle2(\''+opcionBusqueda+'\')" class="boton" title="'+titleMostrarParadasCalle[idioma]+'" />';

        $(opcionBusqueda+'_spanBusquedaParadas2').innerHTML=htmlText;
		$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML='';
		$(opcionBusqueda+'_combo1').innerHTML='';
    }
    else{
        $(opcionBusqueda+"_BusquedaParada").value= txtNoHayCoincidencias[idioma];
		$(opcionBusqueda+'_spanBusquedaParadas2').innerHTML='';
		$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML='';
		$(opcionBusqueda+'_combo1').innerHTML='';
	}
}

function showStopsOfAStreet(xml){

    var num=parseInt(xml.getElementsByTagName('num').item(0).firstChild.data);

    if(num>0){

		if(opcionBusqueda=="pyr4"){
            var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;">';
		}
        else{ 
            var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;" onchange="marcarTipoOrigenDestinoSeleccionado(4); asignarPuntos(\''+opcionBusqueda+'_parada\', null); setUserRoute();">';
            htmlText+='<option value="-">'+comboSeleccioneParada[idioma]+'</option>';
        }

		var i=0;
		while(xml.getElementsByTagName("paradaInfo").item(i)!=null){
			var nombre= xml.getElementsByTagName('denominacion').item(i).firstChild.data;
			var idparada= xml.getElementsByTagName('id').item(i).firstChild.data;
			nombre= idparada+' - '+nombre;
			
			var node= xml.getElementsByTagName('mappoint').item(i);
	        var xx = parseFloat(node.attributes[0].nodeValue);
	        var yy = parseFloat(node.attributes[1].nodeValue);
			
			if(opcionBusqueda=="pyr4"){
                //consulta horarios
                htmlText+='<option value="'+idparada+'" title="'+nombre+'">';
            }
            else
				htmlText+='<option value="'+xx+','+yy+'" title="'+nombre+'">';
			
			if(nombre.length>45){
				if(nombre.length>48){
					var iniTexto= nombre.substring(0,22);
					var finTexto= nombre.substring((nombre.length-23), nombre.length);
					nombre= iniTexto+" ... "+finTexto;
				}
			}
			htmlText+=nombre
			htmlText+='</option>';
			i++;
		}
		htmlText+='</select>&nbsp;';
		
		if(opcionBusqueda== 'pyr3_origen')
            htmlText+='&nbsp;<input type="text" size="3" value="'+txtRadio[idioma]+'" title="'+titleIntroduceRadio[idioma]+'" id="radius_TXT" onfocus=this.value="" />&nbsp;<input name="centerMap" type="button" value="'+butCentrarMostrar[idioma]+'" style="margin-top: 2px;" onclick="$(\'selectTodosPoi\').checked=\'true\'; mostrarRadio(); selectTodosPoi(); comprobarDatosParadas(\''+opcionBusqueda+'\');" class="boton" title="'+titleRealizaConsultaYCentraEnPlano[idioma]+'" /><br />';
        if(opcionBusqueda== 'pyr2_origen')
            htmlText+='&nbsp;<input name="centerMap" type="button" value="'+butCentrar[idioma]+'" style="margin-top: 2px;" onclick="comprobarDatosParadas(\''+opcionBusqueda+'\');" class="boton" title="'+titleCentraResultadoEnPlano[idioma]+'" /><br />';
        if(opcionBusqueda=="pyr4"){
			//htmlText+= '&nbsp;&nbsp;<input type="button" value="'+butBuscarPorLinea[idioma]+'" onclick="$(opcionBusqueda+\'_combo1\').innerHTML=\'\'; lineasPorParada(\''+opcionBusqueda+'\');" class="boton" / title="'+titleBuscarPorLinea[idioma]+'">';
			htmlText+= '&nbsp;&nbsp;<input type="button" value="'+butConsultarHorariosParada[idioma]+'" onclick="getSAE(\'horariosParada\');" class="boton" / title="'+titleConsultarHorariosParada[idioma]+'"><input type="checkbox" id="chkAdaptados">'+titleSoloAutobusesAdaptados[idioma];
		}
		
		if(opcionBusqueda=="pyr4")
			//en el menu de SAE se sustituye por el combo de calles, para que quepan todos los combos.
			$(opcionBusqueda+'_spanBusquedaParadas2').innerHTML=htmlText;
		else
			$(opcionBusqueda+'_spanBusquedaParadas3').innerHTML=htmlText;
		
	}else{
		$(opcionBusqueda+"_spanBusquedaParadas3").innerHTML= '<br />'+txtNoHayParadasEnEsaCalle[idioma];
		setTimeout("$(opcionBusqueda+\"_spanBusquedaParadas3\").innerHTML= '';", 5000);
	}
	
}

function poiIDtoNAME(id){
	switch(id){
	case "1": return bibliotecas[idioma];
			break;
	case "2": return centrosJuveniles[idioma];
			break;
	case "3": return centrosSociales[idioma];
			break;
	case "4": return teatros[idioma];
			break;
	case "5": return correos[idioma];
			break;
	case "6": return instalacionesDeportivas[idioma];
			break;
	case "7": return instalacionesEducativas[idioma];
			break;
	case "8": return instalacionesSanitarias[idioma];
			break;
	case "9": return mercados[idioma];
			break;
	case "10": return museos[idioma];
			break;
	case "11": return organizacionesMunicipales[idioma];
			break;
	case "12": return policia[idioma];
			break;
	case "15": return centrosDeVenta[idioma];
			break;
	case "16": return bocasDeMetro[idioma];
			break;
	//case "22": return poiOtros[idioma];
	//		break;
	case "51": return poiMonumentos[idioma];
			break;
	case "52": return poiCentrosComerciales[idioma];
			break;
	case "53": return poiEstaciones[idioma];
			break;
	case "54": return poiBomberos[idioma];
			break;
	case "55": return poiCementerios[idioma];
			break;
	case "99": return paradasDeAutobus[idioma];
			break;
	default: return otros[idioma];
			break;
	}

}


function showLugaresInteresTXT(xmldata){
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

    if(num>0){
		
		var flagCategoria='';
		var htmlParadas="";
		var htmlPOI="";
		var htmlPV="";
		
		var htmlText='<select name="comboLugarInteresTXT" id="comboLugarInteresTXT" style="margin-top: 3px;" onchange="marcarPOI(); mostrarInformacion();">';
		htmlText+='<option value="">'+txtLugaresCercanos[idioma]+'</option>';
		for(i=0;i<num;i++)
		{
			//mappoint x y
			var node= xmldata.getElementsByTagName('mappoint').item(i);
			var equis = parseFloat(node.attributes[0].nodeValue);
			var ygriega = parseFloat(node.attributes[1].nodeValue);
			
			var texto= xmldata.getElementsByTagName('name').item(i).firstChild.data;
			var categoria= xmldata.getElementsByTagName('categoria').item(i).firstChild.data;
			var arrai= texto.split(',,');
			var arrai2= arrai[1].split('.');

			if(flagCategoria!=categoria){
				if(categoria==99) htmlParadas+='<optgroup label="'+poiIDtoNAME(categoria)+'">';
				else if(categoria==15) htmlPV+='<optgroup label="'+poiIDtoNAME(categoria)+'">';
					else htmlPOI+='<optgroup label="'+poiIDtoNAME(categoria)+'">';
				//htmlText+='<optgroup label="'+poiIDtoNAME(categoria)+'">';
				flagCategoria= categoria;
			}
			
			if(categoria==99) htmlParadas+='<option value="'+equis+','+ygriega+',PARADA" title="'+arrai[0]+'">';
			else if(categoria==15) htmlPV+='<option value="'+equis+','+ygriega+',POI" title="'+arrai[0]+'">';
					else htmlPOI+='<option value="'+equis+','+ygriega+',POI" title="'+arrai[0]+'">';
			//htmlText+='<option value="'+equis+','+ygriega+'" title="'+arrai[0]+'">';
			
			if(arrai[0].length>60){
				if(arrai[0].length>63){
					var iniTexto= arrai[0].substring(0,32);
					var finTexto= arrai[0].substring((arrai[0].length-28), arrai[0].length);
					arrai[0]= iniTexto+" ... "+finTexto;
				}
			}
			
			
			if(categoria==99) htmlParadas+=arrai[0]+', '+arrai2[0]+' m.</option>';
			else if(categoria==15) htmlPV+=arrai[0]+', '+arrai2[0]+' m.</option>';
					else htmlPOI+=arrai[0]+', '+arrai2[0]+' m.</option>';
			//htmlText+=arrai[0]+', '+arrai2[0]+' m.</option>';
		}
		htmlText+= htmlParadas + htmlPOI + htmlPV;
		htmlText+='</select>';
        
        document.getElementById(opcionBusqueda+"_combo3").innerHTML=htmlText;
        
    }
    else document.getElementById(opcionBusqueda+"_combo3").innerHTML= txtNoPOICercano[idioma];
}

/*
* Dibuja el punto de posicion parpadeante.
*/
function marcarPOI(){

	if($('comboLugarInteresTXT')[$('comboLugarInteresTXT').selectedIndex].value!=''){
		var posicion= $('comboLugarInteresTXT')[$('comboLugarInteresTXT').selectedIndex].value;
		var arrai= posicion.split(',');
	
		ponerPunto(arrai[0], arrai[1]);
	}
}

/*
* Muestra automaticamente el div de informacion del POI o Parada seleccionado en el combo de lugares cercanos.
*/
function mostrarInformacion(){
	
	if($('comboLugarInteresTXT')[$('comboLugarInteresTXT').selectedIndex].value!=''){
		var punto= $('comboLugarInteresTXT')[$('comboLugarInteresTXT').selectedIndex].value;
		var arrai= punto.split(',');
	
		labelAbierto= 0; 
		
		guardaPosicionParaMoreInfo(arrai[0], arrai[1], arrai[2]);
		
		getMoreInformation();
		guardaPosicionParaMoreInfo('0','0','STREET');
	}

}

//** Funcion del SAE **
function showParadas(xmldata) {
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

    if(num>0){
        var htmlText='<br /><select name="'+opcionBusqueda+'_parada" id="'+opcionBusqueda+'_parada" style="margin-top: 2px;">';
        htmlText+='<option value="-" title="Seleccione parada">'+comboSeleccioneParada[idioma]+'</option>';
        
        for(i=0; i<num; i++)
        {
            var denominacion= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data;
            var idparada= xmldata.getElementsByTagName('id').item(i).firstChild.data;
            
            var texto= xmldata.getElementsByTagName('denominacion').item(i).firstChild.data
    
            htmlText+='<option value="'+idparada+'" title="'+idparada+' - '+denominacion+'">';
            
			if(texto.length>45){
				if(texto.length>48){
					var iniTexto= texto.substring(0,22);
					var finTexto= texto.substring((texto.length-23), texto.length);
					texto= iniTexto+" ... "+finTexto;
				}
			}
            htmlText+= idparada+' - '+texto
            htmlText+='</option>';
        }
        htmlText+='</select>';
        
        //htmlText+= '&nbsp;&nbsp;<input type="button" value="'+butBuscarPorLinea[idioma]+'" onclick="lineasPorParada(\''+opcionBusqueda+'\'); $(\''+opcionBusqueda+'_combo1\').innerHTML=\'\';" class="boton" / title="'+titleBuscarPorLinea[idioma]+'">';
        htmlText+= '&nbsp;&nbsp;<input type="button" value="'+butConsultarHorariosParada[idioma]+'" onclick="getSAE(\'horariosParada\');" class="boton" / title="'+titleConsultarHorariosParada[idioma]+'"><input type="checkbox" id="chkAdaptados">'+titleSoloAutobusesAdaptados[idioma];
        
		document.getElementById(opcionBusqueda+'_spanBusquedaParadas2').innerHTML=htmlText;
    }
    else{
        $(opcionBusqueda+"_BusquedaParada").value= txtNoHayCoincidencias[idioma];
		$(opcionBusqueda+'_spanBusquedaParadas2').innerHTML="";
	}
}

//** Funcion del SAE **
function showlineasPorParada(xmldata){
    var num=parseInt(xmldata.getElementsByTagName('num').item(0).firstChild.data);

    if(num>0){
        var htmlText='<br /><select name="'+opcionBusqueda+'_lineas" id="'+opcionBusqueda+'_lineas" style="margin-top: 2px;">';
        htmlText+='<option value="-">'+comboSeleccioneLinea[idioma]+'</option>';
        
        for(i=0; i<num; i++)
        {
            var descripcion= xmldata.getElementsByTagName('descripcion').item(i).firstChild.data;
            var linea= xmldata.getElementsByTagName('linea').item(i).firstChild.data;
            
            htmlText+='<option value="'+linea+'" title="'+linea+' - '+descripcion+'">'+linea+' - ';
            
			if(descripcion.length>45){
				if(texto.length>48){
					var iniTexto= descripcion.substring(0,22);
					var finTexto= descripcion.substring((descripcion.length-23), descripcion.length);
					descripcion= iniTexto+" ... "+finTexto;
				}
			}
            htmlText+=descripcion
            htmlText+='</option>';
        }
        htmlText+='</select>';
        
        htmlText+= '&nbsp;&nbsp;<input type="button" value="'+butConsultarHorarios[idioma]+'" onclick="getSAE();" class="boton" title="'+titleConsultarHorariosParadaYLinea[idioma]+'" /><input type="checkbox" id="chkAdaptados">'+titleSoloAutobusesAdaptados[idioma];
        
        document.getElementById(opcionBusqueda+'_spanBusquedaParadas3').innerHTML=htmlText;
    }
    else
        $(opcionBusqueda+'_spanBusquedaParadas3').innerHTML= "<br />"+txtNoHayResultadosLineaParada[idioma];
}


function getFunctionSelected(data) {
    var initpos=data.indexOf('=');
    var endpos=data.indexOf('&');
    //si solo hay un parametro, no habra &, con lo que "endpos" sera igual a la longitud de la cadena
    if(endpos==-1) endpos= data.length

    functionName=data.substring(initpos+1,endpos);
    return functionName;
}

function showList(selectedFunction, xmldata) {
	//alert('selectedFunction '+selectedFunction);
    if(selectedFunction=="findStreet"){
        showStreetList(xmldata);
    }else if(selectedFunction=="findPoint"){
        showPointList(xmldata);
    }else if(selectedFunction=="findCorner1"){
        showCorner1StreetList(xmldata);
    }else if(selectedFunction=="findCorner2"){
        showCorner2StreetList(xmldata);
    }else if(selectedFunction=="findBusStop"){
        showBusStopList(xmldata);
	}else if(selectedFunction=="findBusStopOrRoutes"){
        showBusStopOrRoutesList(xmldata);
	}else if(selectedFunction=="findBusStopsForThisRoute"){
        showBusStopList(xmldata);
    }else if(selectedFunction=="findGetLines"){
        showGetLinesList(xmldata);
	}else if(selectedFunction=="findGetLinesWithSAE"){
        showGetLinesList(xmldata);
    }else if(selectedFunction=="findParadaPorNombre"){
        showBusStopList(xmldata);
    }else if(selectedFunction=="findlineasPorParada"){
        showlineasPorParada(xmldata);
    }else if(selectedFunction=="findParadas"){
        showParadas(xmldata);
	}else if(selectedFunction=="findParadasWithSAE"){
        showParadas(xmldata);
    }else if(selectedFunction=="findLugarInteresPorClase"){
        showLugarInteresPorClase(xmldata);
    }else if(selectedFunction=="findLugarInteresTXT"){
        showLugaresInteresTXT(xmldata);
    }else if(selectedFunction=="findParadaPorCalle"){
        showStreetsWithBusStops(xmldata);
    }
	else if(selectedFunction=="findParadaPorCalle2"){
        showStopsOfAStreet(xmldata);
    }
}

//*************************************
//******metodos para matar una peticion*******************************
//*************************************
function killPetition(){
	Ajax.Responders.register({
		onCreate: function(request) {
					request.transport.abort();
					aborted = 1;
					//alert('killpetition');
		}
	});
}
function checkTimeOut(){
	Ajax.Responders.register({
		onCreate: function(request) {
			request['timeoutId'] = window.setTimeout(
				function() {
					// If we have hit the timeout and the AJAX request is active, abort it and let the user know
					//if (callInProgress(request.transport)) {
						request.transport.abort();
						//alert('timeoutttttt');
						$("cartel").style.visibility = "hidden";
						// Run the onFailure method if we set one up when creating the AJAX object
						//if (request.options['onFailure']) {
						//	request.options['onFailure'](request.transport, request.json);
						//}
					//}
				},
				5 //0.1 segundo
			);
		},
		onComplete: function(request) {
			// Clear the timeout, the request completed ok
			window.clearTimeout(request['timeoutId']);
		}
	});
}
function callInProgress (xmlhttp) {
	switch (xmlhttp.readyState) {
		case 1: case 2: case 3:	return true;
								break;
		// Case 4 and 0
		default: return false;
				break;
	}
}
//*************************************
//*************************************
//*************************************
function UpdateTimer2(){
	
	Ajax.Responders.register({
		onCreate: function(request) {
					request.transport.abort();
					aborted = 1;
					
					$("cartel").style.visibility = "hidden";
					//eyr_tab("Encuadres");
					//oculto el boton de cancelar el calculo
					$('cancelarCalculo').style.display = 'none';
					//mostramos el boton de calcular ruta
					$('btnCalcularRuta').style.display = 'inline';
					alert("updatetimer: "+flagCancelarRuta)
					if($("eyr_div_rutas2").innerHTML == txtNoHayRutaCalculada[idioma] || $("eyr_div_rutas2").innerHTML== txtTimeOut[idioma]){
						$("eyr_div_rutas2").innerHTML = txtTimeOut[idioma];
						$("imprimirRuta").innerHTML = '';
					}
		}
	});
	
}

function UpdateTimer(){
	
	document.getElementById("cartel").style.visibility="hidden";
	//eyr_tab("Encuadres");
	//oculto el boton de cancelar el calculo
	$('cancelarCalculo').style.display = 'none';
	//mostramos el boton de calcular ruta
	$('btnCalcularRuta').style.display = 'inline';
	
	if($("eyr_div_rutas2").innerHTML == txtNoHayRutaCalculada[idioma] || $("eyr_div_rutas2").innerHTML== txtTimeOut[idioma]){
		$("eyr_div_rutas2").innerHTML = txtTimeOut[idioma];
		$("imprimirRuta").innerHTML = '';
	}
}

function CancelRoutePetition(){
	
	flagCancelarRuta = 1
	
	document.getElementById("cartel").style.visibility="hidden";
	//eyr_tab("Encuadres");
	//oculto el boton de cancelar el calculo
	$('cancelarCalculo').style.display = 'none';
	//mostramos el boton de calcular ruta
	$('btnCalcularRuta').style.display = 'inline';
	
	$("eyr_div_rutas2").innerHTML = txtNoHayRutaCalculada[idioma];
	$("imprimirRuta").innerHTML = '';
}

function getXMLObject(xml_string){

	var xml;
	var ini= (xml_string).indexOf('<?xml');
	var cadena='';
	
	if(document.all){ //IEXPLORER
		xml = new ActiveXObject("Microsoft.XMLDOM");
		xml.async="false";
		if(ini==0)
			xml.loadXML(xml_string);
		else{
			cadena= (xml_string).substr(ini);
			xml.loadXML(cadena);
		}
	}else{ //FIREFOX
		if(ini==0)
			xml = (new DOMParser()).parseFromString(xml_string, "text/xml");
		else{
			cadena= (xml_string).substr(ini);
			xml = (new DOMParser()).parseFromString(cadena, "text/xml");
		}
	}

	return xml;
}

//*****************************************************************
var aborted = 0;
//*****************************************************************
function callMapUtilsFunction(getBusquedaCalle, data2) {

    $(opcionBusqueda+"_combo3").innerHTML='<img style="margin-top: 3px; margin-bottom:2px;" border="0" src="../EMT/imagenes/cargando_.gif" alt="Cargando" title="Cargando" />';
	
	//var timerID = setTimeout("UpdateTimer()", _TIMEOUT_PETICIONES_);

	var aleatorio=Math.random();
	new Ajax.Request(_URL_mapUtilsPetitions+getBusquedaCalle+"&nocache="+aleatorio,
	{
		method:'get',
		onSuccess: function(transport){
			if(aborted == 1){ aborted = 0; return;}

			var response = transport.responseText || "no response text";
			//alert("Success! \n\n" + response);
			
			var equisemeele = getXMLObject(response);
			
			//Cortamos el timer
			//clearTimeout(timerID);
		
			//quito el cartel de cargando...
			$(opcionBusqueda+"_combo3").innerHTML='';
			
			selectedFunction=getFunctionSelected(getBusquedaCalle);
			showList(selectedFunction, equisemeele);
			
			objetusOcupado = 0;
			
			if (data2!="" && data2!="CMS"){
				carga_mapa(data2, false);
			}

			if (data2=="CMS"){
				centerMapS(0);
			}
			
			//autoSalvado de los puntos de origen y destino para los usuarios
			if(opcionBusqueda=="pyr1_origen" || opcionBusqueda=="pyr1_destino"){ 
				setUserRoute();
			}
			
		},
		onFailure: function(){ 
			alert(txtErrorProcesandoPeticion[idioma]);
			objetusOcupado = 0;
		}
	});

	return 1;
    
}
//****************************************************************


function $(id) {
    
    return document.getElementById(id);
}



function asignarInputGlobal(input){

    switch(input){
        case 'pyr1_origen': opcionBusqueda= 'pyr1_origen'
                            break;
        case 'pyr1_destino': opcionBusqueda= 'pyr1_destino'
                            break;
        case 'pyr2_origen': opcionBusqueda= 'pyr2_origen'
                            break;
        case 'pyr3_origen': opcionBusqueda= 'pyr3_origen'
                            break;
        case 'pyr4': opcionBusqueda= 'pyr4'
                    break;
        default: break;
    }
}



function findStreet(inputDireccion) {

    if (objetusOcupado==0){
		//objetusOcupado = 1;
		asignarInputGlobal(inputDireccion);
		subSeccion="_spanDireccion";
		
		//----- ESTADISTICAS ---------------------------------------------------------------
		if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'DIR';
		else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'DIR';
		else oEstadisticas.opcion = 'DIR';
		//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
		var peticionEstadisticas = "";
		if(oEstadisticas.herramienta!='CI'){
			peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
			oEstadisticas.reset();
		}
		//--------------------------------------------------------------------
		
        //vacio los combos
        document.getElementById(opcionBusqueda+"_combo1").innerHTML='';
        document.getElementById(opcionBusqueda+"_combo2").innerHTML='';

        //compruebo que haya datos en los input
        if($(inputDireccion+'_street').value && $(inputDireccion+'_street').value!= txtCalleOrigen[idioma] && $(inputDireccion+'_street').value.length>=3)
        {
            var street=document.getElementById(inputDireccion+'_street').value;
            if((!document.getElementById(inputDireccion+'_number').value) || (isNaN(document.getElementById(inputDireccion+'_number').value))) var number=1;
            else var number=document.getElementById(inputDireccion+'_number').value;
            
            var data="?sec=findStreet";
            data+="&street="+street.toUpperCase();
            if(!isNaN(number) && number!='') data+="&number="+number;
    
            callMapUtilsFunction(data + peticionEstadisticas, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInserteNombreYNumeroAntesDeBusqueda[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            if(!document.getElementById(inputDireccion+'_street').value || document.getElementById(inputDireccion+'_street').value== txtCalleOrigen[idioma]) document.getElementById(inputDireccion+'_street').focus()
            else if(isNaN(document.getElementById(inputDireccion+'_number').value) || !document.getElementById(inputDireccion+'_number').value) document.getElementById(inputDireccion+'_number').focus()
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}


function findCorner1(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(inputDireccion);
        subSeccion="_spanEsquina";
        
        if($(inputDireccion+'_street1').value && $(inputDireccion+'_street1').value!= txtPrimeraCalle[idioma] && $(inputDireccion+'_street1').value.length>=3)
        {
            var street=document.getElementById(inputDireccion+'_street1').value;
            
            var data="?sec=findCorner1";
            data=data+"&street="+street.toUpperCase();
        
            callMapUtilsFunction(data, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInserteNombreAntesDeBusqueda[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            document.getElementById(inputDireccion+'_street1').focus();
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findCorner2(inputDireccion)
{
    if (objetusOcupado==0){
		//objetusOcupado = 1;
		//----- ESTADISTICAS ---------------------------------------------------------------
		if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'ESQ';
		else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'ESQ';
		else oEstadisticas.opcion = 'ESQ';
		//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
		var peticionEstadisticas = "";
		if(oEstadisticas.herramienta!='CI'){
			peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
			oEstadisticas.reset();
		}
		//--------------------------------------------------------------------
        subSeccion="_spanEsquina";
        
        var codvia= document.getElementById(opcionBusqueda+'_validStreets1')[document.getElementById(opcionBusqueda+'_validStreets1').selectedIndex].value;
        var nombre= document.getElementById(opcionBusqueda+'_validStreets1')[document.getElementById(opcionBusqueda+'_validStreets1').selectedIndex].text;
        
        
        var data="?sec=findCorner2";
        data=data+"&codvia="+codvia.toUpperCase();
        
        //en caso de ser una calle de extraradio se pasa un parametro extra con el nombre dle pueblo
        var ini= nombre.indexOf('[', 0)
        if(ini!=-1){
            var fin= nombre.indexOf(']', 0);
            var nombre= nombre.substring(ini+1,fin); 
    
            data=data+"&extraradio="+nombre.toUpperCase();
        }
        else data=data+"&extraradio=NO";
    
        callMapUtilsFunction(data + peticionEstadisticas, "");
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findPoint(inputDireccion) {
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(inputDireccion);
        subSeccion="_spanLugarInteres2";

		//----- ESTADISTICAS ---------------------------------------------------------------
		if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'LIN';
		else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'LIN';
		else oEstadisticas.opcion = 'LIN';
		//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
		var peticionEstadisticas = "";
		if(oEstadisticas.herramienta!='CI'){
			peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
			oEstadisticas.reset();
		}
		//--------------------------------------------------------------------

        if($(inputDireccion+'_lugarInteres').value && $(inputDireccion+'_lugarInteres').value.length>=3)
        {
            var point=document.getElementById(inputDireccion+'_lugarInteres').value;
            point = TrimString(point);
            var data="?sec=findPoint";
            data+="&point="+point.toUpperCase();
			
            callMapUtilsFunction(data + peticionEstadisticas, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInsertePOIAntesDeBusqueda[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            document.getElementById(inputDireccion+'_lugarInteres').focus();
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findParadaPorNombre(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(inputDireccion);
        subSeccion="_spanBusquedaParadas2";
		
        if($(inputDireccion+'_BusquedaParada').value && $(inputDireccion+'_BusquedaParada').value!= txtBuscarParada[idioma])
        {
			//----- ESTADISTICAS ---------------------------------------------------------------
			if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'PN';
			else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'PN';
			else oEstadisticas.opcion = 'PN';
			//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
			var peticionEstadisticas = "";
			if(oEstadisticas.herramienta!='CI'){
				peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
				oEstadisticas.reset();
			}
			//--------------------------------------------------------------------
		
            var nombre= document.getElementById(opcionBusqueda+'_BusquedaParada').value;
            var data="?sec=findParadaPorNombre";
            data+="&nombreParada="+nombre.toUpperCase();
        
            callMapUtilsFunction(data + peticionEstadisticas, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInserteParadaAntesDeBusqueda_SinLimCaracteres[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            document.getElementById(opcionBusqueda+'_BusquedaParada').focus();
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findParadaPorCalle(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(inputDireccion);
        subSeccion="_spanBusquedaParadas2";
        
        if($(inputDireccion+'_BusquedaParada').value && $(inputDireccion+'_BusquedaParada').value!= txtBuscarCalle[idioma] && $(inputDireccion+'_BusquedaParada').value.length>=3){
            var nombre= document.getElementById(opcionBusqueda+'_BusquedaParada').value;
            var data="?sec=findParadaPorCalle";
            data+="&street="+nombre.toUpperCase();
        
            callMapUtilsFunction(data, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInserteParadaAntesDeBusqueda[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            document.getElementById(opcionBusqueda+'_BusquedaParada').focus();
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findParadaPorCalle2(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
	    asignarInputGlobal(inputDireccion);
        subSeccion="_spanBusquedaParadas2";
		
		//----- ESTADISTICAS ---------------------------------------------------------------
		if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'PC';
		else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'PC';
		else oEstadisticas.opcion = 'PC';
		//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
		var peticionEstadisticas = "";
		if(oEstadisticas.herramienta!='CI'){
			peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
			oEstadisticas.reset();
		}
		//--------------------------------------------------------------------
        
        if($(inputDireccion+'_streetsWithBusStops')[$(inputDireccion+'_streetsWithBusStops').selectedIndex].value!='-'){
            var codvia= $(inputDireccion+'_streetsWithBusStops')[$(inputDireccion+'_streetsWithBusStops').selectedIndex].value;
            var data="?sec=findParadaPorCalle2";
            data+="&codvia="+codvia;
        
            callMapUtilsFunction(data + peticionEstadisticas, "");
        }
        else{
            $(opcionBusqueda+'_combo1').innerHTML='<br />'+txtSeleccioneCalleDesplegable[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
        }
    }else{
        $(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("$(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findParadas(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(inputDireccion);
        subSeccion="_spanBusquedaParadas2";
        
		if(inputDireccion="pyr4"){
			//vacio el SAE de una posible consulta anterior.
			document.getElementById(opcionBusqueda+'_spanBusquedaParadas3').innerHTML='';
			document.getElementById(opcionBusqueda+'_combo1').innerHTML='';
        }
		
        if($(inputDireccion+'_BusquedaParada').value && $(inputDireccion+'_BusquedaParada').value!= txtBuscarParada[idioma] && $(inputDireccion+'_BusquedaParada').value.length>=3)
        {
            var nombre= document.getElementById(opcionBusqueda+'_BusquedaParada').value;
            var data="?sec=findParadas";
            data+="&nombreParada="+nombre.toUpperCase();
        
            callMapUtilsFunction(data, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInserteParadaAntesDeBusqueda[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            document.getElementById(opcionBusqueda+'_BusquedaParada').focus();
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findParadasWithSAE(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(inputDireccion);
        subSeccion="_spanBusquedaParadas2";
        
		if(inputDireccion="pyr4"){
			//vacio el SAE de una posible consulta anterior.
			document.getElementById(opcionBusqueda+'_spanBusquedaParadas3').innerHTML='';
			document.getElementById(opcionBusqueda+'_combo1').innerHTML='';
        }
		
        if($(inputDireccion+'_BusquedaParada').value && $(inputDireccion+'_BusquedaParada').value.length>=3)
        {
            var nombre= TrimString(document.getElementById(opcionBusqueda+'_BusquedaParada').value);
            var data="?sec=findParadasWithSAE";
            data+="&nombreParada="+nombre.toUpperCase();
        
            callMapUtilsFunction(data, "");
        }
        else{
            document.getElementById(opcionBusqueda+'_combo1').innerHTML='<br />'+txtInserteParadaAntesDeBusqueda[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo1\").innerHTML='';", 3000);
            document.getElementById(opcionBusqueda+'_BusquedaParada').focus();
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findBusStop(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        //la primera opcion del select no vale (-)
        if(document.getElementById(inputDireccion+'_lineas')[document.getElementById(inputDireccion+'_lineas').selectedIndex].value!='-'){
            asignarInputGlobal(inputDireccion);
    
            subSeccion="_spanBusquedaParadas2";
                    
            var data="?sec=findBusStop";
                
            if(document.getElementById(opcionBusqueda+'_lineas')){
                var linea= document.getElementById(opcionBusqueda+'_lineas')[document.getElementById(opcionBusqueda+'_lineas').selectedIndex].value;
                data+="&linea="+linea;
            }
            else data+="&linea=1";
        
            callMapUtilsFunction(data, "");
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findBusStopOrRoutes(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
		
		if(inputDireccion=="pyr4") $(inputDireccion+'_combo1').innerHTML='';
		
        //la primera opcion del select no vale (-)
        if(document.getElementById(inputDireccion+'_lineas')[document.getElementById(inputDireccion+'_lineas').selectedIndex].value!='-'){
            asignarInputGlobal(inputDireccion);
            subSeccion="_spanBusquedaParadas2";
			
		//----- ESTADISTICAS ---------------------------------------------------------------
		if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'PL';
		else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'PL';
		else oEstadisticas.opcion = 'PL';
		//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
		var peticionEstadisticas = "";
		if(oEstadisticas.herramienta!='CI'){
			peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
			oEstadisticas.reset();
		}
		//--------------------------------------------------------------------

            var data="?sec=findBusStopOrRoutes";
                
            if(document.getElementById(opcionBusqueda+'_lineas')){
                var linea= document.getElementById(opcionBusqueda+'_lineas')[document.getElementById(opcionBusqueda+'_lineas').selectedIndex].value;
                data+="&linea="+linea;
            }
            else data+="&linea=1";
			
			data+="&fecha="+$('fechaOA').value;
        
            callMapUtilsFunction(data + peticionEstadisticas, "");
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findBusStopsForThisRoute(inputDireccion){
	
    if (objetusOcupado==0){
		//objetusOcupado = 1;
		
		$(opcionBusqueda+'_combo1').innerHTML="";
		
        //la primera opcion del select no vale (-)
        if(document.getElementById(inputDireccion+'_ruta')[document.getElementById(inputDireccion+'_ruta').selectedIndex].value!='-'){
            asignarInputGlobal(inputDireccion);
    
            subSeccion="_spanBusquedaParadas2";
                    
            var data="?sec=findBusStopsForThisRoute";
                
            if(document.getElementById(opcionBusqueda+'_ruta')){
                var datos= document.getElementById(opcionBusqueda+'_ruta')[document.getElementById(opcionBusqueda+'_ruta').selectedIndex].value;
				var arrai= datos.split(',');
                data+="&idlinea="+arrai[0]+"&idruta="+arrai[1];
            }
        
            callMapUtilsFunction(data, "");
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findGetLines(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        //compruebo si ya existe el combo. En ese caso no lo vuelvo a crear.
        if(!document.getElementById(inputDireccion+'_lineas'))
        {
            asignarInputGlobal(inputDireccion);
            
            subSeccion="_spanBusquedaParadas";
            
            var data="?sec=findGetLines";
			data+="&fecha="+$('fechaOA').value;
    
            callMapUtilsFunction(data, "");
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

function findGetLinesWithSAE(inputDireccion){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        //compruebo si ya existe el combo. En ese caso no lo vuelvo a crear.
        if(!document.getElementById(inputDireccion+'_lineas'))
        {
            asignarInputGlobal(inputDireccion);
            
            subSeccion="_spanBusquedaParadas";
            
            var data="?sec=findGetLinesWithSAE";
			data+="&fecha="+$('fechaOA').value;
    
            callMapUtilsFunction(data, "");
        }
    }else{
        document.getElementById(inputDireccion+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+inputDireccion+"_combo3\").innerHTML='';", 3000);   
    }
}

//encuentra los puntos de interes cercanos a un sitio (resultado en modo texto)
function findLugarInteresTXT(input){
	
	if (objetusOcupado==0){
		//objetusOcupado = 1;
		if(input=='pyr3_origen_pincharEnElPlano'){
			asignarInputGlobal('pyr3_origen');
			
			var x= document.getElementById('puntitoX').value;
			var y= document.getElementById('puntitoY').value;
			var radio= document.getElementById('radius_TXT').value;
			
			if(radio>_RADIO_MAXIMO_){ 
				radio= _RADIO_MAXIMO_;
				$('radius_TXT').value= _RADIO_MAXIMO_;
			}
			if(radio<_RADIO_MINIMO_){
				radio= _RADIO_MINIMO_;
				$('radius_TXT').value= _RADIO_MINIMO_;
			}
			if(isNaN(radio) || radio==''){
				radio= _RADIO_;
				$('radius_TXT').value= _RADIO_;
			}

			var data="?sec=findLugarInteresTXT&x="+x+"&y="+y+"&radio="+radio;
		
			callMapUtilsFunction(data, "CMS");
		}
		else{
			if(input!=null) asignarInputGlobal(input);
			
			var x= document.getElementById('puntitoX').value;
			var y= document.getElementById('puntitoY').value;
			var radio= document.getElementById('radius_TXT').value;

			if(radio>_RADIO_MAXIMO_){ 
				radio= _RADIO_MAXIMO_;
				$('radius_TXT').value= _RADIO_MAXIMO_;
			}
			if(radio<_RADIO_MINIMO_){
				radio= _RADIO_MINIMO_;
				$('radius_TXT').value= _RADIO_MINIMO_;
			}
			if(isNaN(radio) || radio==''){
				radio= _RADIO_;
				$('radius_TXT').value= _RADIO_;
			}
			var data="?sec=findLugarInteresTXT&x="+x+"&y="+y+"&radio="+radio;
		
			callMapUtilsFunction(data, "CMS");
		}
	}else{
		if (input == null) input = 'pyr3_origen';
		document.getElementById(input+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
		setTimeout("document.getElementById(\""+input+"_combo3\").innerHTML='';", 3000);	
	}
	
}


//encuentra los puntos de interes cercanos a una calle (resultado en modo texto)
function findStreetAndNumberTXT(input){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(input);
        
        var x= document.getElementById('puntitoX').value;
        var y= document.getElementById('puntitoY').value;
        var radio= document.getElementById('radius_TXT').value;
        
        if(x==0 && y==0){
            document.getElementById(opcionBusqueda+"_combo3").innerHTML='<br /><br />'+txtNoExisteDichoNumeroVuelveAIntentarlo[idioma];
            setTimeout("document.getElementById(\""+opcionBusqueda+"_combo3\").innerHTML='';", 3000);
        }
        else{
			if(radio>_RADIO_MAXIMO_){ 
				radio= _RADIO_MAXIMO_;
				$('radius_TXT').value= _RADIO_MAXIMO_;
			}
			if(radio<_RADIO_MINIMO_){
				radio= _RADIO_MINIMO_;
				$('radius_TXT').value= _RADIO_MINIMO_;
			}
			if(isNaN(radio) || radio==''){
				radio= _RADIO_;
				$('radius_TXT').value= _RADIO_;
			}
        
            var data="?sec=findLugarInteresTXT&x="+x+"&y="+y+"&radio="+radio;
    
            callMapUtilsFunction(data, "CMS");
        }
    }else{
        document.getElementById(input+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+input+"_combo3\").innerHTML='';", 3000);    
    }
}

//encuentra los puntos de interes cercanos a una calle (resultado en modo texto)
function findCornerTXT(input){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(input);
        
        var x= document.getElementById('puntitoX').value;
        var y= document.getElementById('puntitoY').value;
        var radio= document.getElementById('radius_TXT').value;
        
			if(radio>_RADIO_MAXIMO_){ 
				radio= _RADIO_MAXIMO_;
				$('radius_TXT').value= _RADIO_MAXIMO_;
			}
			if(radio<_RADIO_MINIMO_){
				radio= _RADIO_MINIMO_;
				$('radius_TXT').value= _RADIO_MINIMO_;
			}
			if(isNaN(radio) || radio==''){
				radio= _RADIO_;
				$('radius_TXT').value= _RADIO_;
			}
    
        var data="?sec=findLugarInteresTXT&x="+x+"&y="+y+"&radio="+radio;
    
        callMapUtilsFunction(data, "CMS");
    }else{
        document.getElementById(input+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+input+"_combo3\").innerHTML='';", 3000);    
    }
}


//encuentra los puntos de interes cercanos a una calle (resultado en modo texto)
function findBusStopTXT(input){
    
    if (objetusOcupado==0){
		//objetusOcupado = 1;
        asignarInputGlobal(input);
        
        var x= document.getElementById('puntitoX').value;
        var y= document.getElementById('puntitoY').value;
        var radio= document.getElementById('radius_TXT').value;
        
			if(radio>_RADIO_MAXIMO_){ 
				radio= _RADIO_MAXIMO_;
				$('radius_TXT').value= _RADIO_MAXIMO_;
			}
			if(radio<_RADIO_MINIMO_){
				radio= _RADIO_MINIMO_;
				$('radius_TXT').value= _RADIO_MINIMO_;
			}
			if(isNaN(radio) || radio==''){
				radio= _RADIO_;
				$('radius_TXT').value= _RADIO_;
			}
    
        var data="?sec=findLugarInteresTXT&x="+x+"&y="+y+"&radio="+radio;
    
        callMapUtilsFunction(data, "CMS");
    }else{
        document.getElementById(input+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+input+"_combo3\").innerHTML='';", 3000);    
    }
}
function findLugarInteresPorClase(input)
{
    if (objetusOcupado==0){
        //compruebo si ya existe el combo. En ese caso no lo vuelvo a crear.
        if(!document.getElementById(input+'_clasesLugarInteres'))
        {
            asignarInputGlobal(input);
    
			var combo= '<select name="'+input+'_clasesLugarInteres" id="'+input+'_clasesLugarInteres" style="margin-top: 2px;" onchange="findLugarInteresPorClase(\''+input+'\')"><option value="-">'+comboSeleccioneCategoria[idioma]+'</option><option value="1">'+bibliotecas[idioma]+'</option><option value="6">'+instalacionesDeportivas[idioma]+'</option><option value="2">'+centrosJuveniles[idioma]+'</option><option value="8">'+instalacionesSanitarias[idioma]+'</option><option value="3">'+centrosSociales[idioma]+'</option><option value="7">'+instalacionesEducativas[idioma]+'</option><option value="5">'+correos[idioma]+'</option><option value="9">'+mercados[idioma]+'</option><option value="10">'+museos[idioma]+'</option><option value="11">'+organizacionesMunicipales[idioma]+'</option><option value="12">'+policia[idioma]+'</option><option value="4">'+teatros[idioma]+'</option><option value="15">'+centrosDeVenta[idioma]+'</option><option value="16">'+bocasDeMetro[idioma]+'</option><option value="51">'+poiMonumentos[idioma]+'</option><option value="52">'+poiCentrosComerciales[idioma]+'</option><option value="53">'+poiEstaciones[idioma]+'</option><option value="54">'+poiBomberos[idioma]+'</option><option value="55">'+poiCementerios[idioma]+'</option><option value="22">'+poiOtros[idioma]+'</option></select><br />';
            document.getElementById(opcionBusqueda+'_spanLugarInteres').innerHTML= combo;
        }
        else{
			asignarInputGlobal(input);
			
			//----- ESTADISTICAS ---------------------------------------------------------------
			if(opcionBusqueda=="pyr1_origen") oEstadisticas.opcion = 'LIC';
			else if(opcionBusqueda=="pyr1_destino") oEstadisticas.opcion2 = 'LIC';
			else oEstadisticas.opcion = 'LIC';
			//TODO: A�ADIR PARAMETROS DE ESTADISTICAS EN ESTA FUNCION
			var peticionEstadisticas = "";
			if(oEstadisticas.herramienta!='CI'){
				peticionEstadisticas = "&herramienta="+oEstadisticas.herramienta+"&opcion="+oEstadisticas.opcion+"&opcion2="+oEstadisticas.opcion2+"&info="+oEstadisticas.info;
				oEstadisticas.reset();
			}
			//--------------------------------------------------------------------
			
            //la primera opcion no muestra resultados (-)
            if(document.getElementById(input+'_clasesLugarInteres')[document.getElementById(input+'_clasesLugarInteres').selectedIndex].value!='-'){
                //objetusOcupado = 1;
                subSeccion="_spanLugarInteres2";
                
                var data="?sec=findLugarInteresPorClase";
                var clase= document.getElementById(input+'_clasesLugarInteres')[document.getElementById(input+'_clasesLugarInteres').selectedIndex].value;
                data+="&clase="+clase;
                callMapUtilsFunction(data + peticionEstadisticas, "");
            }
        }
    }else{
        document.getElementById(input+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+input+"_combo3\").innerHTML='';", 3000);
    }
}


function lineasPorParada(input){

    if (objetusOcupado==0){
		//objetusOcupado = 1;
        //la primera opcion del select no vale (-)
        var idparada = $(input+'_parada')[$(input+'_parada').selectedIndex].value;
        
        if(idparada!='-'){
            asignarInputGlobal(input);
            subSeccion="_spanBusquedaParadas2";

            var data="?sec=findlineasPorParada&idparada="+idparada;

            callMapUtilsFunction(data, "");
        }
		else{
			document.getElementById(input+'_combo1').innerHTML='<br />Por favor seleccione una parada del desplegable.';
			setTimeout("document.getElementById(\""+input+"_combo1\").innerHTML='';", 3000);
		}
    }else{
        $(input+'_combo3').innerHTML='<br />'+txtEspereAcabePeticionEnCurso[idioma];
        setTimeout("document.getElementById(\""+input+"_combo3\").innerHTML='';", 3000);   
    }
}

function mostrarRadio(){
	if($('radius_TXT')){
		if($('radius_TXT').value=="Radio")
			$('radius_TXT').value= _RADIO_;
	}
}

/**
* Activa el check correspondiente de la lista de POI's dependiendo de la categoria del lugar de interes que se haya buscado.
*/
function checkCategoriaPOI(combo){

	var arrai= ($(combo)[$(combo).selectedIndex].value).split(',');

	//quitamos todos los checks de POI
	//$('selectTodosPoi').checked= false;
	//selectTodosPoi();
	
	//marcamos el check POI correspondiente
	if(arrai[2]){
		//alert(arrai[2])
		var POICheck=document.getElementsByName(arrai[2]);
		POICheck[0].checked= true;
	}

}


function limitaCaracteres(texto){
	if(texto.length < 3) alert("minimo 3 caracteres para realizar una busqueda");
}


function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}






