
//<![CDATA[
/***** geocode URL 
http://maps.google.com/maps/geo?q=barcelona,spain&output=xml&key=ABQIAAAAyH1wYKPs374pGa3LD9_XtxTavzygPmbRrx4uinrGbHMxIcIeiBRmRp2AY8EUZ9WN0XIv0uCkZBUwrQ
**/
var map,Icon0;
var donde;

donde="Barcelona, Catalunya";

function createMarker(point, address) {
  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(address);
  });
  return marker;
}

// A TextualZoomControl is a GControl that displays textual "Zoom In"
// and "Zoom Out" buttons (as opposed to the iconic buttons used in
// Google Maps).

// We define the function first
function TextualZoomControl() {
}

// To "subclass" the GControl, we set the prototype object to
// an instance of the GControl object
TextualZoomControl.prototype = new GControl();

// Creates a one DIV for each of the buttons and places them in a container
// DIV which is returned as our control element. We add the control to
// to the map container and return the element for the map class to
// position properly.
TextualZoomControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

  var zoomInDiv = document.createElement("div");
  this.setButtonStyle_(zoomInDiv);
  container.appendChild(zoomInDiv);
  zoomInDiv.appendChild(document.createTextNode("+"));
  GEvent.addDomListener(zoomInDiv, "click", function() {
    map.zoomIn();
  });

  var zoomOutDiv = document.createElement("div");
  this.setButtonStyle_(zoomOutDiv);
  container.appendChild(zoomOutDiv);
  zoomOutDiv.appendChild(document.createTextNode("-"));
  GEvent.addDomListener(zoomOutDiv, "click", function() {
    map.zoomOut();
  });

  map.getContainer().appendChild(container);
  return container;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
TextualZoomControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(4, 4));
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle_ = function(button) {
  button.style.textDecoration = "none";
  button.style.color = "#666666";
  button.style.backgroundColor = "#FEFEFE";
  button.style.font = "small Arial";
  //button.style.font-size = "10px";
  button.style.border = "1px solid #666666";
  button.style.padding = "0px";
  button.style.marginBottom = "3px";
  button.style.textAlign = "center";
  button.style.width = "15px";
  button.style.height = "15px";  
  button.style.cursor = "pointer";
}

function showAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(address);
      }
    }
  )
}

function hideMessage(){
 document.getElementById('alertMsg').style.display = 'none'; 
}
function showMessage(){
 document.getElementById('alertMsg').style.display = 'block'; 
}

function load() {
  if (GBrowserIsCompatible()) {
     map = new GMap2(document.getElementById("map"));
     map.setCenter(new GLatLng(41.387917,2.169919), 1);
	 //map.addControl(new TextualZoomControl());

	 /*map.addControl(new GMapTypeControl());
	   map.addControl(new GOverviewMapControl());
	 /*map.addControl(new GZoomControl(), 
		    new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, 
		    new GSize(10, 10))); 
	*/
	var point = new GLatLng(41.387917,2.169919);
  	map.addOverlay(createMarker(point, "<strong class=text1>Josepe...</strong><br /><font class=text1>"+ donde +"</font>"));
    
	//showAddress(donde);

// Create icon
	Icon0 = new GIcon();
	Icon0.image = "mm_small_red.png";
	Icon0.shadow = "mm_small_red_shw.png";
	Icon0.iconSize = new GSize(12, 20);
	Icon0.shadowSize = new GSize(22, 20);
	Icon0.iconAnchor = new GPoint(6, 20);
	Icon0.infoWindowAnchor = new GPoint(5, 1);

	hideMessage();
	//showPoints();
  }else{
  	alert("Navegador no compatible con google maps, actualiza tu navegador.");
  }
}

    //]]>
