

if (GBrowserIsCompatible()) 
{
	var gmarkers = [];
	var i = 0;
	var markers = [];
	var results = 0;
	var icon = "";

	var map = new GMap2(document.getElementById("map_canvas"));
	map.enableScrollWheelZoom();
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(53, -2), 6);
	var bounds = new GLatLngBounds();
	
	icon = new GIcon();
	icon.image = "/files/images/mop_marker.png";
	icon.shadow = "/files/images/mop_marker_shadow.png";
	icon.iconSize = new GSize(32, 32);
	icon.shadowSize = new GSize(59, 32);
	icon.iconAnchor = new GPoint(23, 35);
	icon.infoWindowAnchor = new GPoint(20, 5);
	
	$.ajax({type:"GET",url:"/files/ajax/get_locations.php",dataType:"xml", success:function(data,textStatus) 
	{
		$("marker",data).each(function() 
		{
			var lat = parseFloat($(this).attr("lat"));
			var lng = parseFloat($(this).attr("lng"));
			var point = new GLatLng(lat,lng);
			
			if ( $("description",this).text().length > 0 )
			{
				var marker = createMarker(point, $("location_id",this).text(), $("location_name",this).text(), $("location_name",this).text(),  $("description",this).text(),  $("priority",this).text());
			} else {
			
				var marker = createTabbedMarker(point, $("location_id",this).text(), $("location_name",this).text(),  $("location_name",this).text(),  $("address",this).text(), $("downloads",this).text(), $("activities",this).text(), $("packages",this).text(), $("priority",this).text());
			}
			
			if ( $("priority",this).text() == '1') {bounds.extend(point);}   
			
			map.addOverlay(marker);
		});
		
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter());
		
		pri_loc_list += '<li class="clear">&nbsp;</li>';
		sec_loc_list += '<li class="clear">&nbsp;</li>';
		
		$("#pri_locations_list").html(pri_loc_list);
		$("#sec_locations_list").html(sec_loc_list);
		
		GEvent.addListener(map,"infowindowclose", function() 
		{
			$("#"+lastlinkid).removeClass("highlight_yellow");
		});
		
		$('.map_act_list_items').hover(function()
		{ 	
			clear_markers();
			$(this).addClass("selected");
			activity_id = $(this).attr('ref');
			get_activity_locations(activity_id);
			en_hover = true;
			return false;
		},
		function () // hover out	
		{ 
			if (en_hover){clear_markers();}
		});
		
		$('.map_act_list_items').click(function()
		{ 	
			/*clear_markers();
			$(this).addClass("selected");
			activity_id = $(this).attr('ref');
			get_activity_locations(activity_id);
			en_hover = false;*/
			return false;
		});
			
		if (set_activity !== 0)
		{
			$('a.map_act_list_items[ref='+set_activity+']').addClass('selected');
			get_activity_locations(set_activity);
			en_hover = true;
		}
		
		if (set_location !== 0)
		{
			clear_markers();
			for ( var x=0, len1=marker_id.length; x<len1; ++x )
			{
				if (marker_id[x] == set_location) { GEvent.trigger(gmarkers[x], "click"); }
			}
		}
	
	},
		error:function(XMLHTTPRequest,textStatus,errorThrow)
		{
			alert("There was an error retrieving the marker information.");
		}
	});
	
	
	
	
	

} else {// if browser comp
  alert("Sorry, Google Maps is not compatible with this browser");
}
