//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,callbackFunction) {
	
	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);
				callbackFunction(point);
			}else{
				var lat = document.getElementById('lat');
				var lng = document.getElementById('lng');

				lat.value = 'not found';
				lng.value = 'not found';
				document.getElementById('form').submit();
			}
		});	
		
	localSearch.execute(postcode + ", UK");
}

function setLatLng(point) {
// set DOM’s group_lat, group_lng to the correct lat/lng
var lat = document.getElementById('lat');
var lng = document.getElementById('lng');

lat.value = point.lat();
lng.value = point.lng();

document.getElementById('form').submit();
}

