	//Map Specific
	var map;
	map = new GMap2(document.getElementById("map"));
	var icon = new GIcon();
	var iconView = new GIcon();
	var iconSold = new GIcon();
	var iconBranch = new GIcon();
	var strForm = "";


	//Site Specific
	var ran_unrounded=Math.random()*2;
	var ran_number=Math.round(ran_unrounded);
	var arrLng= new Array;
	var arrLat= new Array;

	arrLng[0] = -2.229845;
	arrLat[0] = 53.011178;	//Newcastle under Lyme
	arrLng[1] = -2.483945;
	arrLat[1] = 52.904310; //Market Drayton

	var propLink = "/follwe/property.asp?propertyID=";
	var intLng = arrLng[ran_number];
	var intLat = arrLat[ran_number];

	//var currLocation = map.getCenter();
	var currLocationLng = arrLng[ran_number];
	var currLocationLat = arrLat[ran_number];
	var currZoomLevel = map.getZoom();

	var currLocation = map.setCenter(new GLatLng(intLat, intLng), 13);

	document.getElementById('mLocation').selectedIndex = ran_number;
	
	function showProp(propID) {
		document.getElementById('property').style.display = "block";
		document.getElementById('propLink').innerHTML = '<a href="Javascript:propertyDetails('+propID+');">&nbsp;&nbsp;&nbsp;View Full Details</a>';
		document.getElementById('propframe').src = propLink + propID;
	}

	function markAsViewed(mapMarker, propID, point) {
		map.removeOverlay (mapMarker);
		var mapMarkerNew = new GMarker(point, iconView, 0);
		map.addOverlay(mapMarkerNew);
		GEvent.addListener(mapMarkerNew, "click",
			function() {
				showProp(propID);
			}
		);
		return;
	}
	
	function addMarker(point, propID, status) {
		if (status == 3 || status == 2)
		{
			var mapMarker = new GMarker(point, iconSold, 0);
		}
		else
		{
			var mapMarker = new GMarker(point, icon, 0);
		}
		map.addOverlay(mapMarker);
		GEvent.addListener(mapMarker, "click",
			function() {
				markAsViewed(mapMarker, propID, point);
				showProp(propID);
			}
		);
		return;
	}

	
	function getData(intLng, intLat, strTicks) {
		currLocationLng = intLng;
		currLocationLat = intLat;
		currZoomLevel = map.getZoom();

		document.getElementById('loading').style.display = "block";
		document.getElementById('loaded').style.display = "none";
		document.getElementById('property').style.display = "none";

		var request = GXmlHttp.create();
		var file = 'getData.asp?lng='+intLng+'&lat='+intLat+'&ticks='+strTicks+strForm;

		request.open("GET", file, true);
		request.onreadystatechange = function() {
		  if (request.readyState == 4) {
			var xmlDoc = request.responseXML;
			var xmlData = xmlDoc.documentElement.getElementsByTagName("marker");

			document.getElementById('loading').style.display = "none";
			document.getElementById('loaded').style.display = "block";

			if (xmlData.length > 250)
			{
				document.getElementById('loaded').innerHTML = "Too many properties to display please change criteria";
			}
			else
			{
				document.getElementById('loaded').innerHTML = "Properties Loaded";
				map.clearOverlays();

				for (var i = 0; i < xmlData.length; i++) {
				  var point = new GPoint(parseFloat(xmlData[i].getAttribute("lng")),
										 parseFloat(xmlData[i].getAttribute("lat")));
				  var propID = parseFloat(xmlData[i].getAttribute("propID"));
				  var status = parseFloat(xmlData[i].getAttribute("status"));
				  addMarker(point, propID, status);
				}
			}
		  }
		}
		request.send(null);
	}

	function eventMoveStart() {
	}

	function eventMoveEnd() {
		var strTicks = map.getBounds();
		var center = map.getCenter();
		var zoom = map.getZoom()

		intZoomDiff = (currZoomLevel - zoom);
		intMovementX = Math.abs(center.lng() - currLocationLng);
		intMovementY = Math.abs(center.lat() - currLocationLat);

		if (intMovementX >= 0.03 || intMovementY >= 0.03)
		{
			getData(center.lng(), center.lat(), strTicks);
		}

		if (intZoomDiff <= -1)
		{
			getData(center.lng(), center.lat(), strTicks);
		}
	}

	function generateMap()
	{		
		icon.image = "_gfx/marker.gif";
		//icon.shadow = "_gfx/marker_shadow.png";
		icon.iconSize = new GSize(15, 15);
		//icon.shadowSize = new GSize(45, 37);
		icon.iconAnchor = new GPoint(7, 15);
		//icon.infoWindowAnchor = new GPoint(23, 10);

		iconView.image = "_gfx/marker_viewed.gif";
		//iconView.shadow = "_gfx/marker_shadow.png";
		iconView.iconSize = new GSize(15, 15);
		//iconView.shadowSize = new GSize(45, 37);
		iconView.iconAnchor = new GPoint(7, 15);
		//iconView.infoWindowAnchor = new GPoint(23, 10);

		iconBranch.image = "_gfx/marker_branch.gif";
		//iconBranch.shadow = "_gfx/marker_shadow.png";
		iconBranch.iconSize = new GSize(35, 35);
		//iconBranch.shadowSize = new GSize(45, 37);
		iconBranch.iconAnchor = new GPoint(18, 35);
		//iconBranch.infoWindowAnchor = new GPoint(23, 10);

		iconSold.image = "_gfx/marker_sold.gif";
		//iconSold.shadow = "/map/_gfx/marker_shadow.png";
		iconSold.iconSize = new GSize(15, 15);
		//iconSold.shadowSize = new GSize(45, 37);
		iconSold.iconAnchor = new GPoint(7, 15);
		//iconSold.infoWindowAnchor = new GPoint(23, 10);

		map.addControl(new GLargeMapControl());
		//map.addControl(new GMapTypeControl());

		var strTicks = map.getBounds();

		GEvent.addListener(map, "movestart", eventMoveStart);
		GEvent.addListener(map, "moveend", eventMoveEnd);
		
		getData(intLng, intLat, strTicks);
	}

generateMap();