
  var localSearch = new GlocalSearch();
  var map = null;
    var geocoder = null;

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(51.4612,-0.9259), 5);
        geocoder = new GClientGeocoder();  
        map.addControl(new GLargeMapControl());
      	map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl());
      }
    }
    
    function ukpostcode(q){ 
    	usePointFromPostcode(q);
    }
	
	function otherpostcode(q){
    	otherPostcode(q);
    }
    
 

function usePointFromPostcode(postcode) {
  
  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);

 		
 		//var pos_array=page_request.responseText.split(",");
		var map = new GMap2(document.getElementById("map"));
     

		// Create our "tiny" marker icon
		var icon = new GIcon();
		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);
//alert(pos_array[0]);
//alert(point.lng())
	   	map.setCenter(new GLatLng(point.lat(),point.lng()), 12);
		var point = new GLatLng(point.lat(),point.lng());
		map.addOverlay(new GMarker(point, icon));
		
		//var marker = new GMarker(point);
        	//map.addOverlay(marker);
       		 //marker.openInfoWindowHtml(q);
		
		//map.addControl(new GLargeMapControl());
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
      	//map.addControl(new GMapTypeControl());
		//map.addControl(new GScaleControl());
		//map.addControl(new GOverviewMapControl,
        	//new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 10)));

 	   ;
       
      }else{
        
        document.getElementById("map").innerHTML = 'The postcode for this address has not been found and failed to return a map.'
      
      }
    });  
   
  localSearch.execute(postcode + ", UK");
}

   function initializeUS(p) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
	    //map.addControl(new GLargeMapControl());
      	map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl())
		USpostcode(p)
      }
    }
   
   
   function initializeAUS(p) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(-24.994167,134.866944), 5); 
        geocoder = new GClientGeocoder();

		//AUSpostcode(p)
      }
    }
	
function initializeSAF(p) {
      if (GBrowserIsCompatible()) {
        //map = new GMap2(document.getElementById("map"));
      // map.setCenter(new GLatLng(-28.883160,25.312500), 4); 
       // geocoder = new GClientGeocoder();
		
		
		map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
	    //map.addControl(new GLargeMapControl());
      	map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl())
		

		SAFAddress(p)
      }
    }
	

  

    function USpostcode(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              document.getElementById("map").innerHTML = 'The postcode for this address has not been found and failed to return a map.'
            } else {
              map.setCenter(point, 6);
              var marker = new GMarker(point);
             map.addOverlay(marker);
             // marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
	
	
	
	function SAFAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
			map.setCenter(new GLatLng(-28.883160,25.312500), 7); 
            //  document.getElementById("map").innerHTML = 'The postcode for this address has not been found and failed to return a map.'
            } else {
              map.setCenter(point, 5);
              var marker = new GMarker(point);
             map.addOverlay(marker);
             // marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
	
	
	//function showAddress(address) 
	//{  geocoder.getLatLng(    address,    
	//function(point) 
	//{      if (!point) {        alert(address + " not found");      
	//} else 
	//{        map.setCenter(point, 13);       
	//var marker = new GMarker(point);        
	//map.addOverlay(marker);       
	// marker.openInfoWindowHtml(address);      
	 //}    
	 //}  
	 //)/;}
	
	


