    var map = "";
    var marker = new Array;
    var gmarkers = [];
    var gicons   = [];
    var i = 0;
    
    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);

    // tablica ikon przypisanych do kategorii (numer kategorii jest indeksem tablicy)
    gicons[1] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[2] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[3] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[4] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[5] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[6] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[7] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[8] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[9] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[10] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[11] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[12] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[13] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[14] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[15] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[16] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[17] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal2/icon10.png', null, 'http://maps.google.com/mapfiles/kml/pal2/icon10s.png');
    gicons[18] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[19] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[20] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[21] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[22] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[23] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[24] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[25] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[26] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal2/icon28.png', null, 'http://maps.google.com/mapfiles/kml/pal2/icon28s.png');
    gicons[27] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[28] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[29] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[30] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal2/icon11.png', null, 'http://maps.google.com/mapfiles/kml/pal2/icon11s.png');
    gicons[31] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[32] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal5/icon14.png', null, 'http://maps.google.com/mapfiles/kml/pal5/icon14s.png');
    gicons[33] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal2/icon40.png', null, 'http://maps.google.com/mapfiles/kml/pal2/icon40s.png');
    gicons[34] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal2/icon40.png', null, 'http://maps.google.com/mapfiles/kml/pal2/icon40s.png');
    gicons[35] = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/kml/pal2/icon62.png', null, 'http://maps.google.com/mapfiles/kml/pal2/icon62s.png');

    function load() {
      if (GBrowserIsCompatible()) {

        resizeMap();
		
		map = new GMap2(document.getElementById("map"), {draggableCursor: 'crosshair', draggingCursor: 'crosshair'});
        //map.addControl(new GLargeMapControl());
		map.addControl(new GSmallMapControl());
        map.enableDoubleClickZoom();
        map.enableContinuousZoom();
        
        // wartości startowe parametrów x, y, zoom
        startX    = 17.022604465528275;
        startY    = 51.09484413034213;
        //startX    = x_p;
        //startY    = y_p;		
        startZoom = 15;
        startType = G_NORMAL_MAP;

        center = new GLatLng(startY, startX);
        map.setCenter(center, startZoom, startType);
		
		// dodanie markera odpowiedzialnego za wskazanie aktualnie wybranego obiektu
        marker[0] = new GMarker(center, {draggable: false});
        map.addOverlay(marker[0]);
		marker[0].openInfoWindowHtml("<img src='./img/slogo.jpg' style='width:100px;float:left' alt='' /><span style='font-size:10px;font-family:verdana'>Powstańców Śląskich 58d<br />53-139 Wrocław<br />tel. 071 367-53-05<br /></span>");
		
		GEvent.addListener(marker[0], "click", function() {
			marker[0].openInfoWindowHtml("<img src='./img/slogo.jpg' style='width:100px;float:left' alt='' /><span style='font-size:10px;font-family:verdana'>Powstańców Śląskich 58d<br />53-139 Wrocław<br />tel. 071 367-53-05</span>");
			
			//top.info.document.location = 'info.php?id=' + id;
		  });		
     }
    }
    
    function mapMoveTo(x,y) {
      point = new GLatLng(y, x);
      //map.clearOverlays();
      //map.addOverlay(new GMarker(point));
      map.panTo(point);
      marker[0].setPoint(point);
    }
    
    function showLayer(element) {
      var request = GXmlHttp.create();
      request.open("GET", "xml.php?cat_id=" + element.value, true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = request.responseXML;
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");

          for (var i = 0; i < markers.length; i++) {
            // pobieramy atrybuty markera
            var lat   = parseFloat(markers[i].getAttribute("lat"));
            var lng   = parseFloat(markers[i].getAttribute("lng"));
            var id    = markers[i].getAttribute("id");
            var point = new GLatLng(lat,lng);
            var html  = markers[i].getAttribute("html");
            var label = markers[i].getAttribute("label");
            
            // jeżeli wspórzędne nie są zdefiniowane...
            if (!lat || !lng)
              continue;
            
            // tworzymy lub usuwamy marker
            if (element.checked) {
              var marker = createMarker(point,label,id, element.value);
              map.addOverlay(marker);
            } else {
              map.removeOverlay(gmarkers[id]);
            }
          }
        }
      }
      request.send(null);
    }

    function createMarker(point,name,id,cat_id) {
      if (gicons[cat_id]) {
        var marker = new GMarker(point,{title:name, icon: gicons[cat_id]});
      } else {
        var marker = new GMarker(point,{title:name});
      }
      GEvent.addListener(marker, "click", function() {
		marker[0].openInfoWindowHtml("<img src='images/slogo.gif' style='width:100px;height:67px;float:left' alt='' /><span style='font-size:10px;font-family:verdana'>Powstańców Śląskich 58d<br />53-139 Wrocław<br />tel. 071 367-53-05<br /></span>");
        
		//top.info.document.location = 'info.php?id=' + id;
      });
      // zapisujemy kopię markera w tablicy do celów usuwania
      gmarkers[id] = marker;
      return marker;
    }

    function resizeMap() {
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      //document.getElementById("map").style.height = myHeight + 'px';
	  document.getElementById("map").style.height = '250px';
	  document.getElementById("map").style.width = '300px';
    }
