		// Definimos las variables globales que vamos a usar en la función
		var map;
		var bus;
	  
		var circulo_creado = 0;
		var circulo_buscador = 0;
		
		var ruta_on = 0;
	  
		// Array donde vamos a introducir todos los puntos que pueden ser de interes
		var markerArray;

		// Objeto GPolygon que representara el area marcada por el radio alrededor del supuesto coche
		var polygon;
	  
		// Punto de comienzo del mapa
		var startPoint = new GLatLng(42.952, -7.19);
	
		var map = null;
		var localSearch = null;
		var myQueryControl = null;
		var hayResultados = null;
		/*
		Inicializamos la funcion
		Creamos el objeto GMap2, y definimos los controles iniciales y la localidad de comienzo.
		 */
		function init() {
			if (GBrowserIsCompatible()) {
				map = new GMap2(document.getElementById("map"));
				//Activamos y desactivamos controles
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				//map.disableDoubleClickZoom();
				map.enableScrollWheelZoom();
				
				//Para el buscador
				geocoder = new GClientGeocoder();
				geocoder.setBaseCountryCode('es');
				sw = new GLatLng(41.80,-9.37);
				ne = new GLatLng(43.80,-6.80);
				limites = new GLatLngBounds(sw,ne);
				
				geocoder.setViewport(limites);
								
				//Aqui llama a la funcion para crear el circulo cuando hace click en el mapa
				GEvent.addListener(map, "click", function(overlay, point) {
					if(circulo_creado == 0){
						if (point) {
							singleClick = !singleClick;
							setTimeout("createCircle(new GLatLng("+ point.y + ", " + point.x +"), 5000);", 1000);
						}
					}
				});
			//Asigamos el punto central con el valor de la variable startPoint que definimos antes y el valor del zoom
			map.setCenter(startPoint, 8);
			// Pasamos los puntos
			markerArray = new Array();
			getParadasPuntos();
			
        }
      }
	
    function createStoreMarker(point, id_parada, nombre){

		var func_icon = new GIcon();
			func_icon.image = "i/dot.png";
			func_icon.iconSize = new GSize(16, 16);
			func_icon.iconAnchor = new GPoint(6, 6);
			func_icon.infoWindowAnchor = new GPoint(5, 1);
		var func_markerOpts = {};
			func_markerOpts.icon = func_icon;
			func_markerOpts.title = nombre;
		
        var func_marker = new GMarker(point, func_markerOpts);
		
        GEvent.addListener(func_marker, "click", function() {
			getDatosPunto(func_marker, id_parada, nombre);
			borrar();
		});
        return func_marker;
    }

    
	/*Funcion para chequear las paradas y ver si alguna esta dentro del circulo*/
    function checkPoints(){
		// Si no existe ninguno, return
        if (!markerArray || markerArray.length == 0)
			return;
	var hay = 0;
        // Iteramos y mostramos o ocultamos segun esten en el circulo o no
		for (n=0 ; n < markerArray.length ; n++ )
        {
			dist = distance(markerArray[n].getLatLng(), GeoQuery._centerHandlePosition); 
			if (dist <= GeoQuery._radius / 1000) {
				markerArray[n].show();
				hay ++;
			}else{
				markerArray[n].hide();
			}
        }
	if (hay){
		paso2();
		hayResultados = hay;
	}else{
		if (!hayResultados){
			escribir("tabla", traducir('Errorparada'));
		}
	}
    }
	
	function ocultarPoints(){
		GeoQuery.deleteCircle();
		// Si no existe ninguno, return
        if (!markerArray || markerArray.length == 0)
			return;
        // Iteramos y mostramos o ocultamos segun esten en el circulo o no
		for (n=0 ; n < markerArray.length ; n++ )
        {
			markerArray[n].hide();
        }
    }
	

    //Event.observe(window, "load", 'init()');
	setTimeout('init()', 1000);
    
	
	
