	function initialize(){
      if (GBrowserIsCompatible()) {
	  
	  	disableSubmit('go');
	    hideDiv('submitter');
		//setup(); // initialize slider
		
		//hideDiv('map_canvas');
			
         }else{
	  alert ('Your browser is not compatible with the Google Geocoding service. Please upgrade your browser. The latest version of Firefox will meet the requirements.');
	  stop;
    	       }
	    }; // end script initialize
		
	function enableSubmit(buttonId){
	var submitButton = document.getElementById(buttonId);
		submitButton.disabled=false;
	}
	
	function disableSubmit(buttonId){
	var submitButton = document.getElementById(buttonId);
		submitButton.disabled=true;
	}

	function showDiv(divId){
	var showDiv = document.getElementById(divId);
		document.getElementById(divId).style.visibility="visible";
	}
	function hideDiv(divId){
	var showDiv = document.getElementById(divId);
		document.getElementById(divId).style.visibility="hidden";
	}
	// next function was moved to receiver.php, but left here for reference
    function littleMap(divTarget,lat,long,magnification){
	var map = new GMap2(document.getElementById(divTarget));
        map.setCenter(new GLatLng(lat, long), magnification);
	}




function fGeocode(){
	var myWindow;
	var address='';
	var line1='';
	var line3='';
	
    var map = null;
    var geocoder = null;
	var lat = 0.00;
	var long =0.00 ;
	var magnification = 2;
	var foundMagnification = 13;
	var latitudeTextbox = document.getElementById("lat");
    var longitudeTextbox = document.getElementById("long");
	latitudeTextbox.value = ''; // make sure there is nothing in there
    longitudeTextbox.value = '';
	
	
	map = new GMap2(document.getElementById("map_canvas"));
    geocoder = new GClientGeocoder();
	geocoder.setBaseCountryCode('UK');

	line1=document.getElementById('addressLine1').value;
	if(line1.length>0)address+=line1;

	line3=document.getElementById('city').value;
	if(line3.length>0){
		if(address.length>0) address+=', ';
		address+=line3;
		}

      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {

              alert(address + " not found. Try just the Town or City followed by a comma and UK. (" + line3 + ", UK"  + ") You will be able to pan and zoom the map at the next stage to find the exact location");
            } else {//alert(address + " successfully geocoded");
              map.setCenter(point, foundMagnification);
			  map.setMapType(G_HYBRID_MAP);				// rac added
              var marker = new GMarker(point, {draggable: true}); // made draggable rac
			  map.addControl(new GLargeMapControl());
	          map.addControl(new GMapTypeControl());
              map.addOverlay(marker);
              marker.openInfoWindowHtml("Click and drag<br /> this marker until it is<br /> in the correct place<br />");
			  var newLat  = marker.getPoint().lat().toFixed(6);
			  var newLong = marker.getPoint().lng().toFixed(6);
			  latitudeTextbox.value = newLat; // sets lat long first time through
              longitudeTextbox.value = newLong;

			  enableSubmit("go");
	    	  showDiv('submitter');
			  //toggle();

			  GEvent.addListener(marker, "dragstart", function() {
        	  map.closeInfoWindow();
        	   }); // end dragstart listener
				
			  GEvent.addListener(marker, "dragend", function() {        // dragend listener that converts drop points to lat long values
		                                                                  // and writes them into textboxes so the user can see them (in form)
			  var newLat  = marker.getPoint().lat().toFixed(6);
			  var newLong = marker.getPoint().lng().toFixed(6);
			  //console.log(newLat);
			 //console.log(newLong);
              latitudeTextbox = document.getElementById("lat");
              longitudeTextbox = document.getElementById("long");
    
              latitudeTextbox.value = newLat;
              longitudeTextbox.value = newLong;

			  map.panTo(new GLatLng(newLat, newLong));
				                                                        // tell the user by opening an info window
		 	  marker.openInfoWindowHtml("position updated,<br />when you are satisfied the marker is<br /> in the correct location<br /> click Submit");
			  map.panTo(new GLatLng(newLat, newLong));               // centre on the new location
        	  }); // end dragend listener


            }
          }
        );
      } // end if(geocoder) 
    //}

}; // end fGeocode function

