function PuntoMapa(eldiv,direccion,titulo)
{
       
    var eldiv = eldiv;
    var direccion = direccion;
	var titulo = titulo;
	/*
    //si el div del mapa se ve, hay que ocultarlo y detener la función
    if (document.getElementById(eldiv).style.display=='block') {
    document.getElementById(eldiv).style.display = 'none';
    return false;
	}
	
    if (document.getElementById(eldiv).style.display=='none') {
              document.getElementById(eldiv).style.display = 'block';
    }*/
	
	var zoom = 16;

	var maprec = new GMap2(document.getElementById(eldiv));
	
	geocoderSucursal = new GClientGeocoder();

    geocoderSucursal.getLocations(direccion, comprobarErrorSucursal);
	
    
	//funcion para comprobar errores
    function comprobarErrorSucursal(response) 
	{
		  if (response.Status.code == G_GEO_SUCCESS) {
			  //addToMap(response);
			 
			  
			  addToMapSucursal(response);
			  
          } 
		  
		  
		  else 
		  
		  {
			document.getElementById(eldiv).style.display = 'none';
			alert("No se ha encontrado la localización geográfica de la dirección dada. Puede que la dirección sea demasiado nueva o incorrecta. ");
            return false;
		  }

	}//comprobarError
	
	
	
	// This function adds the point to the map
   function addToMapSucursal(response)
   {
   
   try {
      // Retrieve the object
      place = response.Placemark[0];
	 
      // Retrieve the latitude and longitude
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);

      // Center the map on this point
      maprec.setCenter(point, 15);
	  maprec.addControl(new GMapTypeControl());
      maprec.addControl(new GSmallZoomControl());
      maprec.addControl(new GOverviewMapControl());
 
 
 /*
      var mapTypeControl = new GMapTypeControl();
      var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
      var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
      maprec.addControl(mapTypeControl, topRight);
       
*/

	  /*baseIcon = new GIcon();
	  baseIcon.iconSize=new GSize(200,34);
	  baseIcon.shadowSize=new GSize(220,34);
	  baseIcon.iconAnchor=new GPoint(20,34);
	  baseIcon.infoWindowAnchor=new GPoint(40,40);

	  var icono = new GIcon(baseIcon);

	  var html1 = '<div class="globo">';
		html1 = '<div class="globo-texto">';
		html1 += '<b>'+unescape(titulo)+'</b>';
		html1 += '</div>';
		html1 += '</div>';
	
		marca = creaMarcaPunto(point,html1,'');
		maprec.addOverlay(marca);*/
		
		
		 // Create a marker
      marker = new GMarker(point);

      // Add the marker to map
      maprec.addOverlay(marker);
/*
      //Add address information to marker
	  var nombre = $('#nempresa').text();
	  //var address = $('#direccion_txt').text()+'<br>'+$('#cp_txt').text()+'<br>'+$('#provincia_txt').text();
	  marker.openInfoWindowHtml('<div style="width:200px; overflow:hidden"><b>'+nombre+'</b></div>');
 */
 	  }
	  
	  
       catch(err) {
		  
	   document.getElementById(eldiv).style.display = 'none';
	   }
	  
	  
   }//addToMapSucursal

  function creaMarcaPunto(punto,html1,icono) 
	{
		var marc = new GMarker(punto);
	
		GEvent.addListener(marc, "click", function() 
		{
			marc.openInfoWindowTabsHtml([new GInfoWindowTab("Situaci?n",html1)]);
	  });
	  return marc;
	   
	} 


}



