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

    function initialize()
    {
      if (GBrowserIsCompatible())
          {      
        map = new GMap2(document.getElementById("map_canvas"));
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(44.198665, -79.648301), 15);
        map.setMapType(G_HYBRID_MAP);
		
		// Make CMOM Marker
		// Create our "tiny" marker icon
        var cmom = new GIcon();
        cmom.image = "http://www.cookstownoutletmall.ca/images/mapicon/cmom.png";
        cmom.shadow = "http://www.cookstownoutletmall.ca/images/mapicon/cmoms.png";
        cmom.iconSize=new GSize(144,52);
        cmom.shadowSize=new GSize(180,52);
        cmom.iconAnchor=new GPoint(00,52);
        cmom.infoWindowAnchor=new GPoint(16,0);
        
        
        // Set up our GMarkerOptions object
        markerOptions = { icon:cmom };
        
        // Add marker to the map
        var point = new GLatLng(44.199100,-79.652115);
        map.addOverlay(new GMarker(point, markerOptions));
		
		
          }
    }
    
    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }

    function handleErrors(){
       if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
         alert("Sorry No corresponding geographic location could be found for one of the specified addresses. This may be that the address is relatively new, or it may not be supported - Please try again or rephrase your location.\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. Please try again or rephrase your location.\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. Please try again with or rephrase your location.\n Error code: " + gdir.getStatus().code);
        
       else alert("Sorry, An Error Occured. Please try again or rephrase your location.");
       
    }

    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...
    }

