    if (GBrowserIsCompatible()) {
      var map;
      var gmarkers = [];
      var gicons = [];

      var baseIcon = new GIcon();
          baseIcon.iconSize=new GSize(32,32);
          baseIcon.shadowSize=new GSize(56,32);
          baseIcon.iconAnchor=new GPoint(16,32);
          baseIcon.infoWindowAnchor=new GPoint(16,0);
          
      gicons["szallashely"] = new GIcon(baseIcon, "http://maps.google.com/mapfiles/kml/pal2/icon28.png", null, "http://maps.google.com/mapfiles/kml/pal2/icon28s.png");
      gicons["vendeglato"]  = new GIcon(baseIcon, "http://maps.google.com/mapfiles/kml/pal2/icon40.png", null, "http://maps.google.com/mapfiles/kml/pal2/icon40s.png");
      //gicons["info"]        = new GIcon(G_DEFAULT_ICON,"colour125.png");

      // A function to create the marker and set up the event window
      function createMarker(point,name,html,category) {
        var marker = new GMarker(point,gicons[category]);
        // === Store the category and name info as a marker properties ===
        marker.mycategory = category;                                 
        marker.myname = name;
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers.push(marker);
        return marker;
      }

      // == 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();
      }

      // == a checkbox has been clicked ==
      function boxclick(box,category) {
        if (box.checked) {
          show(category);
        } else {
          hide(category);
        }
        // == rebuild the side bar
        makeSidebar();
      }

      function myclick(i) {
        GEvent.trigger(gmarkers[i],"click");
      }


      // == rebuilds the sidebar to match the markers currently displayed ==
      function makeSidebar() {
        var html = '<ul>';
        for (var i=0; i<gmarkers.length; i++) {
          if (!gmarkers[i].isHidden()) {
            html += '<li class="' + gmarkers[i].mycategory + '"><a href="javascript:myclick(' + i + ')">' + gmarkers[i].myname + '</a></li>';
          }
        }
        html += '</ul>';
        document.getElementById("side_bar").innerHTML = html;
      }


      function googlemaps_load(p_map, p_x, p_y, p_zoom) {
        // create the map
        map = new GMap2(document.getElementById(p_map));
        map.addControl(new GLargeMapControl());
        //map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(p_x,p_y), p_zoom);

        // Read the data
        GDownloadUrl("../../_application/src/provider/terkep/index.php", function(doc) {
          var xmlDoc = GXml.parse(doc);
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            
          for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var address = markers[i].getAttribute("address");
            var name = markers[i].getAttribute("name");
            var id = markers[i].getAttribute("id");
            var category = markers[i].getAttribute("category");
            var html = "<b>"+name+"</b><div>"+address+"</div>" + makeLink(id, category);
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat,lng);
            // create the marker
            var marker = createMarker(point,name,html,category);
            map.addOverlay(marker);
            if (selectedId != undefined && selectedCategory != undefined) {
              if (selectedId == id && selectedCategory == category) selectedId = i;
            }
          }

          // == show or hide the categories initially ==
          show("szallashely");
          hide("vendeglato");
          if (selectedCategory != undefined) show(selectedCategory);
          //hide("info");
          // == create the initial sidebar ==
          makeSidebar();
          if (selectedId != undefined) myclick(selectedId);
        });

        return map;
      }

    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

