  /* Icon:
	var icon = new VECustomIconSpecification();
	icon.Image = "http://dev.virtualearth.net/mapcontrol/v6/i/bin/1.0.20070926140324.39/pins/poi_usergenerated.gif";
	icon.ImageOffset'>http://dev.virtualearth.net/mapcontrol/v6/i/bin/1.0.20070926140324.39/pins/poi_usergenerated.gif">http://dev.virtualearth.net/mapcontrol/v6/i/bin/1.0.20070926140324.39/pins/poi_usergenerated.gif";
	icon.ImageOffset = new VEPixel(0, -13);

	var shape = new VEShape(VEShapeType.Pushpin, latlong);
	shape.SetCustomIcon(icon); 
  */

	var imageWidth=43;
	var imageHeight=22;
	 
	var customIcon = new VECustomIconSpecification();
	customIcon.Image ="http://www.toppartika.lv/media/img/design/map_pin.png";
	customIcon.ImageOffset = new VEPixel(parseInt(imageWidth/2-13),parseInt(imageHeight/2-13));
	 
  
  
  function createMap(id,large,lat,lon,change)
         {
			if (large == null){ large = false; };
			if (lat == null){ lat = 56.948944; marker = false; }
			else { marker = true; };
			if (lon == null){ lon = 24.103775; };
			if (change == null){ change = true; };
			
			if(large == true) {
				large_map = new VEMap(id);
				latlon = new VELatLong(lat, lon)
				
				if(change == true) { 
					var zoom = 10; 
				} 
				else { 	
					var zoom = 14;
				};
				
				large_map.LoadMap(latlon, zoom ,'VEMapStyle.Road' ,false);
				large_map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers)
				large_map.HideDashboard();
				if(change == true) {
					large_map.AttachEvent("ondoubleclick", addPushpin);
				};
				
				if(marker == true && change == true) {
					// Create the Pushpin Shape
					var s = new VEShape(VEShapeType.Pushpin, latlon);
					s.SetCustomIcon(customIcon);
					s.SetTitle(name);

					// Plot a Shape at the Clicked location
					large_map.AddShape(s);
				}
				else {
					for(i=0;i<shops_count;i++) {
						if (shops[i][0] != null){
						   // Create the Pushpin Shape
							var shop_latlon = new VELatLong(shops[i][2], shops[i][3])
							var s = new VEShape(VEShapeType.Pushpin, shop_latlon);
							s.SetCustomIcon(customIcon);
							s.SetTitle(shops[i][0]);
							s.SetDescription(shops[i][1] + "<br><a href='" + shop_more_url + shops[i][4] + "'>" + shop_more_text + "</a>");
							large_map.AddShape(s);
						};
					};
				}
			}
			else {
				small_map = new VEMap(id);
				
				latlon = new VELatLong(lat, lon);
				
				if(lat != 56.948944 || lon != 24.103775) { 
					var zoom = 13; 
				} 
				else { 	
					var zoom = 10;
				};
				
				small_map.LoadMap(latlon, zoom, 'VEMapStyle.Road' ,false);
				small_map.HideDashboard();
				small_map.HideScalebar();
			
				for(i=0;i<shops_count;i++) {
					if (shops[i][0] != null){
					   // Create the Pushpin Shape
						var shop_latlon = new VELatLong(shops[i][2], shops[i][3])
						var s = new VEShape(VEShapeType.Pushpin, shop_latlon);
						s.SetCustomIcon(customIcon);
						s.SetTitle(shops[i][0]);
						s.SetDescription(shops[i][1] + "<br><br><a href='" + shop_more_url + shops[i][4] + "'>" + shop_more_text + "</a>");
						small_map.AddShape(s);
					};
				};
			};

         }
		 		 
		 function addPushpin(e) {
		 	latlon = large_map.PixelToLatLong(new VEPixel(e.mapX, e.mapY))
			$('#latlon').val(latlon);
			
			// Remove all shapes
			large_map.DeleteAllShapes();
			
		   // Create the Pushpin Shape
			var s = new VEShape(VEShapeType.Pushpin, latlon);
			s.SetCustomIcon(customIcon);
			s.SetTitle(name);

			// Plot a Shape at the Clicked location
			large_map.AddShape(s);
			return true;
		 }
		 
		 function searchLatLon(objId, cback) {
			text = $('#'+objId).val();
			if(cback == 1) {
				// Search closest
				$("#searchShopError").hide();
				small_map.Geocode(text, postMyLocation);
			}
			else if(cback == 2) {
				// Search for pushpin
				large_map.Geocode("Latvia, "+text, addFirstPushpin);
			}
			else if(cback == 3) {
				// Search at shop adding
				large_map.Geocode(text, searchAtAdding);
			}
		 }
		 
		function searchAtAdding(layer, findResults, placeResults) {
			if(placeResults == null) {}
			else if(placeResults.length > 0) {
				latlon = placeResults[0].LatLong;
				$('#latlon').val(latlon);
		
				// Remove all shapes
				large_map.DeleteAllShapes();
				
			   // Create the Pushpin Shape
				var s = new VEShape(VEShapeType.Pushpin, latlon);
				s.SetCustomIcon(customIcon);
				s.SetTitle(name);

				// Plot a Shape at the Clicked location
				large_map.AddShape(s);
			}
		 }
		 
		function postMyLocation(layer, findResults, placeResults)
         {	
			 if(placeResults == null) {
				$("#searchShopError").show();
			 }
			else if(placeResults.length > 0) {
				$("#closest_latlon").val(placeResults[0].LatLong);
				document.forms["searchShop"].submit();
			}
         }
		 
		function addFirstPushpin(layer, findResults, placeResults)
         {
			if(placeResults.length > 0 && $('#latlon').val() == '') {
				latlon = placeResults[0].LatLong;
				$('#latlon').val(latlon);
		
				// Remove all shapes
				large_map.DeleteAllShapes();
				
			   // Create the Pushpin Shape
				var s = new VEShape(VEShapeType.Pushpin, latlon);
				s.SetCustomIcon(customIcon);
				s.SetTitle(name);

				// Plot a Shape at the Clicked location
				large_map.AddShape(s);
			}
         }
