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 getLocations(url) {
	var postcode = $("#search_store").val();
	
	var redirect = url;
			var linkerror = redirect + '?q=error&lat=54.6&long=-4.0';
			
		if (postcode != '' && postcode !='Enter town or postcode'){
	
	localSearch.setSearchCompleteCallback(null, 
		function() {
			
			if (localSearch.results[0])
			{		
				var resultLat = localSearch.results[0].lat;
				var resultLng = localSearch.results[0].lng;
				
				 var link = redirect + '?q=' + postcode + '&lat=' + resultLat + '&long=' + resultLng;
									  location.href = link;
				
				//var point = new GLatLng(resultLat,resultLng);
				
			}else{
			window.location = linkerror;
				
			}
		});	
		
	localSearch.execute(postcode + ", UK");
	}
}






/*
  <input type="submit" value="Do whatever" onclick="javascript:
  usePointFromPostcode(document.getElementById('postcode').value,
    function (point) {
      alert('Latitude: ' + point.lat() + '\nLongitude: ' + point.lng());
      })" />
	  
*/




