//Direction Functions

var map;
var gdir;
var geocoder = null;
var addressMarker;
var point;

function load(){
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
        map.enableContinuousZoom();
        map.enableDoubleClickZoom();
        map.addControl(new GSmallMapControl());
        map.addControl(new GScaleControl());
        map.addControl(new GMapTypeControl());
      
		
        var point = new GLatLng(41.055521, -83.688483);
        var point2 = new GLatLng(40.826100, -83.281054);
        var point3 = new GLatLng(41.356002, -83.613080);
        var cp = new GLatLng(41.143501, -83.350524)
        map.setCenter(cp, 9);
        
        var address_0 = {
            infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: #000;"><strong>Address:</strong><br />JobSolutions Hancock<br />7746 CR 140, Suite B<br />Findlay, OH 45840</span>'
        };
        var address_1 = {
            infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: #000;"><strong>Address:</strong><br />JobSolutions Wyandot<br />120 E. Johnson Street<br />Upper Sandusky, OH 45840</span>'
        };
        var address_2 = {
        
            infowindowtext: '<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: #000;"><strong>Address:</strong><br />JobSolutions Wood<br />1928 E Gypsy Lane Rd<br />Bowling Green, OH 43402</span>'
        };
        
        var marker = new GMarker(point);
        var marker2 = new GMarker(point2);
        var marker3 = new GMarker(point3);
        GEvent.addListener(marker, 'click', function(){
            map.openInfoWindowHtml(point, address_0.infowindowtext);
        });
        GEvent.addListener(marker2, 'click', function(){
            map.openInfoWindowHtml(point2, address_1.infowindowtext);
        });
        GEvent.addListener(marker3, 'click', function(){
            map.openInfoWindowHtml(point3, address_2.infowindowtext);
        });
        map.addOverlay(marker);
        map.addOverlay(marker2);
        map.addOverlay(marker3);
        // marker.openInfoWindowHtml(address_0.infowindowtext);
    
    }
    
}

function setDirections(fromAddress, toAddress, locale){
    map.closeInfoWindow();
	map.clearOverlays();
    gdir.load("from: " + fromAddress + " to: " + toAddress, {
        "locale": locale
    });
    
}

function handleErrors(){
    if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) 
        alert("Please enter an address.");
    else 
        if (gdir.getStatus().code == G_GEO_SERVER_ERROR) 
            alert("A directions request could not be successfully processed.");
        else 
            if (gdir.getStatus().code == G_GEO_MISSING_QUERY) 
                alert("Please select a location.");
            
             //     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("Please select a location.");
                    
                    else 
                        alert("An unknown error occurred.");
    
}

function onGDirectionsLoad(){
    
}

// Direction Functions
