var map;
var geocoder;
var zoomlevel = 15;

function load(titolo, indirizzo) {
      center_map();
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
        map.checkResize();
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        showAddress(indirizzo + ", 43100 Parma, Italia",true,"","<span style='font-size:14px;font-weight:bold'>" + titolo + "</span><p style='padding-top:5px'>" + indirizzo + "<br>Parma, Italia",true);
      }
    }
    
function center_map()
 {
  var map_cont = document.getElementById("map_cont");
  var x = (screen.availWidth / 2) - (1300 / 2);
  var y = (screen.availHeight / 2) - (400 / 2);         
  map_cont.style.top = y + 'px';
  map_cont.style.left = x + 'px'; 
  map_cont.style.display = "block";
 }
 
 function hide_map()
 {
  var map_cont = document.getElementById("map_cont");
  GUnload();
  map_cont.style.display = 'none';
 }
 
 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);}
				}
			}
		});
	}
}


