var map;
var markers = [];

$(document).ready(function() {
	if (GBrowserIsCompatible()) {
		// Initialize the map.
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.setCenter(new GLatLng(35.8782538719004,-97.45988845825195), 7);

		$.ajax({type:"GET",url:"markers.xml",dataType:"xml",

			success:function(data,textStatus) {
				$("marker",data).each(function() {
					// Attributes for each marker.
           			var lat = parseFloat($(this).attr("lat"));
           			var lng = parseFloat($(this).attr("lng"));
           			var point = new GLatLng(lat,lng);
           			var html = $("html",this).text();

           			// Create the marker.
           			var marker = new GMarker(point);
	            			
			        GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowHtml(html);
			        });

           			map.addOverlay(marker);
				});
			},

			error:function(XMLHTTPRequest,textStatus,errorThrow){
				alert("There was an error retrieving the marker information.");
			}});
	}
});
		
$(document.body).unload(function() {
	if (GBrowserIsCompatible()) {
		GUnload();
	}
});