    var gmap_id='map';
    var map;
    var clusterer;
    var geo;
    var icons = new Array();
    var mmPoints = new Array();
    var bounds;
    
    window.onload = load;
    window.onUnLoad = GUnload;

    function load() {
      if (GBrowserIsCompatible()) {
        // map initialization
        map = new GMap2(document.getElementById(gmap_id));
        map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GScaleControl());
        map.setCenter(new GLatLng(47.50, 19.05), 10);
        map.enableScrollWheelZoom();
        map.enableContinuousZoom();
        // catch mouse wheel scroll
        GEvent.addDomListener(map.getContainer(), "DOMMouseScroll", wheelevent);
        map.getContainer().onmousewheel = wheelevent;        
        // clusterer es masok
        clusterer = new Clusterer(map);
        clusterer.SetMaxVisibleMarkers(300);        
        bounds = new GLatLngBounds();        
        
        // icons
        var def_icon = new GIcon();
        def_icon.iconSize=new GSize(32,32);
        def_icon.shadowSize=new GSize(56,32);
        def_icon.iconAnchor=new GPoint(16,32);
        def_icon.infoWindowAnchor=new GPoint(16,0);
        
        icons[1] = new GIcon(def_icon, "/images/blue.png", null, "/images/shadow50.png"); 
        icons[3] = new GIcon(def_icon, "/images/green.png", null, "/images/shadow50.png"); 
        icons[4] = new GIcon(def_icon, "/images/orange.png", null, "/images/shadow50.png");
        
        // listeners
      }
    }

    function createMarker(point, html, category) {      
      var marker = new GMarker(point, icons[category]);
      GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(html);
        //new Ajax.Request('/hu/browse/InfoWindowClick/a/'+id);
      });
      return marker;
    }

    function addPoint(i, latitude, longitude, html, category, name)
    {
      var lat = parseFloat(latitude);
      var lng = parseFloat(longitude);
      var point = new GLatLng(lat, lng);
      var html  = html;
      mmPoints[i] = createMarker(point, html, category);
      clusterer.AddMarker(mmPoints[i], name);
    }
    
    function fitMap()
    {
      if (undefined === $('auto_zoom'))
      {
				return true;
      }
      else
      {
        if (undefined === $('auto_zoom').checked || $('auto_zoom').checked == false) return true;
      }
      bounds = new GLatLngBounds();
      var i;
      for (i in mmPoints)
      {
        if (mmPoints[i] instanceof GMarker)
        {
          bounds.extend(mmPoints[i].getLatLng())
        }
      }
      if (!bounds.isEmpty()) {
        map.setZoom(map.getBoundsZoomLevel(bounds));     
        map.setCenter(bounds.getCenter());
      }
    }

      function wheelevent(e)
      {
         if (!e){
            e = window.event
          }
          if (e.preventDefault){
            e.preventDefault()
          }
          e.returnValue = false;
      }
          
      // == shows all markers of a particular category, and ensures the checkbox is checked ==
      function show(category) {
        for (var i=0; i<gmarkers.length; i++) {
          if (gmarkers[i].mycategory == category) {
            gmarkers[i].show();
          }
        }
        // == check the checkbox ==
        document.getElementById(category+"box").checked = true;
      }

      // == hides all markers of a particular category, and ensures the checkbox is cleared ==
      function hide(category) {
        for (var i=0; i<gmarkers.length; i++) {
          if (gmarkers[i].mycategory == category) {
            gmarkers[i].hide();
          }
        }
        // == clear the checkbox ==
        document.getElementById(category+"box").checked = false;
        // == close the info window, in case its open on a marker that we just hid
        map.closeInfoWindow();
      }

    function resetPoints()
    {
      //map.clearOverlays();
      var i;
      for (i in mmPoints)
      {
        clusterer.RemoveMarker(mmPoints[i]);
      }
      mmPoints = [];
    }

    function markerFocus(i)
    {
      map.panTo(mmPoints[i].getLatLng());
      GEvent.trigger(mmPoints[i], "click");
    }    
