// JavaScript Document

    var map = null;
    var geocoder = null;

    function initialize(address) {
      
	  if (GBrowserIsCompatible()) {
	  
	  	function TextualZoomControl() {
		}
		
		TextualZoomControl.prototype = new GControl();

		TextualZoomControl.prototype.initialize = function(map) {
			var container = document.createElement("div");
			var zoomInDiv = document.createElement("div");
			var logo = document.createElement("img");
			logo.src="img/logo_na_mapu.jpg";
			
			this.setButtonStyle_(zoomInDiv);
			container.appendChild(zoomInDiv);
			zoomInDiv.appendChild(logo);

			map.getContainer().appendChild(container);
			return container;
		}
		
		// By default, the control will appear in the top left corner of the
		// map with 7 pixels of padding.
		TextualZoomControl.prototype.getDefaultPosition = function() {
			return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50, 0));
		}

		
		// Sets the proper CSS for the given button element.
		TextualZoomControl.prototype.setButtonStyle_ = function(button) {
			button.style.marginLeft="30px";
		}
			
        map = new GMap2(document.getElementById("map_canvas"));
		
		
		map.addControl(new GScaleControl());
		map.addControl(new TextualZoomControl());
		
		
        geocoder = new GClientGeocoder();
		
		map.setUIToDefault();
		
		map.disableScrollWheelZoom(); 
		
		
		showAddress(address);
		
      }
	}
	
	function showAddress(address){
		
		if (geocoder) {
	
			gps=address.split("#");
			
			if(gps.length>1){
				
				// vyhaldavame podla GPS
				point=new GLatLng(gps[0],gps[1]);
				map.setCenter(point, 15);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				
			}else{
			
				// vyhladavame podla adresy
				geocoder.getLatLng(
				  address,
				  function(point) {
					if (!point) {
					  //alert("Adresu \""+ address + "\" sa nepodarilo nájsť.");
					  var splitted=address.split(",");
					  if(splitted.length>0){
						  showAddress(address.substring(0,address.lastIndexOf(',')));
					  }else{
						  alert("Adresu \""+ address + "\" sa nepodarilo nájsť.");
					  }
					} else {
					  map.setCenter(point, 15);
					  var marker = new GMarker(point);
					  map.addOverlay(marker);
					  //marker.openInfoWindowHtml(address);
					}
				  }
				);
			}
			
		  }
		
	}
	
	function showForumlar(action){
		
		var rTitle=document.getElementById('reagovatTitle').style;
		var r=document.getElementById('reagovatContainer').style;
		var oTitle=document.getElementById('odporucTitle').style;
		var o=document.getElementById('odporucContainer').style;
		
		if(action=='reagovat'){
			rTitle.display="block";
			r.display="block";
			oTitle.display="none";
			o.display="none";
		}else if(action=='odporucit'){
			rTitle.display="none";
			r.display="none";
			oTitle.display="block";
			o.display="block";
		}
		
		/*document.location="#formular";*/
		
	}

  	function displayFull(newFile,id,img){
  	
		var mainHref = document.getElementById('bighref');	
		
		mainHref.innerHTML="<img src="+newFile+" onclick=\"window.open('gallery.php?inz="+id+"&img="+img+"','','scrollbars=yes,width=1050,height=700')\" id=\"mainImage\" alt=\"\" border=\"0\" />";
		
	}

