         function GetMap(){
            map = new VEMap('myMap');
            map.LoadMap(new VELatLong(start_map_lat, start_map_lon), start_map_zoom ,'r' ,false);
            map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
            //map.ShowMiniMap(588, 298);
			
            setupMap();
			
			if(open_panel_at_start){
				map.Pan(defpanX,defpanY);
				initSlideLeftPanel();
			}
           
		    map.AttachEvent("onchangemapstyle", OnChangeStyle);
		   	firefoxFixMenu();
				
         }   

        function OnChangeStyle(e){
			//alert(map.GetCenter());
			
			//var scene = map.GetBirdseyeScene();
			var style = map.GetMapStyle();

            if (style == VEMapStyle.Birdseye) {
				map.SetBirdseyeScene(map.GetCenter(), VEOrientation.North, poi_bird_zoom, null);
			}
			
		}	
		
		 function firefoxFixMenu(){
		 	var flatlandMapMode = document.getElementById('MSVE_navAction_FlatlandMapMode');
			if(flatlandMapMode != null)
				flatlandMapMode.innerHTML = "2D";
				
			var roadMapStyle = document.getElementById('MSVE_navAction_RoadMapStyle');
			if(roadMapStyle != null)
				roadMapStyle.innerHTML = "Stradale";			
			
			var aerialMapStyle = document.getElementById('MSVE_navAction_AerialMapStyle');
			if(aerialMapStyle != null)
				aerialMapStyle.innerHTML = "Aerea";
			
			var hybridMapStyle = document.getElementById('MSVE_navAction_HybridMapStyle');
			if(hybridMapStyle != null)
				hybridMapStyle.innerHTML = "Ibrida";			
			
			var obliqueMapView = document.getElementById('MSVE_navAction_ObliqueMapView');
			if(obliqueMapView != null)
				obliqueMapView.innerHTML = "Ravvicinata";			
		 }

         function AddMyLayer(type,lat,lon,descr)
         {
            
			//ripulisco se ho già 1 layer visualizzato
			if(map.GetShapeLayerCount() > 1) map.Clear();
			
			//alert("visualizza il layer!!!");
            var shapeLayer = new VEShapeLayer();
            var date = new Date();
            date.getTime();    

            var georssURL = baseUrl+date.getTime()+'.xml';
            //alert(georssURL);
            var veLayerSpec = new VEShapeSourceSpecification(type, georssURL , shapeLayer);
            
			map.AttachEvent("onchangeview", panMapLayer);
            map.ImportShapeLayerData(veLayerSpec, onFeedLoad);
            
			//da fixare!!!
            //map.Pan(defpanX,defpanY);
            
         }
		
		function onFeedLoad(layer){
		    var numShapes = layer.GetShapeCount();
		    var shape;
		    for(var i=0; i < numShapes ; ++i){
				
		        shape = layer.GetShapeByIndex(i);
		        //shape.SetCustomIcon("<img src='images/georss.png'/>"); // LA INSERISCO A TUTTI GLI ELEMENTI
		        shape.SetCustomIcon("<img src='"+ shape.IconId+"'/>"); //NEL CASO IN QUI L'URL L'IMMAGINE SI TROVI ALL'INTERNO DEL GEORSS
		        if(shape.IconId == "images/pixel.gif"){
					shape.Hide();
				}
		    }
		}
		
		function clearMap(){
			map.Clear();
			//map.LoadMap(new VELatLong(start_map_lat, start_map_lon), start_map_zoom ,'r' ,false);
			//map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
			//map.ShowMiniMap(358, 298);
            var style = map.GetMapStyle();

            if (style == VEMapStyle.Birdseye){
               map.SetMapStyle(VEMapStyle.Road);
            }

			var map_reset_latlon = new VELatLong(start_map_lat, start_map_lon);
			map.AttachEvent("onchangeview", panMapLayer);
			map.SetCenterAndZoom(map_reset_latlon, start_map_zoom);
			setupMap();
		}
		
		function panMapLayer(){
			map.Pan(defpanX,defpanY);
			map.DetachEvent("onchangeview", panMapLayer);
		}		
		
		function setupMap(){	
			document.getElementById('MSVE_navAction_View3DMapMode').style.display = "none";		
			document.getElementById('MSVE_navAction_showLabels').style.display = "none";	
			document.getElementById('MSVE_navAction_ObliqueMapView').style.width = "80px";
			document.getElementById('MSVE_navAction_container').style.width = "340px";
			
			//document.getElementById('MSVE_navAction_ObliqueMapView').style.display = "none";	visualizzazione  bird's eye
			//document.getElementById('MSVE_obliqueNotification').style.visibility = "hidden";
			document.getElementById('MSVE_navAction_separator2').style.visibility = "hidden";	

			if(document.getElementById('MSVE_minimap_resize') != null)	
				document.getElementById('MSVE_minimap_resize').style.display = "none";
	
		}
		
		function zoomEntity(lat,lon,pos){
		
		    //map.Resize();
		    
			map.HideInfoBox();
			//map.ClearInfoBoxStyles();
			//var maplevel = map.GetZoomLevel();
			
			sel_entity_latlon  = new VELatLong(lat, lon);

			//map.SetCenterAndZoom(sel_entity_latlon, poi_zoom);
			//map.SetCenter(sel_entity_latlon);
			
			posSelected = pos;
			
			var style = map.GetMapStyle();

            if (style == VEMapStyle.Birdseye) {
				fixCenterLatLonBird(deffixX, deffixY);
			}else {
				fixCenterLatLon(deffixX, deffixY);
			}
		}
		
		
		function fixCenterLatLon(fixX,fixY){
			if(map.GetZoomLevel() != poi_zoom)
				map.SetZoomLevel(poi_zoom);
		
			var pixel = map.LatLongToPixel(sel_entity_latlon, map.GetZoomLevel());
			var latlonfixX = pixel.x;
			var latlonfixY = pixel.y;
            
			//sposto il centramento di 200px sull'asse delle x
			latlonfixX = latlonfixX + fixX ;
			latlonfixY = latlonfixY + fixY ;
			
            var pixel = new VEPixel(latlonfixX, latlonfixY);
            
            var fixsel_entity_latlon = map.PixelToLatLong(pixel);

			map.AttachEvent("onchangeview", fixCenterEnd);
			map.SetCenterAndZoom(fixsel_entity_latlon, poi_zoom);
			window.setTimeout(fixCenterEnd, 800);				


		}
		
		function fixCenterLatLonBird(fixX,fixY){
		
			var scene = map.GetBirdseyeScene();
			
			//var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

			var pixel = scene.LatLongToPixel(sel_entity_latlon, map.GetZoomLevel());
			var latlonfixX = pixel.x;
			var latlonfixY = pixel.y;

			//sposto il centramento di 200px sull'asse delle x
			latlonfixX = latlonfixX + fixX ;
			latlonfixY = latlonfixY + fixY ;
			
            pixel = new VEPixel(latlonfixX, latlonfixY);

            var fixsel_entity_latlon = scene.PixelToLatLong(pixel);
			map.SetBirdseyeScene(fixsel_entity_latlon, scene.GetOrientation(),map.GetZoomLevel(),fixCenterEnd);
			window.setTimeout(fixCenterEnd, 800);	

			//ok senza problemi
			//map.SetBirdseyeScene(sel_entity_latlon, VEOrientation.North,poi_bird_zoom,fixCenterEnd);

		}		

		
		function fixCenterEnd(e){
			
			map.DetachEvent("onchangeview", fixCenterEnd);
			
			if(map.GetShapeLayerCount() > 1){
				var sel_layer = map.GetShapeLayerByIndex(1);
				var sel_shape = sel_layer.GetShapeByIndex(parseInt(posSelected));	
				sel_entity_Id = map.GetShapeByID(sel_shape.GetID());
				window.setTimeout(ShowInfoBox, 800);
			}	

		}
		

		
		function ShowInfoBox(){
			try{	
				map.ShowInfoBox(sel_entity_Id, sel_entity_latlon);
			}catch(err){
			}				
		}		
		
		function hideInfoBox(){
			map.HideInfoBox();
		}		
		
