
function cambiarTabObra(idtab)
{
	var parentUL = document.getElementById("tab_ul_obra");
	var ntabs = parentUL.getElementsByTagName('li').length;
	if (idtab>ntabs-1) {idtab=ntabs-1;}
	
	for(i=0;i<ntabs;i++)
	{
		var pestana = document.getElementById("tab_obra_"+i);
		pestana.className="";
		var elemento =document.getElementById("datos_obra_"+i);
		elemento.style['display'] = "none";
	}

	var pestana2 = document.getElementById("tab_obra_"+idtab);
	pestana2.className="tabberactive";
	var elemento2 = document.getElementById("datos_obra_"+idtab);
	elemento2.style['display'] = "block";
	
	// Si se pulsa la Localización cargamos el mapa (sólo si es la primera vez)
	if (idtab==(ntabs-1))
	{
		if (document.getElementById("map_canvas").innerHTML == '')
		{
			loadMap();
		}
	}
}

/* Se necesitan definir 4 variables:
latitud: contiene la latitud del centro del mapa
longitud: contiene la longitud del centro del mapa
contenido: HTML que se mostrará en el bocadillo
titulo: texto del tooltip de la marca
*/

function loadMap() 
{
	var latlng = new google.maps.LatLng(latitud, longitud);
	
    var myOptions = {
      zoom: 16,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	  var infowindow = new google.maps.InfoWindow({
        content: contenido
    });

	var image = new google.maps.MarkerImage('http://www.programate.com/wp-content/themes/default/images/simbolo_mapa.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(40, 40),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(20, 20));

    var marker = new google.maps.Marker({
		icon: image,
        position: latlng,
        map: map,
        title: titulo
    });
  
	google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
	
	google.maps.event.addListener(marker, 'mouseover', function() {
      infowindow.open(map,marker);
    });
	  
}
  	

