    //<![CDATA[

    var map;
    var ovmap;
    var marker;    
    var directionsPanel;
    var directions;

    function load() {
        if (GBrowserIsCompatible()) {
    	    map = new GMap2(document.getElementById("map"));
    	    directionsPanel = document.getElementById("direct");
    	    directions = new GDirections(map, directionsPanel);
            var point = new GLatLng(35.53196666666667, -83.27478333333333);
            marker = new GMarker(point);
            map.addControl(new GLargeMapControl());
    	    map.addControl(new GMapTypeControl());
    	    map.addControl(new GScaleControl());
            map.setCenter(new GLatLng(35.53196666666667, -83.27478333333333), 12);
            map.addOverlay(marker);
            document.getElementById("mapOptions").innerHTML="<form action=\"javascript:reCenter();\" method=\"post\"><input name=\"submit\" type=\"submit\" value=\"Reset Map\" /></form>"
            map.setMapType(G_HYBRID_MAP);
            GEvent.addListener(marker, "click", function() {
    		    marker.openInfoWindowHtml("<br><div class=\"popup\"> <b>Mingo Falls</b><br><br> Latitude: 35&deg 31' 55\" N<br>Longitude: 83&deg 16' 29\" W<BR><BR><form action=\"javascript:getDirections(document.getElementById('fromDir').value);\" method=\"post\">From:&nbsp;<input type=\"text\" size=\"25\" id=\"fromDir\" name=\"from\"/><br /><input name=\"submit\" type=\"submit\" value=\"Get Directions\" /></form></div>");
    	    });
            var ovcontrol = new GOverviewMapControl(new GSize(150,150)); 
            map.addControl(ovcontrol);
    	    ovmap = ovcontrol.getOverviewMap();    	    
    	    setTimeout("ovmap.setMapType(G_NORMAL_MAP);",1);    	        	        	    
        }
        if (!GBrowserIsCompatible()) {
            alert("Google Maps is not compatable with this browser. Please try using a different browser. Thank you.");
        }      
     }

    function getDirections(fromDir) {
        if (fromDir != ""){
	        var tempStr;
	        marker.closeInfoWindow();
	        directions.load(fromDir + " to 35.53196666666667, -83.27478333333333");
            GEvent.addListener(directions, "load", ondirectionsectionsLoad);
            GEvent.addListener(directions, "error", handleErrors);	    
            tempStr="<TABLE><TBODY><TR>";
	        tempStr+="<TD><form action=\"javascript:turnOffDirect();\" method=\"post\"><input name=\"submit\" type=\"submit\" value=\"Reset Map\" /></form></TD>";
	        tempStr+="<TD><form action=\"javascript:printMap();\" method=\"post\"><input name=\"submit\" type=\"submit\" value=\"Print Directions\" /></form></TD>"; 
	        tempStr+="</TR></TBODY></TABLE>";
	        document.getElementById("mapOptions").innerHTML=tempStr;
	    }
	    else{
	        alert("Please enter in an address seperated by commas(\"1600 Amphitheatre Parkway, Mountain View, CA 94043\") or a location(\"Mountain View, CA\")");
	    }
    }

    function turnOffDirect(){
        directions.clear();
        reCenter();
        document.getElementById("mapOptions").innerHTML="<form action=\"javascript:reCenter();\" method=\"post\"><input name=\"submit\" type=\"submit\" value=\"Reset Map\" /></form>"                
    }
    
    function reCenter(){
        window.setTimeout(function() {
            map.panTo(new GLatLng(35.53196666666667, -83.27478333333333));
            window.setTimeout(function() {              
                map.setCenter(new GLatLng(35.53196666666667, -83.27478333333333),12);
                map.setMapType(G_HYBRID_MAP);
		        setTimeout("ovmap.setMapType(G_NORMAL_MAP);",1);  
            }, 1000);
        }, 1000);
    }
    
    function printMap(){
      var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
          disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
      var content_vlue = document.getElementById("direct").innerHTML;    
      var docprint=window.open("","",disp_setting); 
       docprint.document.open(); 
       docprint.document.write('<html><head><title>Directions to Mingo Falls</title>'); 
       docprint.document.write('</head><body onLoad="self.print()"><center>');          
       docprint.document.write(content_vlue);          
       docprint.document.write('</center></body></html>'); 
       docprint.document.close(); 
       docprint.focus(); 
    }
    
    function handleErrors(){
       turnOffDirect();
	   if (directions.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: " + directions.getStatus().code);
	   else if (directions.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: " + directions.getStatus().code);
	   
	   else if (directions.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: " + directions.getStatus().code);

	//   else if (directions.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: " + directions.getStatus().code);
	     
	   else if (directions.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: " + directions.getStatus().code);

	   else if (directions.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + directions.getStatus().code);
	    
	   else alert("An unknown error occurred.");
	   
	}

	function ondirectionsectionsLoad(){ 
          // Use this function to access information about the latest load()
          // results.

          // e.g.
	  // document.getElementById("getStatus").innerHTML = directions.getStatus().code;
	  // and yada yada yada...
	}

    //]]>
