

// Kezdő koordináták:
var start_x = 47.450677;
var start_y = 19.038396;
var defzoom = 15;

// teszt buborék
var message = "<b>Újbuda Terasz Étterem</b><br>1116 Budapest, Fehérvári út 168-178/a fszt. 10.";

// gombok URL
var usedefault = false; //használja e a beépített gombokat, ha true, akkor nem ''-val töltsük fel a köv. sorokat!
var uparrow = 'images/arrow_up.png';
var downarrow = 'images/arrow_down.png';
var leftarrow = 'images/arrow_left.png';
var rightarrow = 'images/arrow_right.png';
var zoomin = 'images/zoom_in.png';
var zoomout = 'images/zoom_out.png';
var centerbutt = 'images/arrow_center.png';


function load() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(start_x, start_y), defzoom); // ((x,y),zoom level)
    map.setMapType(G_HYBRID_MAP);
    
       // ---- Szövegbuborék ---- 
        //map.openInfoWindow(map.getCenter(), document.createTextNode("Hello, world"));
		
        // ************************************************************************
        
        // ---- Koordináta kiirás ----
    /*GEvent.addListener(map, "moveend", function() {
      var center = map.getCenter();
      document.getElementById("message").innerHTML = center.toString();
      });*/
        
        //*************************************************************************
        

    // Függvény ami mutatót tesz a megadott helyre, a mutatóra kattintva eltünik/előjön a buborék
	    /*function createMarker(point, title, address) {
	      var marker = new GMarker(point);
	      marker.value = title;
	      GEvent.addListener(marker,"click", function() {
	        var myHtml = "<b>"+ title + "</b><br/>" + address;
	        map.openInfoWindowHtml(point, myHtml);
	      });
		  return marker;
	    }*/
	    
	   
	   
	   
	   
	    var baseIcon = new GIcon();
        baseIcon.shadow = "images/bubble_shad.png";
        baseIcon.iconSize = new GSize(40, 42);
        baseIcon.shadowSize = new GSize(45, 50);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index) {
          // Create a lettered icon for this point using our icon class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "images/bubble.png";

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("<font color='black'>"+message+"</font>");
          });
          return marker;
        }
        
        point = new GLatLng(start_x, start_y);
        map.addOverlay(createMarker(point,1));
	   
	   
	   
	   
	   
			
		//******************************************************************************
		
		// ---- Zoom, meg a többi :D ----
		
		var posiTion = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		/* ez a pozicionáló! : - mihez képest? -> ( G_ANCHOR_TOP_RIGHT, 
													G_ANCHOR_TOP_LEFT, 
													G_ANCHOR_BOTTOM_RIGHT, 
													G_ANCHOR_BOTTOM_LEFT) ->értelemszerüen
								- ennyivel -> GSize (x,y) */
 
		//map.addControl(new GLargeMapControl(),posiTion); // zoom, [opt pozíciója] ... alapértelmezésben a bal felső
       
		
		
		function TextualZoomControl() {
		    }
	    TextualZoomControl.prototype = new GControl();

	    TextualZoomControl.prototype.initialize = function(map) {
	      var container = document.createElement("div"); 
	      
	       var panUpDiv = document.createElement("div");
	      this.setButtonStyle_(panUpDiv);
	      container.appendChild(panUpDiv);
	      panUpDiv.style.backgroundImage = "url('"+uparrow+"')";
	      panUpDiv.appendChild(document.createTextNode(" "));
	      GEvent.addDomListener(panUpDiv, "click", function() {
	        map.panDirection(0,1);
	      });
	      
	      var panLeftDiv = document.createElement("div");
	      this.setButtonStyle_(panLeftDiv);
	      container.appendChild(panLeftDiv);
	      panLeftDiv.style.backgroundImage = "url('"+leftarrow+"')";
	      panLeftDiv.style.position = 'relative';
	      panLeftDiv.style.left = '-18';
	      panLeftDiv.appendChild(document.createTextNode(" "));
	      GEvent.addDomListener(panLeftDiv, "click", function() {
	        map.panDirection(1,0);
	      });
	      
	      var panRightDiv = document.createElement("div");
	      this.setButtonStyle_(panRightDiv);
	      container.appendChild(panRightDiv);
	      panRightDiv.style.backgroundImage = "url('"+rightarrow+"')";
	      panRightDiv.style.position = 'relative';
	      panRightDiv.style.left = '18';
	      panRightDiv.style.top = '-19.5';
	      panRightDiv.appendChild(document.createTextNode(""));
	      GEvent.addDomListener(panRightDiv, "click", function() {
	        map.panDirection(-1,0);
	      });
	      
	      var panDownDiv = document.createElement("div");
	      this.setButtonStyle_(panDownDiv);
	      container.appendChild(panDownDiv);
	      panDownDiv.style.backgroundImage = "url('"+downarrow+"')";
	      panDownDiv.style.position = 'relative';
	      panDownDiv.style.top = '-19.5';
	      panDownDiv.appendChild(document.createTextNode(""));
	      GEvent.addDomListener(panDownDiv, "click", function() {
	        map.panDirection(0,-1);
	      });
	      var centerpoint = new GLatLng(start_x, start_y);
	      var panCenterDiv = document.createElement("div");
	      this.setButtonStyle_(panCenterDiv);
	      container.appendChild(panCenterDiv);
	      panCenterDiv.style.backgroundImage = "url('"+centerbutt+"')";
	      panCenterDiv.style.position = 'relative';
	      panCenterDiv.style.top = '-58.5';
	      panCenterDiv.appendChild(document.createTextNode(""));
	      GEvent.addDomListener(panCenterDiv, "click", function() {
	        map.panTo(centerpoint);
	      });
	      
	      var zoomInDiv = document.createElement("div");
	      this.setButtonStyle_(zoomInDiv);
	      container.appendChild(zoomInDiv);
	      zoomInDiv.style.backgroundImage = "url('"+zoomin+"')";
	      zoomInDiv.style.position = 'relative';
	      zoomInDiv.style.top = '-39';
	      zoomInDiv.appendChild(document.createTextNode(""));
	      GEvent.addDomListener(zoomInDiv, "click", function() {
	        map.zoomIn();
	      });
	
	      var zoomOutDiv = document.createElement("div");
	      this.setButtonStyle_(zoomOutDiv);
	      container.appendChild(zoomOutDiv);
	      zoomOutDiv.style.backgroundImage = "url('"+zoomout+"')";
	      zoomOutDiv.style.position = 'relative';
	      zoomOutDiv.style.top = '-39';
	      zoomOutDiv.appendChild(document.createTextNode(""));
	      GEvent.addDomListener(zoomOutDiv, "click", function() {
	        map.zoomOut();
	      });
	      
	      map.getContainer().appendChild(container);
	      return container;
		  }
		
		TextualZoomControl.prototype.getDefaultPosition = function() {
		      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(20, 5));
		    }
		
		TextualZoomControl.prototype.setButtonStyle_ = function(button) {
		      button.style.textDecoration = "none";
		      button.style.color = "#ffffff";
		      button.style.height = "13px";
		      button.style.width = "13px";
		      button.style.font = "Arial";
		      button.style.border = "0";
		      button.style.padding = "2px";
		      button.style.marginBottom = "3px";
		      button.style.textAlign = "center";
		      button.style.cursor = "pointer";
		   }
		
		
		
		map.addControl(new TextualZoomControl());
		
		map.addControl(new GMapTypeControl()); // nézet (Map,Satellite,Hybrid)
		
		// kiirja a kattintás helyének infóit
		/*GEvent.addListener(map,"click", function(overlay,point) {     
          var myHtml = "The GPoint value is: " + map.fromLatLngToDivPixel(point) + " at zoom level " + map.getZoom();
          map.openInfoWindow(point, myHtml);
        });*/
		
        //********************************************************************************
		// ide jönne egy számláló, ami a térképre kettintást számolja, csak nagyon át kéne
		// variálni az egészet hozzá ezért csak megjegyzem, hogy ez is megoldható!
		//********************************************************************************
   		
		
		
		function TextOut() {
		    }
	    TextOut.prototype = new GOverlay();

	    TextOut.prototype.initialize = function(map) {
	      var cont = document.createElement("div");
	      
	       var textDiv = document.createElement("div");
	      this.setButtonStyle2_(textDiv);
	      cont.appendChild(textDiv);
	      textDiv.appendChild(document.createTextNode("blaaablabalacd"));
	      
	      map.getContainer().appendChild(cont);
	      return cont;
		  }
		
		TextOut.prototype.setButtonStyle2_ = function(button) {
		      button.style.color = "#ffffff";
		      button.style.height = "13px";
		      button.style.width = "13px";
		      button.style.backroundColor = '#ffffff';
		      button.style.font = "Arial";
		      button.style.border = "0";
		      button.style.padding = "2px";
		      button.style.marginBottom = "3px";
		      button.style.textAlign = "center";
		      button.style.cursor = "pointer";
		   }
		
		
		
		map.addControl(new TextualZoomControl());
		
		    
      }
    }