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

function initialize() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("google_map"));
    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", handleErrors);
    setDirections(CMGSettings['city'] + ", " + CMGSettings['address'], CMGSettings['city'] + ", " + CMGSettings['address'], CMGSettings['country']);
  }
}

function setDirections(fromAddress) {
  gdir.load("from: " + CMGSettings['city'] + ", " + fromAddress + " to: " + CMGSettings['city'] + ", " + CMGSettings['address'], { "locale": CMGSettings['locale'] });
}

function handleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
     alert(CMGSettings['streetNotFound']);
   else alert(CMGSettings['googleMapError']);
}

function onGDirectionsLoad(){
}

jQuery(function(){initialize();});
