var map;
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);

function usePointFromPostcode(postcode) {
	
	if (postcode=="")
	{
		document.getElementById('OuterMap').style.display="none";
	}
	else
	{
	    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);
		        placeMarkerAtPoint(point);
		    } else {
		        document.getElementById('OuterMap').style.display = "none";
		    }
		});	
			
		localSearch.execute(postcode + ", UK");
	}
}

function placeMarkerAtPoint(point)
{
	var marker = new GMarker(point,icon);
	if (map) map.setCenter(point, 11);
	
	if (map) map.addOverlay(marker);
}

function setCenterToPoint(point)
{
	if (map) map.setCenter(point, 13);
}

function showPointLatLng(point)
{
	alert("Latitude: " + point.lat() + "\nLongitude: " + point.lng());
}
