	var map;
	
	// Set these variables to change beginning map location
//	var beginLatitude = 44.97;
//	var beginLongitude = -93.3;
	var beginZoom = 6;
	// Url for accessing data from database
	// var pinServiceUrl = "returnresults.php";
	var pinServiceUrl = "/xjournal/getbingpos.php";
	var pinid = 0;

	function OnPageLoad() {
		map = new VEMap('myMap');
		// map.LoadMap();
		map.LoadMap(new VELatLong(beginLatitude, beginLongitude), beginZoom, 'h', false);
	//	alert("load");
		LoadPushPins();
	}
  
  
 	// Load the current map with push pins
	function LoadPushPins() {
		view = map.GetMapView();
		topleft = view.TopLeftLatLong;
		bottomright = view.BottomRightLatLong;
		
		$.getJSON(pinServiceUrl, { tlLat: topleft.Latitude, tlLong: topleft.Longitude, brLat: bottomright.Latitude , brLong: bottomright.Longitude}, GetPinsCallback);
	}
	
	// Call back from JSON getPins command.  Parse JSON response and adds pins to map.
	function GetPinsCallback(jsonData) {
		var desc = "";
		map.ClearInfoBoxStyles();
		map.Clear();
		$.each(jsonData, function(i, item) {
			if(item.latitude != null && item.longitude != null) {
				desc = item.plotTime + "<br>" + item.location + "<br><a href='http://www.x-journal.com'>XJournal</a>"
				AddPushpin(item.title, desc, new VELatLong(item.latitude, item.longitude),item.mapboxHTML);
			}
		});
	}
	
	// Add Pushpin at desired latitude & longitude
	// Title - Title of Pushpin
	// Description - Description to set on Pushpin
	// latLon - VELatLong object of location to set PushPin
	function AddPushpin(title, description, latLon, mapboxHTML) {
		var shape = new VEShape(VEShapeType.Pushpin, latLon);
		// shape.SetTitle(title);
		// shape.SetPhotoURL("http://www.x-journal.com/journal/ericlars/images/" + pic);
		
		shape.SetDescription(mapboxHTML);
		
		var icon = "http://www.x-journal.com/xj_files/images/xjge_pushpin24.png";
		shape.SetCustomIcon(icon);

		pinid++;
		
		map.AddShape(shape);
	}
  