var map;
var geoXml = new GGeoXml("http://eeipecs.hu/maps.kml");

function Load() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(46.070000,18.222349), 14);
    //map.addControl(new GLargeMapControl());
    map.addControl(new TextualZoomControl());
    map.addOverlay(geoXml);
  }
	var bounds = map.getBounds();
	var southWest = bounds.getSouthWest();
	var northEast = bounds.getNorthEast();
	var lngSpan = northEast.lng() - southWest.lng();
	var latSpan = northEast.lat() - southWest.lat();
}

function addAddressToMap(x,y,text) {
	map.clearOverlays();
	map.setCenter(new GLatLng(x+0.003,y-0.007), 15);
    window.setTimeout(function() {
  		map.panTo(new GLatLng(x,y));
		}, 1000);
    point = new GLatLng(x,y);
    marker = new GMarker(point);
    map.addOverlay(marker);
    marker.openInfoWindowHtml(text);
    }


function TextualZoomControl() {
   }

TextualZoomControl.prototype = new GControl();

TextualZoomControl.prototype.initialize = function(map) {
     var container = document.createElement("div");

     var zoomInDiv = document.createElement("div");
     this.setButtonStyle_(zoomInDiv);
     container.appendChild(zoomInDiv);
     zoomInDiv.appendChild(document.createTextNode("Közelít"));
     GEvent.addDomListener(zoomInDiv, "click", function() {
     map.zoomIn();
     });

     var zoomOutDiv = document.createElement("div");
     this.setButtonStyle_(zoomOutDiv);
     container.appendChild(zoomOutDiv);
     zoomOutDiv.appendChild(document.createTextNode("Távolít"));
     GEvent.addDomListener(zoomOutDiv, "click", function() {
     map.zoomOut();
     });

     /*
     var normalDiv = document.createElement("div");
     this.setButtonStyle2_(normalDiv);
     container.appendChild(normalDiv);
     normalDiv.appendChild(document.createTextNode("Térkép"));
     GEvent.addDomListener(normalDiv, "click", function() {
     map.setMapType(G_NORMAL_MAP);
     });

     var satDiv = document.createElement("div");
     this.setButtonStyle3_(satDiv);
     container.appendChild(satDiv);
     satDiv.appendChild(document.createTextNode("Szatelit"));
     GEvent.addDomListener(satDiv, "click", function() {
     map.setMapType(G_SATELLITE_MAP);
     });

         var mindketDiv = document.createElement("div");
     this.setButtonStyle4_(mindketDiv);
     container.appendChild(mindketDiv);
     mindketDiv.appendChild(document.createTextNode("Mindkét"));
     GEvent.addDomListener(mindketDiv, "click", function() {
     map.setMapType(G_HYBRID_MAP);
     });
     */

     map.getContainer().appendChild(container);
     return container;
}

TextualZoomControl.prototype.getDefaultPosition = function() {
     return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle_ = function(button) {
     button.style.textDecoration = "none";
     button.style.color = "#222";
     button.style.backgroundColor = "#E3E3E3";
     button.style.font = "small Arial";
     button.style.border = "3px solid #FFFFFF";
     button.style.padding = "2px";
     button.style.marginBottom = "3px";
     button.style.textAlign = "center";
     button.style.width = "6em";
     button.style.cursor = "pointer";
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle2_ = function(button2) {
     button2.style.textDecoration = "none";
     button2.style.color = "#222";
     button2.style.backgroundColor = "#E3E3E3";
     button2.style.font = "small Arial";
     button2.style.border = "3px solid #FFFFFF";
     button2.style.padding = "2px";
     button2.style.margin= "-58px 0 0 515px";
     button2.style.textAlign = "center";
     button2.style.width = "6em";
     button2.style.cursor = "pointer";
     button2.style.position = "absolute";
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle3_ = function(button3) {
     button3.style.textDecoration = "none";
     button3.style.color = "#222";
     button3.style.backgroundColor = "#E3E3E3";
     button3.style.font = "small Arial";
     button3.style.border = "3px solid #FFFFFF";
     button3.style.padding = "2px";
     button3.style.margin= "-58px 0 0 607px";
     button3.style.textAlign = "center";
     button3.style.width = "6em";
     button3.style.cursor = "pointer";
     button3.style.position = "absolute";
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle4_ = function(button4) {
     button4.style.textDecoration = "none";
     button4.style.color = "#222";
     button4.style.backgroundColor = "#E3E3E3";
     button4.style.font = "small Arial";
     button4.style.border = "3px solid #FFFFFF";
     button4.style.padding = "2px";
     button4.style.margin= "-58px 0 0 699px";
     button4.style.textAlign = "center";
     button4.style.width = "6em";
     button4.style.cursor = "pointer";
     button4.style.position = "absolute";
}