      var map = null;
       //var lat= '<%=Latitudine%>';var lon= '<%=Longitudine%>';

	  function GetMap()
      {
         map = new VEMap('harta');
         map.LoadMap();
         map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
	 DoCenterZoom(scara);
	 if (scara==16)
	            {
                    var s = new VEShape(VEShapeType.Pushpin, new VELatLong(lat, lon));
                    //s.SetTitle(decodeUtf8('ªmîrlã Þuþulea'));
                    map.AddShape(s);
                    }
         else
	            {
                    map.AddPolyline(AddCircle(lat,lon,8));
                    }

      }

      function DoZoomIn(c)
      {
         map.ZoomIn();
      }

      function DoZoomOut()
      {
         map.ZoomOut();
      }

      function DoCenterZoom(scara)
      {

         if (lat=='')
		 {
		 lat=14.6048471550539;
		 lon=0;
		 var zoom = 1;
		 } else {
		 var zoom = scara;
		 }
         //var LatLon = new VELatLong(lat, lon);
         // Add Shape to Map
         // map.AddShape(new VEShape(VEShapeType.Pushpin, LatLon));
         map.SetCenterAndZoom(new VELatLong(lat, lon), zoom);
      }

function AddCircle(latin, lonin, radius)
{
    var locs = new Array();
    var lat1 = latin * Math.PI/180.0;
    var lon1 = lonin * Math.PI/180.0;
    var d = radius/3956;
    var x;
    for (x = 0; x <= 360; x+=10) // 36 points per circle
    {
        var tc = (x / 90)* Math.PI / 2;
        var lat = Math.asin(Math.sin(lat1)*Math.cos(d)+Math.cos(lat1)*Math.sin(d)*Math.cos(tc));
        lat = 180.0 * lat / Math.PI;
        var lon;
         if (Math.cos(lat1)==0)
        {
            lon=lonin; // endpoint a pole
        }
        else
        {
            lon = ((lon1 - Math.asin(Math.sin(tc) * Math.sin(d)/Math.cos(lat1)) + Math.PI) % (2 * Math.PI)) - Math.PI;
        }
        lon = 180.0 * lon / Math.PI;
        var loc = new VELatLong(lat,lon);
        locs.push(loc);
    }
    var poly = new VEPolyline(999, locs, new VEColor(255,0,0,.1) , 8);
    return poly;
}

     function AddShape(title, latlong) {
         // Create Pushpin Shape
         var s = new VEShape(VEShapeType.Pushpin, latlong);
         s.SetTitle(title);

         // Add Shape to Map
         map.AddShape(s);
     }
     
	function encodeUtf8 (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	}
	function decodeUtf8 (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}
