	//<![CDATA[

	//AG: Aug 2008
	//Google maps js interface without automatic null co-ordinate resolution

	function checkPostcode(postcode)
	{
		localSearch.setSearchCompleteCallback(null, 
		function() {
			if (localSearch.results[0])
			{		
				var resultLat = localSearch.results[0].lat;
				var resultLng = localSearch.results[0].lng;
				var point = new GLatLng(resultLat,resultLng);
				var data = [];
				map.setCenter(new GLatLng(resultLat, resultLng), zoom);
			} 
			else alert("Search term not found!");
		});	
		localSearch.execute(postcode + ", UK");
	}
	
	
	function setupMap()
	{
		map.setCenter(new GLatLng(map_y, map_x), zoom);
		map.setMapType(G_NORMAL_MAP);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());		
	}

	function addMarkerCenter()
	{
		var mapCenter = map.getCenter();
		mgr.clearMarkers();
		var maplng = mapCenter.lng();
		var maplat = mapCenter.lat(); 
		maplng = maplng.toFloat();
		maplat = maplat.toFloat();
		addMarker(maplng, maplat);
		updateForm(maplng.toFixed(6), maplat.toFixed(6));
	}
	
	function addMarker(x, y, postcode, item_id)
	{
		azureIcon = new GIcon(G_DEFAULT_ICON);
		markerOptions = { icon:azureIcon, draggable: true };
		//
		var posn = new GLatLng(y, x);
		var newMarker = new GMarker(posn, markerOptions);
		//								
		GEvent.addListener(newMarker, "dragend", function() {
			point = newMarker.getPoint();
			updateForm(point.lng().toFixed(6), point.lat().toFixed(6));
		});
		GEvent.addListener(newMarker, "drag", function() {
			point = newMarker.getPoint();
		});
		mgr.addMarker(newMarker, 1);
		mgr.refresh();	
	}
	
	function addMarkerStatic(x, y, postcode, item_id)
	{
		azureIcon = new GIcon(G_DEFAULT_ICON);
		markerOptions = { icon:azureIcon, draggable: false, title: item_id };
		var posn = new GLatLng(y, x);
		//
		var newMarker = new GMarker(posn, markerOptions);								
		mgr.addMarker(newMarker, 1);
		mgr.refresh();	
	}
	
	function addMarkerStaticU(x, y, postcode, item_id)
	{
		azureIcon = new GIcon(G_DEFAULT_ICON);
		azureIcon.image = "http://www.sunderlandaccommodationservice.co.uk/cms/images/uni_marker.png";
		azureIcon.shadow = "http://www.sunderlandaccommodationservice.co.uk/cms/images/uni-shadow.png";
		azureIcon.iconSize = new GSize(40, 36);
		azureIcon.shadowSize = new GSize(59, 36);		
		azureIcon.iconAnchor = new GPoint(20, 25);
		azureIcon.maxHeight = 25;
		azureIcon.imageMap = new Array(0,0, 40,0, 40,36, 0,36);
		markerOptions = { icon:azureIcon, draggable: false, title: item_id };
		//
		var posn = new GLatLng(y, x);
		var newMarker = new GMarker(posn, markerOptions);
		mgr.addMarker(newMarker, 1);
		mgr.refresh();	
	}
	
	function updateForm(x, y)
	{
		document.getElementById("map_x").value = x;
		document.getElementById("map_y").value = y;		
	}
	


