var geocoder = null;

function load() {
  if (GBrowserIsCompatible()) {
	geocoder = new GClientGeocoder();
  }
}

function geocode(form,popup) {
  if (geocoder) {
	geocoder.getLatLng(
	  form.address1.value + ", " + form.city.value + ", " + form.zip.value + ", " + form.state.value,
	  function(point) {
		if (!point) {
		  alert("Address could not be found ! \nPlease refine the address or try using the coordinates...");
		  geocoding = false;
		  return false;
		} else {
		  form.decimalLat.value = point.lat();
		  form.decimalLong.value = point.lng();
  		  if (popup==0) form.submit();
 		  else {
			  xr = point.lng() - 0.005;
			  xl = point.lng() + 0.005;
			  yt = point.lat() + 0.005;
			  yb = point.lat() - 0.005;
			  window.open("http://www.epa.gov/myenv/MYENVIEW.results2?minx=" + xr + "&maxy=" + yt + "&maxx=" + xl + "&miny=" + yb,"EnviroWindow","");
		  }		  
		  return true;
		}
	  }
	);
  }
}