/* Funciones Google maps */
function initialize() {
			
	//Si empieza a ejecutarse significa que javascript está activo, por tanto se oculta el mapa estático y se activa
  	//el dinámico
//  	document.getElementById('staticMap').style.display = 'none';
  	document.getElementById('map').style.display = 'block';

	//Creación de los iconos para el mapa  		
    icon = new GIcon();
	icon.image = "/img/" + sIdioma + "/aplicaciones/google.png";
	//icon.shadow = "/img/" + sIdioma + "/aplicaciones/googleSombra.png";
	icon.iconSize = new GSize(20, 27);
	//icon.shadowSize = new GSize(59, 32);
	icon.iconAnchor = new GPoint(10, 27);
	icon.infoWindowAnchor = new GPoint(10, 0);

    if (GBrowserIsCompatible()) {      
    	map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
	  	map.addControl(new GMapTypeControl());
    	setDirections('');
     }
}
    
function setDirections(fromAddress) {
	
	if (fromAddress == '' || fromAddress == ', '){
		var marker = new GMarker(new GLatLng(sLatIni,sLongIni),icon);
		map.setCenter(new GLatLng(sLatIni,sLongIni),10);
		map.addOverlay(marker);
	} else {
		//Las direcciones deben expresarse siempre en latitud y longitud, con lo que tendremos que transformarlas
		var oGeoCoder
		map.closeInfoWindow();
		oGeoCoder = new GClientGeocoder;
		oGeoCoder.getLatLng(fromAddress,function (point){
			if (!point) {
				alert(fromAddress + ' dirección no encontrada');      
			} else {
				var sLocale = sIdioma;
				oDirections.load('from: ' + point.lat() + ', ' + point.lng() + ' to: ' + sLatIni + ', ' + sLongIni, {'locale':sLocale});
			}
		});
    }
}
