    //<![CDATA[

	// global arrays to hold copies of the markers and html used by the sidebar
	var gmarkers = [];
	var htmls = [];
	var proprefs = [];
	var gpoints = [];

	// global "map" variable
	var map;
	var ROOTURL = "http://www.aldeburghlettings.co.uk/";

    // This function picks up the sidebar click and opens the corresponding info window
    function myclick(i) {
		map.closeInfoWindow();
		map.recenterOrPanToLatLng(gpoints[i]);
		window.setTimeout(function() {
			gmarkers[i].openInfoWindowHtml(htmls[i]);
		}, 1000);
    }
    
    // This function zooms in or out
    // its not necessary to check for out of range zoom numbers, because the API checks
    function myzoom(a) {
      map.zoomTo(map.getZoomLevel() - a);
    }




	function PageQuery(q)
	{
		try
		{
			if(q.length > 1) this.q = q.substring(1, q.length);
			else this.q = null;
			this.keyValuePairs = new Array();
			if(q) {
				for(var i=0; i < this.q.split("&").length; i++) {
					this.keyValuePairs[i] = this.q.split("&")[i];
				}
			}
			this.getKeyValuePairs = function() { return this.keyValuePairs; }
			this.getValue = function(s) {
				for(var j=0; j < this.keyValuePairs.length; j++) {
					if(this.keyValuePairs[j].split("=")[0] == s)
					return this.keyValuePairs[j].split("=")[1];
				}
			return false;
			}
			this.getParameters = function() {
				var a1 = new Array(this.getLength());
				for(var j=0; j < this.keyValuePairs.length; j++) {
					a1[j] = this.keyValuePairs[j].split("=")[0];
				}
				return a1;
			}
			this.getLength = function() { return this.keyValuePairs.length; }
		}
		catch(e)
		{
		
		}
	}

	function queryString(key){
		var page = new PageQuery(window.location.search);
		return unescape(page.getValue(key));
	}

    function onLoad(propref, lat, lon) {
      var sidebar_html = "";
      var i = 0;

		function createMarker(id, point, icon, html) {
			var marker = new GMarker(point, icon);
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(html);
				//populateSources(id);
			});
			gmarkers[i] = marker;
			gpoints[i] = point;
			htmls[i] = html;
			// add a line to the sidebar html
			sidebar_html += '<a href="javascript:myclick(' + i + ')">' + proprefs[i] + '</a><br>';
			i++;
			return marker;
		}
	
		var icons = [];
		icons[0] = new GIcon();
		icons[0].image = "/images/map/house1.png";
		icons[0].iconSize = new GSize(12, 10);
		icons[0].iconAnchor = new GPoint(6, 5);
		icons[0].infoWindowAnchor = new GPoint(6, 1);
		icons[1] = new GIcon();
		icons[1].image = "/images/map/house2.png";
		icons[1].iconSize = new GSize(12, 10);
		icons[1].iconAnchor = new GPoint(6, 5);
		icons[1].infoWindowAnchor = new GPoint(6, 1);
		icons[2] = new GIcon();
		icons[2].image = "/images/map/house3.png";
		icons[2].iconSize = new GSize(12, 10);
		icons[2].iconAnchor = new GPoint(6, 5);
		icons[2].infoWindowAnchor = new GPoint(6, 1);
		icons[3] = new GIcon();
		icons[3].image = "/images/map/house4.png";
		icons[3].iconSize = new GSize(12, 10);
		icons[3].iconAnchor = new GPoint(6, 5);
		icons[3].infoWindowAnchor = new GPoint(6, 1);
		icons[4] = new GIcon();
		icons[4].image = "/images/map/house5.png";
		icons[4].iconSize = new GSize(12, 10);
		icons[4].iconAnchor = new GPoint(6, 5);
		icons[4].infoWindowAnchor = new GPoint(6, 1);

		map = new GMap(document.getElementById("property_mapframe"));
		map.addControl(new GSmallZoomControl());
		//var zoom = queryString('zoom');
		//if (zoom != 'false') {
			map.setCenter(new GLatLng(lat,lon), 11);
		//} else {
		//	map.setCenter(new GLatLng(lat,lon), 11);
		//}
		
		//var mapTypeControl = new GMapTypeControl();
		//var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		//var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		//map.addControl(mapTypeControl, topRight);


		var request = GXmlHttp.create();
		//request.open("GET", ROOTURL + "NCC/includes/map_xml.php", true);
		request.open("GET","/includes/map_xml.php?propref="+propref, true);
		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				var xmlDoc = request.responseXML;
				var markers = xmlDoc.documentElement.getElementsByTagName("marker");
				for (var ii = 0; ii < markers.length; ii++) {
					var point = new GPoint(parseFloat(markers[ii].getAttribute("lng")),
										   parseFloat(markers[ii].getAttribute("lat")));
										   
					
					
					var html = "		"  
								+ "	<table width='200' border='0' cellspacing='2' cellpadding='3' style='min-height: 200px;'>"  
								+"	<tr>"  
								+"		<td colspan='2' style='padding: 0px;'>"  
								+"			<font color='#006633' size='1'><B>" + markers[ii].getAttribute("propname") + "</B></font>"  
								+"			<font size='1'><B> - " + markers[ii].getAttribute("addr1") + "</B></font>"  
								+"		</td>"  
								+"	</tr>"  
								+"	<tr>"  
								//+"		<td rowspan='2' align='center' height='75' style='padding: 0px;' valign='top'>"  
								//+"			<a href='/properties/" + markers[ii].getAttribute("propref") + "'>"  
								//+"				<img src='http://www.aldeburghlettings.co.uk/images/properties/availthumbnails/" + markers[ii].getAttribute("propref") + "_t.jpg' border='0' width='50'>"  
								//+"			</a>"  
								//+"		</td>"  
								//+"		<td style='padding: 0px; font-size: 10px;'>" + markers[ii].getAttribute("desc") + " <a href='http://www.aldeburghlettings.co.uk/cottage-details/" + markers[ii].getAttribute("propref") + "'>More info ></a></td>"  
								+"		<td style='padding: 0px; font-size: 10px;'><a href='http://www.aldeburghlettings.co.uk/cottage-details/" + markers[ii].getAttribute("propref") + "'>More info ></a></td>"  
								+"	</tr>"  
								+"	<tr>"  
								+"		<td style='padding: 0px;'>"  
								+"			<font face='Verdana'>"  
								+"				<strong>Sleeps:</strong> " + markers[ii].getAttribute("sleeps") + " "  
								+"				<br>"  
								+"				<strong> Bedrooms:</strong> " + markers[ii].getAttribute("bedrooms") + "</font>"  
								+"		</td>"  
								+"	</tr>"  
								+"	</table>"  
								+"	";
						var icn = 0;
					
					GEvent.addListener(markers[ii], "click", function() {
						marker.openInfoWindowHtml(html);
					});
					
					switch(markers[ii].getAttribute("area"))
					{
						case "NORWE":
							icn = 0;
							break
						case "EASTC":
							icn = 1;
							break
						case "BROAD":
							icn = 2;
							break
						case "NORMI":
							icn = 3;
							break
						case "W/S":
							icn = 4;
							break
					}
					proprefs[i] = markers[ii].getAttribute("propref");
					var marker = new createMarker(ii + 1, point, icons[icn], html);
					map.addOverlay(marker);
				}
				//document.getElementById("sidebar").innerHTML = sidebar_html;
				var propref = queryString('prop');
				if (propref != 'false') {
					for (var iii = 0; iii < proprefs.length; iii++) {
						if (propref == proprefs[iii]) {
							myclick(iii);
						}
					}
				}
		   	  //document.getElementById("map").innerHTML = '';
			}
		}
		request.send(null);

	}
	
	function loadMainOffice()
	{
		if (GBrowserIsCompatible())
		{
			var map = new GMap2(document.getElementById("contact_mapframe"));
			var officeLoc = new GLatLng(52.1589719, 1.588233);
			map.setCenter(officeLoc, 13);
			
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			
			var marker = new GMarker(officeLoc);

			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml("<div style='font-family: arial;'><strong>Pamela Pask, Aldeburgh Lettings<br />Address:</strong><br />111 Saxmundham Road, Aldeburgh<br />Suffolk. IP15 5JF</div>");
			});

			map.addOverlay(marker);
			

			
		}

	}


    //]]>
