/************************************************************************************************************************
				MAPS GOOGLE 
 FABIO LUCATTINI - gestione mappa 
*************************************************************************************************************************/
	var map = null;
	var geocoder = null;
	var indirizzo = '';
	var lat ,long ;
	var divMappa = "map";
	var zoomSTART = 16;
	
	function load() {
		if ( GBrowserIsCompatible() ) 
		{ 
			
			map = new GMap2( document.getElementById( divMappa ) );
			//POSIZIONO IL CENTRO DELLA MAPPA NEL PUNTO FORNITO 
			if( indirizzo )
			{
				map.setCenter( new GLatLng( indirizzo ) );
			}
			else if( lat && long )
			{
				map.setCenter( new GLatLng( lat, long ) );
			}
			else
			{
				alert(" ERRORE INDIRIZZO ");
			}
			
			map.GGeoAddressAccuracy = 10;
			geocoder = new GClientGeocoder();
			
			// VISUALIZZA LA SCELTA DEL TIPO DI MAPPA
			var tipoMappa = new GMapTypeControl();
			map.addControl( tipoMappa , new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50,1)));
			
			// VISUALIZZA LE FRECCE CHE SI UTILIZZANO PER IL MOVIMENTO
			var frecceMovimento = new GSmallMapControl(); // GSmallMapControl, GLargeMapControl, GSmallZoomControl
			map.addControl( frecceMovimento , new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(1,1)));			
			
			// VISUALIZZA LA MINIMAPPA CON L'AREA ZOMMATA
			var posizione = new GOverviewMapControl();
			map.addControl( posizione , new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(1,1)));
			//posizione.setMapType(G_HYBRID_MAP);
			
			//SETTA DI DEFAULT IL TIPO DI MAPPA 
			map.setMapType(G_HYBRID_MAP); // G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP
			
			// VISUALIZZA LA SCALA DELLA MAPPA
			/*
			var scala = new GScaleControl();			
			map.addControl( scala , new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(1,130)));
			*/
			
		}
		//RICHIAMO LA FUNZIONE CHE IMPOSTA L'INDIRIZZO
		//
		if( indirizzo )
		{
			showAddress ( indirizzo );
		}
		else if( lat && long )
		{
			showAddress ( lat+","+long );
		}
		else
		{
			alert(" ERRORE INDIRIZZO ");
		}
	}
	
	
	function showAddress( address ) {
	  if ( geocoder ) 
	  {
		  geocoder.getLatLng( address ,
		  function(point) 
		  {
			if ( !point ) 
			{ 
			  document.getElementById ( divMappa ).style.visibility = "hidden"; 
			  alert( "ERRORE CARICAMENTO MAPPA !" );
			}  
			else 
			{
				
				map.setCenter(point, zoomSTART);
				
				var infoTabs = [
								
				new GInfoWindowTab("Indirizzo", "<b><span class=\"verdana12\">Bicinque s.r.l.<br>Via di Vorno, 4<br>55060 Guamo Lucca (LU) <br><br>Toscana, Italy</span></b><br><br><center><a target=\"_blank\" class=\"verdana12\" href=\"http://maps.google.com/maps?f=q&source=s_q&hl=it&geocode=&q=43.81441,10.4974&sll=43.676374,10.549534&sspn=0.007729,0.01929&ie=UTF8&hq=&hnear=Via+di+Vorno+in+Guamo,+55012+Capannori+Lucca,+Toscana,+Italia&t=h&z=16\">Calcolare Percorso</a></center>"),		  
		   new GInfoWindowTab("Info", "<b><center><span class=\"verdana12\" >:: Raimar ::</span></center></b><br><a class=\"verdana12\" style=\"cursor:pointer;\" onClick=\"javascript:createDiv('mail');\" target=\"_blank\">info@raimar.it</a><br><a class=\"verdana12\" href=\"http://www.raimar.it\" target=\"_blank\"><b>www.RAIMAR.it</b></a><br>")
				
				];
				
				var marker = new GMarker(map.getCenter());
				
				/*
				SE VUOI IMPOSTARE IL MARKER COME DRAGGABLE
				{draggable: true}
				GEvent.addListener(marker, "dragstart", function() {
				  map.closeInfoWindow();
				});
		
				GEvent.addListener(marker, "dragend", function() {
				  alert("PUNTATORE SPOSTATO");
				});
				*/
				
				map.addOverlay(marker);	
				GEvent.addListener( marker, "click", 
				function() 
				{
					marker.openInfoWindowTabsHtml( infoTabs );
				}
				);			
				
				//AL DOPPIO CLICK AVANZO CON LO ZOOM
				map.enableDoubleClickZoom();			
				
				//APRO LA FINESTRA DELLE INFORMAZIONI AL CARICAMENTO
				marker.openInfoWindowTabsHtml( infoTabs );	

			}
		  }
		  );
	  }
	}
 /***********************************************************************************************************************************************************/