var map = null;
var localSearch = new GlocalSearch();
var icon = new GIcon();
icon.image = "http://www.google.com/mapfiles/marker.png";
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(10, 34);
//This script is based on code from 
//http://www.tomanthony.co.uk/blog/geocoding-uk-postcodes-with-google-map-api/

function FindPostCode(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);
				DisplayMap(point);
			}else{
				alert("Postcode not found!");
			}
		});	
		
	localSearch.execute(postcode + ", UK");
}

 function FindLonLat(resultLat,resultLng) {          
		var point = new GLatLng(resultLat,resultLng);
		DisplayMap(point);
    }

function DisplayMap(point)
{
 if (GBrowserIsCompatible()) { 
  map = new GMap2(document.getElementById("map"));
  map.setCenter(point, 16);
  var marker = new GMarker(point,icon);
  map.addOverlay(marker);
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  }
}




