	var map;
	var walkmap;
	var gdir;
	var geocoder = null;
	var addressMarker;
	var from = "Davis, CA" ;//"I-80 W@38.530794,-121.75063" ;
	var to = "Parking lot@38.534286,-121.7567" ;
	var locale = "en_US" ;
	//<![CDATA[
    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress,{ "locale": locale });
    }
	function updateDirections()
	{
		var el = document.getElementById('from');
		from = el.value ;
		setDirections( from, to, locale );
	}
	function load()
	{
	  if( GBrowserIsCompatible() )
	  {
		map = new GMap2( document.getElementById( "map" ) ) ;
		map.setCenter( new GLatLng( 38.533648, -121.754115 ), 16 ) ;
		//alert( map.getCurrentMapType() ) ;
		map.addControl( new GSmallMapControl() ) ;
		map.addControl( new GMapTypeControl() ) ;
		//map.addControl(new GOverviewMapControl());
		map.setMapType( G_HYBRID_MAP ) ;
		
		gdir = new GDirections( map, document.getElementById( "directions" ) ) ;
		GEvent.addListener( gdir, "load", onGDirectionsLoad ) ;
		GEvent.addListener( gdir, "error", handleErrors ) ;

		setDirections( from, to, locale);
		
		walkmap = new GMap2( document.getElementById( "walkmap" ) ) ;
		walkmap.setCenter( new GLatLng( 38.5357,-121.755 ), 16 ) ;
		walkmap.setMapType( G_HYBRID_MAP ) ;
		var polyline =
			new GPolyline(
				[
					new GLatLng( 38.5347,-121.7565 ) ,
					new GLatLng( 38.5347,-121.7554 ) ,
					new GLatLng( 38.535813,-121.75535 ) ,
					new GLatLng( 38.5372,-121.75575 ) ,
					new GLatLng( 38.5374,-121.7546 ) ,
					new GLatLng( 38.5372,-121.7546 ) ,
				], "#0000ff", 7
			);
		walkmap.addOverlay(polyline);

		walkmap.addControl( new GSmallMapControl() ) ;
		walkmap.addControl( new GMapTypeControl() ) ;
		walkmap.addControl(new GOverviewMapControl());

var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 34);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

		var Marker = function( point, info, image )
		{
			var point = point ;
			var icon = new GIcon( baseIcon ) ;
			icon.image = image ;
			var marker = new GMarker( point, icon ) ;
			marker.info = info ;
			marker.showInfo = function()
			{
				this.openInfoWindowHtml( this.info ) ;
			}
			GEvent.addListener( marker, "click", function() {
				marker.showInfo() ;
			});
			walkmap.addOverlay( marker ) ;
			return marker ;
		}
		new Marker( new GLatLng( 38.5347,-121.7565 ), "Parking", "http://www.google.com/intl/en_us/mapfiles/dd-start.png" ) ;
		var kemper = new Marker( new GLatLng( 38.5372,-121.7546 ), "Kemper Hall", "http://www.google.com/intl/en_us/mapfiles/dd-end.png" ) ;
		kemper.showInfo() ;

// Directions
// http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=I-80+W+%4038.530420,+-121.750670&daddr=38.534269,-121.756389+to:Bainer+Hall+Dr+%4038.536420,+-121.754770&mrcr=0,1&mrsp=1&sz=16&mra=dpe&sll=38.533195,-121.751432&sspn=0.015459,0.017896&ie=UTF8&ll=38.533396,-121.751432&spn=0.015056,0.017896&t=h&z=16&om=1&pw=2
	}
    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
	}

	function onGDirectionsLoad(){ 
          // Use this function to access information about the latest load()
          // results.

          // e.g.
	  // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}

	}
	//]]>
