Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java	(revision 13624)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java	(revision 13625)
@@ -35,12 +35,14 @@
 /**
  * Class that displays a slippy map layer.
- *
+ * 
  * @author Frederik Ramm <frederik@remote.org>
- *
+ * @author LuVar <lubomir.varga@freemap.sk>
+ * 
  */
 public class SlippyMapLayer extends Layer implements ImageObserver,
         PreferenceChangedListener
 {
-    ArrayList<HashMap<Integer, SlippyMapTile>> tileStorage = null;
+	public int currentZoomLevel = 14;
+    ArrayList<HashMap<SlippyMapKey, SlippyMapTile>> tileStorage = null;
 
     Point[][]                                  pixelpos    = new Point[21][21];
@@ -57,5 +59,5 @@
     {
         super(tr("Slippy Map"));
-    background = true;
+	background = true;
 
         clearTileStorage();
@@ -110,4 +112,26 @@
             }
         }));
+        
+        //increase and decrease commands
+        tileOptionMenu.add(new JMenuItem(new AbstractAction(tr("Increase zoom"))
+        {
+            public void actionPerformed(ActionEvent ae)
+            {
+            	increaseZoomLevel();
+                needRedraw = true;
+                Main.map.repaint();
+            }
+        }));
+        
+        tileOptionMenu.add(new JMenuItem(new AbstractAction(tr("Decrease zoom"))
+        {
+            public void actionPerformed(ActionEvent ae)
+            {
+            	decreaseZoomLevel();
+                needRedraw = true;
+                Main.map.repaint();
+            }
+        }));
+        //end of adding menu commands
 
         SwingUtilities.invokeLater(new Runnable()
@@ -150,10 +174,31 @@
     }
 
+    /**
+     * Zoom in, go closer to map.
+     */
+    public void increaseZoomLevel() {
+    	//TODO max lvl should be in preferences...
+    	if(currentZoomLevel < 17) {
+    		currentZoomLevel++;
+    		loadAllTiles();
+    	}
+    }
+    
+    /**
+     * Zoom out from map.
+     */
+    public void decreaseZoomLevel() {
+    	if(currentZoomLevel > 10) {
+    		currentZoomLevel--;
+    		loadAllTiles();
+    	}
+    }
+    
     private void clearTileStorage()
     {
-        tileStorage = new ArrayList<HashMap<Integer, SlippyMapTile>>(20);
+        tileStorage = new ArrayList<HashMap<SlippyMapKey, SlippyMapTile>>(20);
 
         for (int i = 0; i < 18; i++)
-            tileStorage.add(new HashMap<Integer, SlippyMapTile>());
+            tileStorage.add(new HashMap<SlippyMapKey, SlippyMapTile>());
     }
 
@@ -179,19 +224,25 @@
             z12y1 = tmp;
         }
-        if (z12x1 - z12x0 > 18)
+        //if there is more than 18 tiles on screen in any direction, do not load all tiles!
+        if (z12x1 - z12x0 > 18) {
+        	System.out.println("Not downloading all tiles because there is more than 18 tiles on X axis!");
             return;
-        if (z12y1 - z12y0 > 18)
-            return;
+        }
+        if (z12y1 - z12y0 > 18) {
+        	System.out.println("Not downloading all tiles because there is more than 18 tiles on Y axis!");
+        	return;
+        }
+        
         for (int x = z12x0 - 1; x <= z12x1; x++)
         {
             for (int y = z12y0 - 1; y <= z12y1; y++)
             {
-                int key = (y << 19) + x;
-
-                SlippyMapTile tile = tileStorage.get(12).get(key);
+            	SlippyMapKey key = new SlippyMapKey(x,y);
+
+                SlippyMapTile tile = tileStorage.get(currentZoomLevel).get(key);
 
                 if (tile == null)
-                    tileStorage.get(12).put(key,
-                            tile = new SlippyMapTile(x, y, 12));
+                    tileStorage.get(currentZoomLevel).put(key,
+                            tile = new SlippyMapTile(x, y, currentZoomLevel));
 
                 if (tile.getImage() == null)
@@ -244,5 +295,5 @@
             z12y1 = tmp;
         }
-
+        
         if (z12x1 - z12x0 > 18)
             return;
@@ -269,11 +320,11 @@
             for (int y = z12y0 - 1; y <= z12y1; y++)
             {
-                int key = (y << 19) + x;
-                SlippyMapTile tile = tileStorage.get(12).get(key);
+            	SlippyMapKey key = new SlippyMapKey(x,y);
+                SlippyMapTile tile = tileStorage.get(currentZoomLevel).get(key);
 
                 if (tile == null)
                 {
-                    tileStorage.get(12).put(key,
-                            tile = new SlippyMapTile(x, y, 12));
+                    tileStorage.get(currentZoomLevel).put(key,
+                            tile = new SlippyMapTile(x, y, currentZoomLevel));
                 }
                 Image img = tile.getImage();
@@ -304,9 +355,9 @@
             for (int y = z12y0 - 1; y <= z12y1; y++)
             {
-                int key = (y << 19) + x;
+            	SlippyMapKey key = new SlippyMapKey(x,y);
                 int texty = p.y + 2 + fontHeight;
-                SlippyMapTile tile = tileStorage.get(12).get(key);
+                SlippyMapTile tile = tileStorage.get(currentZoomLevel).get(key);
                 p = pixelpos[x - z12x0 + 1][y - z12y0 + 2];
-                g.drawString("x=" + x + " y=" + y + " z=12", p.x + 2, texty);
+                g.drawString("x=" + x + " y=" + y + " z=" + currentZoomLevel + "", p.x + 2, texty);
                 texty += 1 + fontHeight;
                 if ((x % 32 == 0) && (y % 32 == 0))
@@ -346,5 +397,16 @@
         oldg.drawImage(bufferImage, 0, 0, null);
 
-    }
+        if((z12x1 - z12x0 < 2) || (z12y1 - z12y0 < 2)) {
+        	increaseZoomLevel();
+        	this.paint(oldg, mv);
+        }
+        
+        if((z12x1 - z12x0 > 6) || (z12y1 - z12y0 > 6)) {
+        	decreaseZoomLevel();
+        	this.paint(oldg, mv);
+        }
+        
+        g.drawString("currentZoomLevel=" + currentZoomLevel, 120, 120);
+    }//end of paint metod
 
     SlippyMapTile getTileForPixelpos(int px, int py)
@@ -375,9 +437,9 @@
             return null;
 
-        int key = (tiley << 19) + tilex;
-        SlippyMapTile tile = tileStorage.get(12).get(key);
+        SlippyMapKey key = new SlippyMapKey(tilex,tiley);
+        SlippyMapTile tile = tileStorage.get(currentZoomLevel).get(key);
         if (tile == null)
-            tileStorage.get(12).put(key,
-                    tile = new SlippyMapTile(tilex, tiley, 12));
+            tileStorage.get(currentZoomLevel).put(key,
+                    tile = new SlippyMapTile(tilex, tiley, currentZoomLevel));
         return tile;
     }
@@ -435,15 +497,15 @@
         double l = lat / 180 * Math.PI;
         double pf = Math.log(Math.tan(l) + (1 / Math.cos(l)));
-        return (int) (2048.0 * (Math.PI - pf) / Math.PI);
+        return (int) (Math.pow(2.0, currentZoomLevel-1) * (Math.PI - pf) / Math.PI);
     }
 
     private int lonToTileX(double lon)
     {
-        return (int) (512.0 * (lon + 180.0) / 45.0);
+        return (int) (Math.pow(2.0, currentZoomLevel-3) * (lon + 180.0) / 45.0);
     }
 
     private double tileYToLat(int y)
     {
-        return Math.atan(Math.sinh(Math.PI - (Math.PI * y / 2048.0))) * 180
+        return Math.atan(Math.sinh(Math.PI - (Math.PI * y / Math.pow(2.0, currentZoomLevel-1)))) * 180
                 / Math.PI;
     }
@@ -451,5 +513,5 @@
     private double tileXToLon(int x)
     {
-        return x * 45.0 / 512.0 - 180.0;
+        return x * 45.0 / Math.pow(2.0, currentZoomLevel-3) - 180.0;
     }
 
@@ -468,5 +530,5 @@
     /*
      * (non-Javadoc)
-     *
+     * 
      * @see org.openstreetmap.josm.data.Preferences.PreferenceChangedListener#preferenceChanged(java.lang.String,
      *      java.lang.String)
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java	(revision 13624)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java	(revision 13625)
@@ -16,5 +16,4 @@
     public SlippyMapPlugin()
     {
-
     }
 
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java	(revision 13624)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java	(revision 13625)
@@ -3,13 +3,6 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-import javax.swing.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
 
 import org.openstreetmap.josm.Main;
@@ -24,6 +17,5 @@
  *
  */
-public class SlippyMapPreferenceSetting implements PreferenceSetting
-{
+public class SlippyMapPreferenceSetting implements PreferenceSetting {
     /**
      * ComboBox with all known tile sources.
@@ -60,6 +52,6 @@
     public boolean ok()
     {
-        Main.pref.put(SlippyMapPreferences.PREFERENCE_TILE_URL, tileSourceCombo
-                .getSelectedItem().toString());
+        Main.pref.put(SlippyMapPreferences.PREFERENCE_TILE_URL, tileSourceCombo.getSelectedItem().toString());
+        //restart isnt required
         return false;
     }
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java	(revision 13624)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java	(revision 13625)
@@ -5,7 +5,8 @@
 /**
  * Preferences for Slippy Map Tiles
- *
+ * 
  * @author Hakan Tandogan <hakan@gurkensalat.com>
- *
+ * @author LuVar <lubomir.varga@freemap.sk>
+ * 
  */
 public class SlippyMapPreferences
@@ -14,5 +15,5 @@
 
     public static String PREFERENCE_TILE_URL = PREFERENCE_PREFIX + ".tile_url";
-
+    
     public static String getMapUrl()
     {
@@ -35,5 +36,7 @@
                 "http://tah.openstreetmap.org/Tiles/maplint", // maplint
                 "http://tile.openstreetmap.org", // mapnik
-                "http://hypercube.telascience.org/tiles/1.0.0/coastline" // coastline
+                "http://hypercube.telascience.org/tiles/1.0.0/coastline", // coastline
+                "http://www.freemap.sk/layers/allinone/?", //freemapy.sk
+                "http://www.freemap.sk/layers/tiles/?", //freemapy.sk pokus 2
         };
         return defaultTileSources;
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapTile.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapTile.java	(revision 13624)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapTile.java	(revision 13625)
@@ -13,7 +13,8 @@
 /**
  * Class that contains information about one single slippy map tile.
- *
+ * 
  * @author Frederik Ramm <frederik@remote.org>
- *
+ * @author LuVar <lubomir.varga@freemap.sk>
+ * 
  */
 public class SlippyMapTile
@@ -21,7 +22,7 @@
     private Image  tileImage;
 
-    int            x;
-    int            y;
-    int            z;
+    int x;
+    int y;
+    int z;
 
     private String metadata;
@@ -45,5 +46,5 @@
             URL imageURL = new URL(SlippyMapPreferences.getMapUrl() + "/" + z
                     + "/" + x + "/" + y + ".png");
-
+            
             tileImage = Toolkit.getDefaultToolkit().createImage(imageURL);
         }
@@ -65,5 +66,5 @@
             URL dev = new URL(
                     "http://tah.openstreetmap.org/Tiles/info_short.php?x=" + x
-                            + "&y=" + y + "&z=12/layer=tile");
+                            + "&y=" + y + "&z=" + z + "/layer=tile");
             URLConnection devc = dev.openConnection();
             BufferedReader in = new BufferedReader(new InputStreamReader(devc
