
var LLat;
var LLong;

//var localSearch;
var myOptions;
var pcode;
var  localSearch;

function get_pcode() {

//if( (document.getElementById("postcode").value != 'Enter Postcode') && (document.getElementById("postcode").value != '')) {
pcode=document.getElementById("postcode").value;
pcode = pcode.replace(' ','');
if((pcode.toUpperCase().match(/GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[0-9][ABD-HJLNP-UW-Z]{2}/))){



localSearch = new GlocalSearch();
showPointLatLng = '';
usePointFromPostcode1 (pcode,showPointLatLng);
}else { alert("Postcode not found!"); }

}

function usePointFromPostcode1(postcode, callbackFunction) {
 localSearch = new GlocalSearch();
  
  localSearch.setSearchCompleteCallback(null,
    function() {
      if (localSearch.results[0]) {    
        var resultLat = localSearch.results[0].lat;
        var resultLng = localSearch.results[0].lng;

//alert(resultLat+','+resultLng);
document.getElementById("geo").value=resultLat+","+resultLng;
document.nearestclub.submit();
//       var point = new GLatLng(resultLat,resultLng);
//       callbackFunction(point);

      }else{
        alert("Postcode not found!");
      }
    });  

  localSearch.execute(postcode + ", UK");

}
