/***********************************************************************************************************************************************************
				MAPS GOOGLE 
					gestisce la mappa 
***********************************************************************************************************************************************************/
	var map = null;
	var geocoder = null;
	var selezioneMappa ;
	function creaMap(){
		if(!document.getElementById("map")){
			
			var contenitoreMap = document.createElement('div');
			document.getElementsByTagName("body")[0].appendChild(contenitoreMap);			
			contenitoreMap.setAttribute('id',"contenitoreMap");
			contenitoreMap.innerHTML = "<div align='right'><b><a href='#' style='cursor:pointer; color:#FFFFFF; text-decoration:none;' onclick='javascript:closeMap();'>X</a></b></div>";
			
			var map = document.createElement('div');
			contenitoreMap.appendChild(map);			
			map.setAttribute('id',"map");	
			
			if(!ie4){
				map.setAttribute("onMouseDown", "disattivaSetta2();");
				map.setAttribute("onMouseUp", "disattivaSetta2();");
				map.setAttribute("onClick", "disattivaSetta2();");
				contenitoreMap.setAttribute("onMouseDown", "setta2();");
				contenitoreMap.setAttribute("onMouseUp", "disattivaSetta2();");				
			}else{
				document.getElementById("contenitoreMap").onmousedown = setta2;
				document.getElementById("contenitoreMap").onmouseup = disattivaSetta2;	
			}
		
			
		}
	}
	
	function closeMap(){
		
		document.getElementsByTagName("body")[0].removeChild(document.getElementById("contenitoreMap"));
	
	}
	
	function google( dove ){
		 creaMap();
		 selezioneMappa = dove;

		 load();
		 if(dove == 1){
			 showAddress('Via per Camaiore, 2204 Monte S. Quirico Lucca');	
		 }else{
		 	 showAddress('Via Della Rena 55027 gallicano lucca');	
		 }
		 
		 
	}
	
	function load() {
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(43.835664, 10.527745), 5);
			geocoder = new GClientGeocoder();		
		}
	}
	
	function showAddress(address) {
	  if (geocoder) {
		geocoder.getLatLng(address,
		  function(point) {
			if (!point) {
			  //alert(address + " not found");
			} else {
			  map.setCenter(point, 14);
			 // Our info window content
			 var infoTabs;
		if(selezioneMappa == 2){
		 infoTabs = [
		  new GInfoWindowTab("Indirizzo", "<b><span class=\"verdana12\">Papeschi s.r.l. <br> Filiale di Gallicano <br> Via Della Rena <br> Tel. e Fax. +39 0583. 74056</span></b><br><br><center><a target=\"_blank\" class=\"verdana12\" href=\"http://maps.google.it/maps?f=q&hl=it&geocode=&q=Via+Della+Rena+-+55027+gallicano+lucca&sll=41.442726,12.392578&sspn=10.816538,29.355469&ie=UTF8&ll=44.054871,10.447204&spn=0.010132,0.028667&t=h&z=16&iwloc=addr&om=1\">Calcolare Percorso</a></center>"),		  
		   new GInfoWindowTab("Info", "<b><center><span class=\"verdana12\" >:: Papeschi ::</span></center></b><br><a class=\"verdana12\" style=\"cursor:pointer;\" onClick=\"mailto:info@papeschi.it\" target=\"_blank\">info@papeschi.it</a><br><a class=\"verdana12\" href=\"http://www.papeschi.it\" target=\"_blank\"><b>www.papeschi.it</b></a><br>")
		];
		}else{
			 infoTabs = [
		  new GInfoWindowTab("Indirizzo", "<b><span class=\"verdana12\">Papeschi s.r.l. <br> Via per Camaiore, 2204 <br> Monte S. Quirico - Lucca</span></b><br><br><center><a target=\"_blank\" class=\"verdana12\" href=\"http://maps.google.it/maps?f=q&hl=it&geocode=&q=Via+per+Camaiore,+2204+-+Monte+S.+Quirico+-+Lucca&sll=41.442726,12.392578&sspn=13.26565,29.882813&ie=UTF8&ll=43.901603,10.486107&spn=0.099692,0.233459&z=12&iwloc=cent&om=1\">Calcolare Percorso</a></center>"),		  
		   new GInfoWindowTab("Info", "<b><center><span class=\"verdana12\" >:: Papeschi ::</span></center></b><br><a class=\"verdana12\" style=\"cursor:pointer;\" onClick=\"mailto:info@papeschi.it\" target=\"_blank\">info@papeschi.it</a><br><a class=\"verdana12\" href=\"http://www.papeschi.it\" target=\"_blank\"><b>www.papeschi.it</b></a><br>")
		];
		}
		
		// Place a marker in the center of the map and open the info window
		// automatically
		var marker = new GMarker(map.getCenter());
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowTabsHtml(infoTabs);
		});
		map.addOverlay(marker);
		marker.openInfoWindowTabsHtml(infoTabs);
		map.enableDoubleClickZoom();
			}
		  }
		);
	  }
	}
 /***********************************************************************************************************************************************************/
