var hhAddress = '1501 East Ave, Rochester, NY 14610';
var map = null;
var route = null;
var directions = null;
var geocoder = null;
var marker = null;

function initialize_map() {
	map = new GMap2(document.getElementById('map_canvas'));
	route = document.getElementById('route');
	directions = new GDirections(map, route);
	geocoder = new GClientGeocoder();
	showAddress(hhAddress);
}

function showAddress(address) {
	if (geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					map.setCenter(point, 13);
					marker = new GMarker(point);
					map.addOverlay(marker);
					marker.openInfoWindowHtml(address);
				}
			}
		);
	}
}

function searchDirections() {
	map.removeOverlay(marker);
	var fromAddress = document.getElementById('from').value;
	directions.load("from: "+fromAddress+" to: "+hhAddress);
}
