

var apicode = 'ABQIAAAAjkTfisE9ZYkeFtxDnwVUGxRq33IcirnAhvGOjaZRRrxDzGbBlBRZmdRJCDs3sP76PSeV_id6A2IF8A'

//ID del div della mappa
var idfrommaps = 'map'; 

 //livello dello zoom || 13 citta, 16 strada.
var zoomlevel=14;

 //true per usare gli indrizzi | false per la latitudine e longitudine
var addressORlatlag=true;

//indirizzo di default | attivare il segnaposto | nome della nuvoletta (richiede che activemarker sia true) | testo della nuvoletta (richiede che activemarker sia true) | apertura della nuvoletta in automatico (richiede che activemarker sia true)
var addressbase={address:'via  Andrea Appiani 20038 Seregno Milan Italy',activemarker:true,tabname:"Mtm Srl",tabinfo:"via Appiani ang. via Mameli!",opentab:false}; 

//latitudine di default
var latitudebase="37.4419"; 

//longitudine di default
var longitudebase="-122.1419"; 
//fine campi modificabili

var map = null;
var geocoder = null;
var icon = null;

function googlesapi_load() {
	divmaps=document.getElementById(idfrommaps);
	if (GBrowserIsCompatible() && divmaps) {
		map = new GMap2(divmaps);
		geocoder = new GClientGeocoder();
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.enableContinuousZoom();
		GEvent.addDomListener(divmaps, "DOMMouseScroll", wheelZoom);
		GEvent.addDomListener(divmaps, "mousewheel",     wheelZoom);
	}
}    
function showAddress(address,setmarker,tabname,tabtext,opentab) {
	if(geocoder){
		geocoder.getLatLng(address,
			function(point) {
			if(!point){
				alert(address + " not found");
			}else{
				map.setCenter(point, zoomlevel);
				if(setmarker){
					marker = new GMarker(point);
					infoTabs = [ new GInfoWindowTab(tabname, tabtext)];
					GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowTabsHtml(infoTabs);
					});
					map.addOverlay(marker);
					if(opentab){marker.openInfoWindowTabsHtml(infoTabs);}
				}
			}
		});
	}
}
function showlatlng(latshow,lonshow){
	map.setCenter(new GLatLng(latshow, lonshow), zoomlevel);	
}
function wheelZoom(a){
	if (a.detail){
		if (a.detail < 0){ 
			map.zoomIn(); 
		}else if (a.detail > 0){
			map.zoomOut(); 
		}
	}else if (a.wheelDelta){
		if (a.wheelDelta > 0){
			map.zoomIn(); 
		}else if (a.wheelDelta < 0){
			map.zoomOut(); 
		}
	}
}
function showmaps(){
	googlesapi_load();
	if(addressORlatlag){
		showAddress(addressbase['address'],addressbase['activemarker'],addressbase['tabname'],addressbase['tabinfo'],addressbase['opentab']);
	}else{
		showlatlng(latitudebase,longitudebase);
	}
}
document.write('<script src="http://maps.google.com/maps?file=api&v=2&key='+apicode+'" type="text/javascript"></script>');

