function getMbounds() 
{
   var view = map.GetMapView();
    if(view.BottomRightLatLong.Latitude == null || view.BottomRightLatLong.Longitude == null)
    {
	if (map.IsBirdseyeAvailable())
        {
     //var view = map.GetBirdseyeScene().GetBoundingRectangle();
	// var view = map.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());
	var northWestLL = (new _xy1).Decode(map.GetMapView().TopLeftLatLong);
    var southEastLL = (new _xy1).Decode(map.GetMapView().BottomRightLatLong);

	 var topleft = view.TopLeftLatLong;
     var bottomright = view.BottomRightLatLong;
	var mapZoom= map.GetZoomLevel()+18;
	xajax_setZoom(mapZoom);
     xajax_setBounds(northWestLL,southEastLL);
	 return true;
        }
     else
        {
        }
	}
	
    var topleft = view.TopLeftLatLong;
    var bottomright = view.BottomRightLatLong;
    var mapZoom= map.GetZoomLevel();
    xajax_setZoom(mapZoom);
    xajax_setBounds(topleft,bottomright);
    //xajax_setCenter(centerLat,centerLon);
	//xajax_updateMapPoints(LatMin,LonMin,LatMax,LonMax);
	return false;
	}
function map_onendzoom(e)
{
    var mapRestrictionZoomLevel = 12; 
	
    if (e.zoomLevel < mapRestrictionZoomLevel)
    {
        //Zoom the map back in to the restricted area
        map.SetZoomLevel(mapRestrictionZoomLevel);
		
    }
	
} 
function SchimbaHarta()
{
    /// Change the map style to Shaded if it's set to Road
    if (map.GetMapStyle() == VEMapStyle.Road)
    {
        map.SetMapStyle(VEMapStyle.Birdseye);
		//map.ShowMiniMap(600,300); 
		//map.DeleteAllPushpins();
		
    }else{
		 map.SetMapStyle(VEMapStyle.Road);
	}
	}
function onFeedLoad(feed)
      {
return;
}
function sterge(id) {
	map.DeleteShape(id);
}
function EventHandlerOnClick(e)

		{

			 VEPushpin.ShowDetailOnMouseOver = true;

			 if (e!=null) {

			   document.getElementById(e.currentTarget.id + "_" + map.GUID).onmouseover();

			   VEPushpin.ShowDetailOnMouseOver = false;

			 } else {

			   document.getElementById(window.event.srcElement.id).onmouseover();

			   VEPushpin.ShowDetailOnMouseOver = false;

			 }

		}
function mouseWheel(e)
        {
             return true;
        }
function showInfoB(e) {
	map.ShowInfoBox(e);
}
function hideInfoB(e){
	if(e!="undefined") {
		return true;

}
else {
		map.HideInfoBox(e);
	}
}
function onClick(e)
{

	if (e.elementID)
{
pin= map.GetShapeByID(e.elementID);
map.ShowInfoBox(pin);
}
}

function onMouseOver(e)
{
pin= map.GetShapeByID(e.elementID);
map.ShowInfoBox(pin);
}

	function MouseHandler(e)
{
if (e.eventName == "onmousedown" && e.elementID != null)
{
//dragShape = map.GetShapeByID("punctTemp");
return true;
}else if (e.eventName == "onmouseup")
{
dragShape = null;
}else if (e.eventName == "onmousemove" && dragShape != null)
{
var x = e.mapX;
var y = e.mapY;
pixel = new VEPixel(x, y);
var LL = map.PixelToLatLong(pixel);
dragShape.SetPoints(LL);
return true; // prevent the default action
}
} 
function onMapMouseDown(e) {
    if (e.leftMouseButton && e.elementID) {
        mode=1;
        //document.getElementById("toolpanelDisplay").value = "down";
        map.vemapcontrol.EnableGeoCommunity(true);
    }
}

function onMapMouseMove(e) {
    var loc = map.PixelToLatLong(new VEPixel(e.mapX, e.mapY)); 
   // document.getElementById("infopanel").innerHTML = round5dec(loc.Latitude) + ", " + round5dec(loc.Longitude);
    if (mode==1) {
        SetPin(loc);
    }
}

function onMapMouseUp(e) {
    if (mode==1 && e.leftMouseButton) {
       // document.getElementById("toolpanelDisplay").value = "up";
        map.vemapcontrol.EnableGeoCommunity(false);
        mode=0;
        var loc = map.PixelToLatLong(new VEPixel(e.mapX, e.mapY));
        SetPin(loc);
    }
}

function onMapClick(e) {
    if (e.rightMouseButton) {
        var loc = map.PixelToLatLong(new VEPixel(e.mapX, e.mapY));         
        SetPin(loc);
    }
}
function SetPin(loc) {
   // document.getElementById("toolpanelDisplay").value = "new VELatLong(" + round5dec(loc.Latitude) + "," + round5dec(loc.Longitude) + ")";
        document.getElementById("lat").value = round5dec(loc.Latitude);       
        document.getElementById("lng").value = round5dec(loc.Longitude); 
    if (pin) {
        //relocate
        pin.SetPoints(loc);
    }else
    {
        //create
        pin = new VEShape(VEShapeType.Pushpin, loc);
 pin.SetCustomIcon("crosshair.png");
        map.AddShape(pin);
    }
}


function SetLocation() {
    var lat = parseFloat(document.getElementById("lat").value);       
    var lon = parseFloat(document.getElementById("lng").value);
    if (!isNaN(lat) && !isNaN(lon) && lat>=-90 && lat<=90 && lon>=-180 && lon<=180) {
        var loc = new VELatLong(lat,lon);
        SetPin(loc);
        map.IncludePointInView(loc);
    }else
    {
        alert("Not valid decimal degrees");
    }
}

function onMapMouseOver(e) {
    if (e.elementID){
        return true;
    }
}

function round5dec(value) {
    return Math.floor(value * 1e5)/ 1e5;
}


