﻿<!--		var geocoder = null;		var dir_index = 10; // 10 means out of range		var formPtr = null;		var fieldPtr = null;		function initializeGeocoder() {			if (GBrowserIsCompatible()) {				geocoder = new GClientGeocoder();			}		} // EOF				// geocodeDirectionsAddress() is called when you click on the Get		// Directions button in a marker. It geocodes the address and submits		// form to directions.php.		function geocodeDirectionsAddress() {			formPtr =  document.forms['getDirections'];			fieldPtr =  formPtr.startAddr;			var address = fieldPtr.value; // Take the value			geocoder.getLocations(address, getAddrForDirections); // Send data to Google, process response		} // EOF		// getAddrForDirections() is called when the geocoder returns an answer		// after user tries to geocode an address for proximity searches		function getAddrForDirections(response) {			var userMsg = geocodeTest(response,6);			if(userMsg) {				alert(userMsg);			} else {								//  ******************************************				//  ***** This is what we want to get to *****				//  ******************************************				var place = response.Placemark[0].AddressDetails;				var accuracy = place.Accuracy;				var country = place.Country.CountryNameCode;				var points = response.Placemark[0].Point.coordinates;				// Set scrubbed address				var clean_address = response.Placemark[0].address;				if(country == 'US') {					clean_address = clean_address.replace(", USA", "");				} else {					clean_address = clean_address.replace(", Canada", "");				}				fieldPtr.value = clean_address;				// Submit and continue				formPtr.submit();				//  ******************************************				//  ******************************************				//  ******************************************			} // End if we could run this		} // EOF		// geocodeTest() is called by a few functions to see if		// lat & lon accuracy meet a certain threshold		function geocodeTest(response, accuracy_level) {			var userMsg = "";			if (!response || response.Status.code != 200) { // Error				userMsg = "Sorry, we were unable to geocode that address.\n";				userMsg += "Please try another address.";					} else { // We got something							var place = response.Placemark[0].AddressDetails;				var accuracy = place.Accuracy;				if(accuracy >= accuracy_level) { // 4 = town level accuracy, 6 = street level accuracy					var country = place.Country.CountryNameCode;					if((country != 'US') && (country != 'CA')) {						userMsg = "Sorry, your starting point must be in the United\n";						userMsg += "States or Canada.";					} // End if we have the right country (US & Canada)				} else { // Not accurate enough					userMsg = "Sorry, we were unable to geocode that address\n";					userMsg += "to a necessary level of accuracy. Please try\n";					userMsg += "another address.";								} // End if accurate enough			}// End if we had a 200 level response			return userMsg;		} // EOF-->