//<![CDATA[	
	$(document).ready(function(){
		$('#getDir').click(function(){
			if($('#startLocation').val().replace(/\s+/g,"").length == 0){
				alert('Please enter startig address!');
				$('#startLocation').focus();
			}
			else{
				fromAddress = $('#startLocation').val();
				gdir.load('from: ' + fromAddress + ' to: 35 Park Place, Waterbury, CT 06702', { 'locale' : 'en_US'  });
			}
		});
		
		var map1 = new google.maps.Map2($('#map1')[0]);
		
		geocoder = new GClientGeocoder();
		
		if (geocoder) {
			geocoder.getLatLng(
				'35 Park Place, Waterbury, CT 06702',
				function(point) {
					if (!point) { alert(address + " not found"); } else {
						  map1.setCenter(point, 15);
						  var marker = new GMarker(point);
						  map1.addOverlay(marker);
						  map1.addControl(new GSmallMapControl());
					}
				}
			);
		}
		
		gdir = new GDirections(map1, $('#directionsArea')[0]);
		GEvent.addListener(gdir, "load", function(){});
	    GEvent.addListener(gdir, "error", handleErrors);
		
		function handleErrors(){
			//alert(gdir.getStatus().code);
			if(gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS || gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS){
				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.");
			}
			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.");
			}
			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.");
			}
			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.");
			}
			else if (gdir.getStatus().code == G_GEO_BAD_REQUEST){
				alert("A directions request could not be successfully parsed.");
			}
			else{
				alert("An unknown error occurred.");
			}
   
		}
	});
//]]>
