	var _actiu;
	var gmarkers = [];
	var side_bar_html = "";
	var numConc = "";
 // A function to create the marker and set up the event window

  function createMarker(point,options, i) {      	
			var options2 = {title:options.title};
			var marker = new GMarker(point, options2);
			var html = '';
      //var marker = new GMarker(point,options);
      GEvent.addListener(marker, "click", function() {        	
				if(options.imgSRC != "" && options.imgALT != ""){
					html  = '<dl class="sidebardl bocGmap"><dt><img alt="'+options.imgALT+'" src="'+options.imgSRC+'"/><p><strong>'+options.categoria+'</strong><br/><a href="'+options.link+'">'+options.title+'</a></p></dt></dl>';
				}
				else{
					html  = '<dl class="sidebardl bocGmap"><dt><p><strong>'+options.categoria+'</strong><br/><a href="'+options.link+'">'+options.title+'</a></p></dt></dl>';
				}

				marker.openInfoWindowHtml(html);
      });
              
      // save the info we need to use later for the side_bar
      gmarkers[i] = marker;
      // add a line to the side_bar html
      side_bar_html += '<a id="gog_' + i + '" href="javascript:myclick(' + i + ')">' + name + '</a><br>';
      i++;
      return marker;
    }


		// This function picks up the click and opens the corresponding info window
	function myclick(i) {
		GEvent.trigger(gmarkers[i], "click");
		if (_actiu!=null) { $("gog_" + _actiu).removeClass("actiu"); }
		$("gog_" + i).addClass("actiu");
		 _actiu = i;
	}

function loadMap(){		
		if (GBrowserIsCompatible()) {
    // this variable will collect the html which will eventualkly be placed in the side_bar		      
  
    // arrays to hold copies of the markers used by the side_bar
    // because the function closure trick doesnt work there
    
    var i = 0;

    // create the map
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng( 41.25398,0.4863707), 2);
    map.setMapType(G_SATELLITE_MAP);
	
		

    // Read the data from example.xml
    var request = GXmlHttp.create();
    request.open("GET", "xml/gmaps_489.xml", true);
    
    
    request.onreadystatechange = function() {
    if (request.readyState == 4) {
        
        //var xmlDoc = GXml.parse(request.responseXML);
        var xmlDoc = request.responseXML;
        // obtain the array of markers and loop through it
        
        var markers = xmlDoc.documentElement.getElementsByTagName("item");
        
        for (var i = 0; i < markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i].getAttribute("lat"));
          var lng = parseFloat(markers[i].getAttribute("long"));
          var id_item = markers[i].getAttribute("id");
          
          var point = new GLatLng(lat,lng);
          var label = markers[i].getElementsByTagName('label')[0].firstChild.data;
          var categoria = markers[i].getElementsByTagName('categoria')[0].firstChild.data;
          var urlLink = markers[i].getElementsByTagName('link')[0].firstChild.data;
          
          var img = markers[i].getElementsByTagName("img");
          var imgSRC = "";
          var imgALT = "";
          if (img.length > 0){
							imgSRC = img[0].attributes.getNamedItem("src").value;
							imgALT = img[0].attributes.getNamedItem("alt").value;
					}
					
					var marker = createMarker(point,{'title':label,'link':urlLink,'imgALT':imgALT,'imgSRC':imgSRC,'categoria':categoria}, i);            
          
          map.addOverlay(marker);
        }
      }
    }
    request.send(null);
  }

  else {
    alert("Sorry, the Google Maps API is not compatible with this browser");
  }
    }
