var map = null;
    var geocoder = null;
    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById('map'), {draggableCursor: 'crosshair', draggingCursor: 'move'});
        map.setCenter(new GLatLng(51.126367518319235,15.913352966308594), 14);
        map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));
        map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT));
        map.setMapType(G_NORMAL_MAP);
        map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT));
        map.enableDoubleClickZoom();
        keyboardhandler = new GKeyboardHandler(map);
        toPoint = map.getCenter();
        gdir=new GDirections(map, document.getElementById('directions'));
        geocoder = new GClientGeocoder();
      }
    }
    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
    function showDirections() {
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";
      GEvent.addListener(gdir, "error", function() {
          var code = gdir.getStatus().code;
          var reason="Code "+code;
          if (reasons[code]) {
           reason = reasons[code];
          }
          alert(reason);
      });
     var toAddr = "end"+"@"+toPoint.lat() + "," + toPoint.lng();
     // selectcoordinate=177
     var opts = {};
     opts.travelMode = G_TRAVEL_MODE_DRIVING;
     opts.avoidHighways = false;
     opts.locale = "pl";
     var fromAddr = document.inputFormDirection.fromAddr.value;
     gdir.load("from: "+fromAddr+" to: "+toAddr, opts);
   }