var map = null;
var geocoder = null;

function initialize() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_target"));
	map.setCenter(new GLatLng(40.541026, -79.785328), 13);
	geocoder = new GClientGeocoder();
  }
}

function get() {

	var address = "";

	if (document.getElementById('DeliveryLocation_StreetAddress').value != '' || document.getElementById('DeliveryLocation_ZipCode').value != ''){
	
		address += document.getElementById('DeliveryLocation_StreetAddress').value + ',';
		address += document.getElementById('DeliveryLocation_ZipCode').value;
		
		if (geocoder) {
			geocoder.getLatLng(
				address,
				function(point) {
				if (!point) {
				  alert(address + " not found");
				} else {
				  map.setCenter(point, 15);
				  var marker = new GMarker(point);
				  map.addOverlay(marker);
				  
				  var poststr = encodeURI('start=40.541026, -79.785328') + '&end=' + encodeURI(point);
				
				  new Ajax.Updater('distance', 'gmaps_include.php', { method: 'get', parameters: poststr } );
				  
				}
			  }
			);
		  }
	}
	else{
	
		alert("You must enter a valid Address and Zipcode to continue.");
	
	}

}


