﻿////////////////////////////////////////
// Functions to centre map from postcode
////////////////////////////////////////
var localSearch = new GlocalSearch();

function showGMap(point) {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        if (point != null){
            map.setCenter(point, 15);
            map.addOverlay(new GMarker(point));
        }
    }
}

function initGMap(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{
        /*alert("Postcode Not Found!");
        commented this out due to making postcode 
        an optional field for overseas employers
        #D2228 - JWM (14/12/09)
        */
        document.getElementById('mapHeader').style.display='none';
      }
    });  
  localSearch.execute(postcode + ", UK");
}
