var map;
var localSearch = new GlocalSearch();

function checklocation (point) {

  s = new String(point);
  var bracket1 = "(";
  var bracket2 = ")";
				  
  s = s.replace(")","");
  s = s.replace("(","");
  
  var s_array  = s.split(",");
  
  
  
  //alert(s_array[0]);
  
  //alert(s_array[1]);
  
  //boundary area
  lat1 = 51.39;
  lng1 = -0.39;
  
  lat2 =51.64;
  lng2 =0.11;

 if (s_array[0]>=lat1 && s_array[0]<=lat2 && s_array[1]>=lng1 && s_array[1]<=lng2) { document.updateForm.geocode.value = point; } else { alert("The postcode you have entered is not a London postcode!"); document.updateForm.postcode.value = ""; }
	
	}




function initialize(address) {
	
	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);
				//alert(point);
				checklocation(point);	
				
			}else{
				alert("Postcode not found!");
				document.updateForm.postcode.value = "";
			}
		});	
		
	localSearch.execute(address + ", UK");
}


google.load("maps", "2");
google.load("search", "1");
/*function initialize (address) {
	addressnew = address+" , London, Greater London";
	//alert(address);
	//var address = "<? //print $_GET['georef']; ?>";
	//var eventid = "<? //print $_GET['eventid']; ?>";
	var geocoder = new GClientGeocoder;
	geocoder.getLatLng(addressnew, function(point) {
		if (!point) {
              alert("There was a problem with the postcode you entered, Please re-enter the postcode");
			  document.updateForm.postcode.value = "";
            } else {
			checklocation(point);	
			
		}
	});
}*/

//<![CDATA[
function load() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(51.501423,-0.122137), 13);
  }
}
//]]>

function checkage(age) {
	if(age=='under 16') {
		document.updateForm.author.disabled=true;
	} else {
		document.updateForm.author.disabled=false;
	}
}
