	var map;
	var manager;
	var icons = [];
	function loadmarkerdesc(i) { return true; }
	function calculatePanTo(point) {
	  marker = new GMarker(point);
    var pixPosition = map.fromLatLngToDivPixel(marker.getLatLng());
    var pixPosition_mapcenter = map.fromLatLngToDivPixel(map.getCenter());
    var mapWidth = map.getSize().width;
    var mapHeight = map.getSize().height;
    var bounds = map.getBounds();
    var boundsSpan = bounds.toSpan();
    var longSpan = boundsSpan.lng();
    var latSpan = boundsSpan.lat();

    var width_ = document.getElementById('div_1').offsetWidth;
    var height_ = document.getElementById('div_1').offsetHeight + 60;

    var degWidth = (width_/mapWidth) * longSpan;
    var degHeight = (height_/mapHeight) * latSpan;


    if(!bounds.contains(point)) {
    var pix = {x: pixPosition.x, y:(pixPosition.y  + map.getSize().height/2 ) -  height_};
    return map.fromDivPixelToLatLng(pix);
    }

    var bottompt = new GLatLng( (marker.getLatLng().lat() + degHeight), marker.getLatLng().lng());
    if (!bounds.contains(bottompt) || (marker.getLatLng().lng() + degWidth > bounds.getNorthEast().lng())) {
        if((marker.getLatLng().lng() + degWidth > bounds.getNorthEast().lng()))
        var pix = {x: pixPosition.x, y: (pixPosition.y  + map.getSize().height/2 ) -  height_}
        else
        var pix = {x: pixPosition_mapcenter.x, y: (pixPosition.y  + map.getSize().height/2 ) -  height_}
        return map.fromDivPixelToLatLng(pix);
    }
    return map.getCenter();
  }
var HideTimer;
function przewodnik_mapa(przewodnik) {
        if(!ep_markers[przewodnik] || przewodnik <=0) return;
	  		ewindow.openOnMarker(ep_markers[przewodnik],ep_htmls[przewodnik]);
        map.panTo(calculatePanTo(ep_markers[przewodnik].getPoint()));
}

function load(x,y,z,obiekt) {
	x=48.12287993415022; y=14.4140625; z=5;


	ep_icon = new GIcon();
  ep_icon.iconSize = new GSize(35, 37);  
	ep_icon.iconAnchor = new GPoint(14, 0);
	ep_icon.infoWindowAnchor = new GPoint(12, 10);
	ep_icon.image = "images/ep_icon.png";

	if (GBrowserIsCompatible()) {

		map = new GMap2(document.getElementById("map"));
		//map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(x,y),z);
    map.addMapType(G_PHYSICAL_MAP) ;

    ewindow = new EWindow(map, E_STYLE_7);
    map.addOverlay(ewindow);
    
    manager = new MarkerManager(map);

    dget('map_loading_objects').style.display='block'; 
    advAJAX.get({    
      url: "geosearch_mainpage.php?id=0",      
  		    onSuccess : function(obj) { eval(obj.responseText);  }
  		}
    );		



 	}
	return map;
}
function do_geosearch_mainpage(id,bounds) {
  advAJAX.get({    
    url: "geosearch_mainpage.php?id=" + id + "&bounds=" + bounds,      
		    onSuccess : function(obj) { eval(obj.responseText);  }
		}
  );		
}

