function getImportantPointsAsBounds(kategoria, bThumbnailMap) {
    var bounds = new GLatLngBounds();
    switch(kategoria) {
        
        case 0:
            // Bielsko Biała
            bounds.extend(new GLatLng( 49.7954, 19.0283));
            // Bieszczady przy Ukrainie
            bounds.extend(new GLatLng( 49.0234, 22.8515));
            // Świnoujście
            bounds.extend(new GLatLng( 53.9075, 14.2712));
            // Władysławowo
            bounds.extend(new GLatLng( 54.79276, 18.3966));
//            bounds.extend(new GLatLng( , ));
        break
        
        
        case 1:
        // Cały obrys Plant:
//            bounds.extend(new GLatLng(50.06661595241162, 19.939756393432617));
//            bounds.extend(new GLatLng(50.06446722189228, 19.945335388183594));
//            bounds.extend(new GLatLng(50.05383234372285, 19.93915557861328));
//            bounds.extend(new GLatLng(50.06182249834169, 19.931259155273438));
            
            if(!bThumbnailMap) {
        // Punkty wewnątrz obrysu Plant:
                bounds.extend(new GLatLng(50.06460496391557, 19.939541816711426));
                bounds.extend(new GLatLng(50.06143679730778, 19.942116737365723));
                bounds.extend(new GLatLng(50.05746940668196, 19.93743896484375));
                bounds.extend(new GLatLng(50.06138169690691, 19.934349060058594));
        // Plac Nowy:
                bounds.extend(new GLatLng(50.051049253312065, 19.945292472839355));
            } else {
        // Rynek Główny (obrys):
                bounds.extend(new GLatLng(50.0619326980675, 19.939284324645996));  // wschód
                bounds.extend(new GLatLng(50.06306223066147, 19.936881065368652)); // północ
                bounds.extend(new GLatLng(50.0613265964428, 19.93494987487793));   // zachód
                bounds.extend(new GLatLng(50.0604174296473, 19.93748188018799));   // południe
            }
        break;
        case 2:
            //Dworzec Centralny
            bounds.extend(new GLatLng(52.22881144379907, 21.00311279296875));
            // Pałac Kultury - środek
            bounds.extend(new GLatLng(52.231702816483164, 21.00635290145874));
            // Zamek Królewski
            bounds.extend(new GLatLng(52.247739943549966, 21.014742851257324));
            
        break
        case 3: // Wrocław
            //Ogród Botaniczny
            bounds.extend(new GLatLng(51.11596987134979, 17.04829216003418));
            //Wystpa Tamska
            bounds.extend(new GLatLng(51.114973082793654, 17.036876678466797));
            //Park Słowackiego
            bounds.extend(new GLatLng(51.10953077691781, 17.045931816101074));
            //Połudiowa część Rynku
            bounds.extend(new GLatLng(51.1093421706695, 17.031469345092773));
        
        break;
        case 4: // Poznań
            // Park Cytadela
            bounds.extend(new GLatLng(52.42179015393902, 16.935253143310547));
            // Park im. Jana Kasprowicza
            bounds.extend(new GLatLng(52.39623921683941, 16.89096450805664));
            // Park im. JP II
            bounds.extend(new GLatLng(52.388906297668264, 16.92770004272461));
//            
//            bounds.extend(new GLatLng());
        
        break;
    }
    return bounds;    
}

        
function centruj(marker, bounds, zoom, bPanTo, map) {
    var bounds = bounds;
    var markerPixelPoint;
    var markerPixelPointTop;
    if(marker instanceof GMarker) {
        bounds.extend(marker.getPoint());
    }
    var zoomLevel = map.getBoundsZoomLevel(bounds) + zoom;
    if(zoomLevel > 14) {
        zoomLevel=14;
    }
    var center = bounds.getCenter();
    if(bPanTo) {
        map.setZoom(zoomLevel);
        map.panTo(center);
    } else {
        map.setCenter(center, zoomLevel);
    }
    
    if(marker) {
        var markerDimensions = {x: 20, y: 34};
        var margins = {top: markerDimensions.y, left: markerDimensions.x/2, right: markerDimensions.x/2, bottom: 0};
        
        try {
            if(map.fromLatLngToDivPixel(marker.getPoint()).y < margins.top) {
                  markerPixelPoint = map.fromLatLngToDivPixel(marker.getPoint());
                  markerPixelPointTop = new GPoint(markerPixelPoint.x, markerPixelPoint.y-margins.top);
                  bounds.extend(map.fromDivPixelToLatLng(markerPixelPointTop));
                  centruj(null, bounds, 0, bPanTo, map);
            }
            
            if(map.fromLatLngToDivPixel(marker.getPoint()).x < margins.left) {
                  markerPixelPoint = map.fromLatLngToDivPixel(marker.getPoint());
                  markerPixelPointTop = new GPoint(markerPixelPoint.x-margins.left, markerPixelPoint.y);
                  bounds.extend(map.fromDivPixelToLatLng(markerPixelPointTop));
                  centruj(null, bounds, 0, bPanTo, map);
            }
            
            if(map.fromLatLngToDivPixel(marker.getPoint()).x > map.getSize().width - margins.right) {
                  markerPixelPoint = map.fromLatLngToDivPixel(marker.getPoint());
                  markerPixelPointTop = new GPoint(markerPixelPoint.x+margins.right, markerPixelPoint.y);
                  bounds.extend(map.fromDivPixelToLatLng(markerPixelPointTop));
                  centruj(null, bounds, 0, bPanTo, map);
            }
        } catch(e) {}
    }
            
    
    
    
}   

function checkBounds(map, allowedBounds) {
//    if (allowedBounds.contains(map.getCenter())) {
//      return;
//    }
    var bRecenter = false;
    var C = map.getCenter();
    var X = C.lng();
    var Y = C.lat();
    
    mapWindowHeight = Math.abs(map.getBounds().getNorthEast().lat() - map.getBounds().getSouthWest().lat());
    mapWindowWidth  = Math.abs(map.getBounds().getNorthEast().lng() - map.getBounds().getSouthWest().lng());
    
//    alert(mapWindowHeight+'x'+mapWindowWidth);
    
    var AmaxX = allowedBounds.getNorthEast().lng();
    var AmaxY = allowedBounds.getNorthEast().lat();
    var AminX = allowedBounds.getSouthWest().lng();
    var AminY = allowedBounds.getSouthWest().lat();
    
//    if (X < AminX - mapWindowWidth/iFactor)  {X = AminX - mapWindowWidth/iFactor;  bRecenter = true;}
//    if (X > AmaxX + mapWindowWidth/iFactor)  {X = AmaxX + mapWindowWidth/iFactor;  bRecenter = true;}
//    if (Y < AminY - mapWindowHeight/iFactor) {Y = AminY - mapWindowHeight/iFactor; bRecenter = true;}
//    if (Y > AmaxY + mapWindowHeight/iFactor) {Y = AmaxY + mapWindowHeight/iFactor; bRecenter = true;}

    if (X < AminX)  {X = AminX;  bRecenter = true;}
    if (X > AmaxX)  {X = AmaxX;  bRecenter = true;}
    if (Y < AminY)  {Y = AminY; bRecenter = true;}
    if (Y > AmaxY + mapWindowHeight/10) {Y = AmaxY + mapWindowHeight/10; bRecenter = true;}
//    alert ("Restricting "+Y+" "+X);
    if(bRecenter) {
//        if(oMoveListener) {
//            GEvent.removeListener(oMoveListener);
//        }
        map.setCenter(new GLatLng(Y,X));
//        map.panTo(new GLatLng(Y,X));
//      oMoveListener = GEvent.addListener(map, "move", function() {
//        checkBounds(this, oAllowedBounds);
//      });                    
        
    }
}
