var map;

var gmarkers = [];
var htmls = [];
var i = 0;
var y =0;
var side_bar_html = "";
var side_bar_html2 = "<table border=0 width=100%><tr><td width=30% valign=top>";

var geocoder = null;


function ShowMap( Elem, Latitude, Longtude, Zoom , Opis, Placeid, Cityid) {
    this.latitude  = Latitude;
    this.longtude  = Longtude;
    this.zoom   = Zoom;
    this.element= Elem;
    this.opis = Opis;
    this.placeid = Placeid;
    this.cityid = Cityid;
    this.show();
}

function ShowCityMap( Elem ) {
this.element= Elem;
	this.show();
}    


function CloseObjects(placeid) {
this.placeid = placeid;
}

CloseObjects.prototype = new GControl();
CloseObjects.prototype.initialize = function(map) {
    var container = document.createElement("div");
    var zoomInDiv2 = document.createElement("div");
    var pl = this.placeid;
    this.setButtonStyle_(zoomInDiv2);
    container.appendChild(zoomInDiv2);
    map.getContainer().appendChild(container);
    return container;
}

CloseObjects.prototype.setButtonStyle_ = function(button) {
    with(button.style) {
        paddingLeft="1px";
        border="1px solid black";
        cursor="pointer";
        color="#000";
        backgroundColor="#fff";
        font="12px Arial";
        width="67px";
        textAlign="center";
        marginBottom="1px";
    }
}



ShowMap.prototype.show = function() {
    if (GBrowserIsCompatible()) {
	map   = new GMap2( this.element );
	var point = new GLatLng( this.latitude, this.longtude );
	map.setCenter( point, this.zoom );
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.enableContinuousZoom();

    scale = new GScaleControl(); 
    
    map.addControl(scale); 
    
    map.addControl(new CloseObjects(this.placeid));
    						
		var icon = new GIcon();
		icon.image = "http://www.google.com/mapfiles/markerR.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(20, 34);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);						
							
	var marker = new GMarker(point , icon)
	map.addOverlay( marker );
	var opisik = this.opis;
	
	if(opisik !="")
	{
	    marker.openInfoWindowHtml(opisik);

	    GEvent.addListener(marker, "click", function() {
	        marker.openInfoWindowHtml(opisik);
	    });
	}
	
   }	
}




  

	 

function zout()
{
 		map.zoomOut();		
}
function zin()
{
 		map.zoomIn();		
}