    var map = null;
    var geocoder = null;

	function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_div"));
        map.setCenter(new GLatLng(52.00, 19.078789), 6);
		map.setUIToDefault();
		map.enableRotation();
        geocoder = new GClientGeocoder();
      }
      
	JavaScript:xmlhttpPost("map_context.php",1);
	JavaScript:xmlhttpPost("include/search_result.php",2);
	JavaScript:xmlhttpPost("include/catalogue_result.php",3);

    } 
    function initializeSM(adres) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_div"));
        map.setCenter(new GLatLng(52.00, 19.078789), 9);
		map.setUIToDefault();
		map.enableRotation();

        geocoder = new GClientGeocoder();
      }
      
      JavaScript:xmlhttpPost("include/search_result.php",2);
      addMarAddress(adres);
    }
    
    function getIcon(img) {
      
        var icon = new GIcon();
        icon.image = img;
        icon.iconAnchor = new GPoint(40, 40);
        icon.infoWindowAnchor = new GPoint(0, 0);
        icon.iconSize = new GSize(50, 55);

      return icon;
    }

    function addMarAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(address, function(point) {
            if (!point) {
              
            } else {
              var letteredIcon = getIcon("img/elektrownia.png");
              markerOptions = { icon:letteredIcon };
              var marker = new GMarker(point, markerOptions);
              map.setCenter(marker.getLatLng(), 13);
              map.addOverlay(marker);
            }
          }
        );
      }
   }
   
    function createMarker(point, t, i) {
          // Create a lettered icon for this point using our icon class

          var letteredIcon = getIcon("img/elektrownia.png");

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "click", function() {
            	map.setCenter(marker.getLatLng(), i);
				map.openInfoWindow(map.getCenter(), t);
          });
          return marker;
        }
        

    function addAddress(x, y, message) {
      
              var marker = new createMarker(new GLatLng(x,y), message, 13);
              map.addOverlay(marker);
   }

