﻿var map = null;
var geocoder = null;
var adres = null;


    function initialize() {
      if (GBrowserIsCompatible()) {
		adres = document.form_adres.adres.value+', '+document.form_adres.miasto.value+', '+document.form_adres.kod.value;
        map = new GMap2(document.getElementById("mapa"));
		map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());

        geocoder = new GClientGeocoder();
		geocoder.getLatLng(
          adres,
          function(point) {
            if (!point) {
             // alert(adres + " not found");
			 geocoder.getLatLng( document.form_adres.miasto.value+', Polska', function(point) 
			 {
				if(point)
				{
					map.setCenter(point, 14);
					var marker = new GMarker(point);
					map.addOverlay(marker);
				}
				
			 });
			 //
            } else {
              map.setCenter(point, 14);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              //marker.openInfoWindowHtml(adres);
            }
          }
        );

      }
    }

