// JavaScript Document


    //<![CDATA[
			   
    	var map;
    	var markers = [];
			var startingWith = '';
			var gridN = '';
			var gridE = '';
			var county = '';

		function loadMap() {

			if (GBrowserIsCompatible()) {
				// Initialize the map.
				map = new GMap2(document.getElementById("map"));
				map.addControl(new GLargeMapControl());
				map.setCenter(new GLatLng(54.265,-3.603), 5);

				var lookupPath = "http://www.ultraframe-conservatories.co.uk/Scripts/ConservatoryMarkers.php";
				if ((gridN != '') && (gridE != '')) {
					lookupPath += "?GridN=" + gridN + "&GridE=" + gridE;
				}
				else if (county != '') {
					lookupPath += "?County=" + county;
				}
				else if (startingWith != '') {
					lookupPath += "?StartingWith=" + startingWith;
				}
				$.ajax({type:"GET",url:lookupPath,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();
			}
			
		});
   //]]>

