var gmarkers = [];
var htmls = [];
var to_htmls = [];
var from_htmls = [];
var i=0;
		
// A function to create the marker and set up the event window
function createMarker(point,name,html) {
	var marker = new GMarker(point);
	// The info window version with the "to here" form open
	to_htmls[i] = html + '<br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + i + ')">From here</a>' +
           '<br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + 
                  // "(" + name + ")" + 
           '"/>';
  // The info window version with the "to here" form open
  from_htmls[i] = html + '<br>Directions: <a href="javascript:tohere(' + i + ')">To here</a> - <b>From here</b>' +
           '<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" + 
           '"/>';
  // The inactive version of the direction info
  html = html + '<br>Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
  });
  gmarkers[i] = marker;
  htmls[i] = html;
	i++;
  return marker;
}
			
function load() {
  if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		// En esta parte asignamos el punto central y el ZOOM. 40.396764,-3.713379 es Madrid y ZOOM 6 para 600 x 600 se ve toda España.
		map.setCenter(new GLatLng(40.396764,-3.713379), 5); 
		
		/*
		var icon_oficinas_madrid = new GIcon();
		icon_oficinas_madrid.image = "../../images/iconos/gm_rojo.gif";
		icon_oficinas_madrid.iconSize = new GSize(30,30);
		icon_oficinas_madrid.iconAnchor = new GPoint (15,30); // punto de anclaje.
		icon_oficinas_madrid.infoWindowAnchor = new GPoint(15,15); // Punto de anclaje de la ventana.
		
		var v_html_madrid = '<div style="width:320px;height:80px;">';
		v_html_madrid += '<div style="width:140px;height:80px;float:left;"><img border="0" alt="Logotipo de Grupo Lekunbide" title="GRUPO LEKUNBIDE" src="../../images/caras/grupo-lekunbide.jpg" /></div>';
		v_html_madrid += '<div style="width:5px;height:80px;float:left;"></div>';
		v_html_madrid += '<div style="width:auto;height:80px;">';
		v_html_madrid += '<p>';
		v_html_madrid += '<strong>Dirección Comercial</strong><br/>';
		v_html_madrid += 'Tfno: 91 653 91 90<br/>';
		v_html_madrid += '</p>';
		v_html_madrid += '</div>';
		v_html_madrid += '</div>';
		*/
			
		var icon_oficinas_bilbao = new GIcon();
		icon_oficinas_bilbao.image = "../../images/iconos/gm_amarillo.gif";
		icon_oficinas_bilbao.iconSize = new GSize(30,30);
		icon_oficinas_bilbao.iconAnchor = new GPoint (15,30); // punto de anclaje.
		icon_oficinas_bilbao.infoWindowAnchor = new GPoint(15,15); // Punto de anclaje de la ventana.
		
		var v_html_bilbao = '<div style="width:320px;height:80px;">';
		v_html_bilbao += '<div style="width:140px;height:80px;float:left;"><img border="0" alt="Logotipo de Grupo Lekunbide" title="GRUPO LEKUNBIDE" src="../../images/caras/grupo-lekunbide.jpg" /></div>';
		v_html_bilbao += '<div style="width:5px;height:80px;float:left;"></div>';
		v_html_bilbao += '<div style="width:auto;height:80px;">';
		v_html_bilbao += '<p>';
		v_html_bilbao += '<strong>Bureaux Centraux</strong><br/>';
		v_html_bilbao += 'Tfno: 94 661 31 96 <br/>';
		v_html_bilbao += '</p>';
		v_html_bilbao += '</div>';
		v_html_bilbao += '</div>';
								
		/*
		var marcador_oficinas_madrid = new GMarker(new GLatLng(40.363288,-3.619995),icon_oficinas_madrid)
		map.addOverlay(marcador_oficinas_madrid);
		*/
		
		var marcador_oficinas_bilbao = new GMarker(new GLatLng(43.262058,-2.928125),icon_oficinas_bilbao)
		map.addOverlay(marcador_oficinas_bilbao);
		
		/*
		GEvent.addListener(marcador_oficinas_madrid, "click", function() {
			marcador_oficinas_madrid.openInfoWindowHtml(v_html_madrid);
		});
		*/
			
		GEvent.addListener(marcador_oficinas_bilbao, "click", function() {
			marcador_oficinas_bilbao.openInfoWindowHtml(v_html_bilbao);
		});
  }
}
