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

	// Creates a marker at the given point with the given number label
	function createMarker(point, html) {
	  var marker = new GMarker(point);
	  GEvent.addListener(marker, "click", function() {
	    marker.openInfoWindowHtml(html);
	  });
	  return marker;
	}

    function initialize() {
      if (document.getElementById("map_canvas")==null)
      	return;
      	
      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);       
        var point = new GLatLng(50.280337,19.147839);
        map.setCenter(point, 10);
        map.addOverlay(createMarker(point, "<span style='color: black'>SEGU POLSKA</span>"));
        map.addControl(new GSmallMapControl());
      }
    }
    
    function setDirections(fromAddress) {
      gdir.load("from: polska " + fromAddress + " to: Segu@50.280337,19.147839",
                { "locale": "pl" });
    }

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("Nie można znaleźć podanego adresu. Adres może być nieprawidłowy lub nie ma go w naszej bazie danych");
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("Adres znaleziony, jednak wystąpił nieznany błąd. Prosimy o kontakt z administratorem strony.");	
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("Brak podanego adresu");
	//   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("Klucz domeny jest nieprawidłowy. Prosimy o kontakt z administratorem strony.");
	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("Nie można przetworzyć tego zapytania.");	    
	   else alert("Wystąpił nieznany błąd.");
	   
	}

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

