    var map;
    var geocoder;
    var gdzie;

    function initialize(gdzie) {
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(34, 0), 2);
      geocoder = new GClientGeocoder();
        map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    GDownloadUrl("http://www.apartworld.com/mapy/property_list.xml.php?siteid=1&regionid=1306", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("title");
            var address = markers[i].getAttribute("city");
            var bookinglink = "http://www.apartworld.com/view_apartment.php?id="+markers[i].getAttribute("id");
             var id= markers[i].getAttribute("id");
            var photo= markers[i].getAttribute("photos");
            var price= markers[i].getAttribute("price");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, address, photo, bookinglink, id, price);
            map.addOverlay(marker);
           
          }
  map.setCenter(point,12);
        }  
      );
      
    }
    
     function createMarker(point, name, address, photo, bookinglink, id, price) {
      var marker = new GMarker(point);
      var cena = price;
      if (cena>0)
        cena = "Arrive: "+document.search.startdate.value+" <br/>"+"Nights: "+document.search.nights.value+"<br/>"+"People: "+document.search.sleeps.value+"<br/>Total: <b style='font-size:14px; font-color: black;'>&pound; "+price+"</b>";
      else 
        cena = "";
      var html = "<div id='ramka'><div id='photo'><img src='"+photo+"' alt='ApartWorld.com -"+ name +"'/></div><div id='tekst'><div id='naglowek' style='width:130px; text-align:left;'><a href='http://www.apartworld.com/view_apartment.php?id="+id+"'><b>" + name + "</a></div><div id='reszta'>" + address+"<br/>"+ cena +"<br/><div id='book' style='text-align: right; top-padding:5px;'><a href='"+bookinglink+"'><img src='http://www.apartworld.com/images/more.gif' alt='more information'</a></div></div></div>";
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }


    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
      
      GDownloadUrl("http://www.apartworld.com/mapy/property_list.xml.php?siteid=1&startdate="+document.search.startdate.value+"&nights="+document.search.nights.value+"&sleeps="+document.search.sleeps.value+"&regionid="+document.search.region_id.value, function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("title");
            var address = markers[i].getAttribute("city");
            var photo= markers[i].getAttribute("photos");
            var id= markers[i].getAttribute("id");
            var price= markers[i].getAttribute("price");
            var bookinglink = markers[i].getAttribute("booking_url");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, name, address, photo, bookinglink, id, price);
            map.addOverlay(marker);
            map.setCenter(point,12);
          }
 
        }   
      );
        place = response.Placemark[0];
        point1 = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        //marker = new GMarker(point);
        //map.addOverlay(marker);
        //map.setCenter(point, 12);
        //marker.openInfoWindowHtml(place.address + '<br>' +
          //'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
       
        
      }
    }

    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation() {
       //alert (document.search.startdate.value);
      var address = document.forms[0].region_id.value;
      geocoder.getLocations(address, addAddressToMap);
      
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.forms[0].region_id.value = address;
      showLocation();
    }
    
