
var map = null;
var language;
var latitude;
var longitude;
var title;
var description;
var zoom = 13;
var style;

function GetMap(){
    //Lat & Lng Bergamo: 45.7040570355124200, 9.6629476547241200
    
    var lat_lng = new VELatLong(latitude, longitude);

    map = new VEMap('map');
    map.LoadMap();
    
    switch(style) {
        case 'aerial': 
            map.SetMapStyle(VEMapStyle.Aerial);
            break;
        default: 
            map.SetMapStyle(VEMapStyle.Road);
            break;
    }

    LoadPlacesLayer('inc/hotels.xml', 'images/pushpin.gif');  //Hotels
    
    //AddPushPin(lat_lng, title, description);
    map.SetCenterAndZoom(lat_lng, zoom);
}

function AddPushPin(lat_lng, title, description) {
    var pushpin = new VEShape(VEShapeType.Pushpin, lat_lng);
    
    pushpin.SetTitle(title);
    pushpin.SetCustomIcon('images/pushpin.gif');
    pushpin.SetDescription(description);
    
    map.AddShape(pushpin);
}

function LoadPlacesLayer(src, IconUrl) {
    var layer = new VEShapeLayer();
    var veLayerSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS, src, layer);
    
    map.ImportShapeLayerData(veLayerSpec, function() {
        var numShapes = layer.GetShapeCount();
        var s, n, icon;
		 
        for (var i = 0; i < numShapes; ++i) {
		    s = layer.GetShapeByIndex(i);
				
		    n = i + 1;
		    icon = IconUrl;
		    s.SetCustomIcon(icon);
        }
    }, false);
}

function OpenMap(url) {
    window.open(url,'map','width=990,height=500');
}
