var map;
var geoXml = new GGeoXml("http://qx-impex.hu/qx_maps.kml");

function Load() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(46.897747,19.312979), 7);
    //map.addControl(new GLargeMapControl());
    FullMenu = 0;
    map.addControl(new TextualZoomControl());
    map.addOverlay(geoXml);
  }
}

function LoadPecs() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(46.059727, 18.213573), 14);
	    FullMenu = 0;
        map.addControl(new TextualZoomControl());

        GEvent.addListener(map, "moveend", function() {
        var center = map.getCenter();
        });

        var baseIcon = new GIcon();
        baseIcon.shadow = "http://maps.google.com/mapfiles/ms/icons/msmarker.shadow.png";
        baseIcon.iconSize = new GSize(32, 32);
        baseIcon.shadowSize = new GSize(59, 32);
        baseIcon.iconAnchor = new GPoint(9, 32);
        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 icon = new GIcon(baseIcon);
        icon.image = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png";
        var marker = new GMarker(point, icon);

        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml("<b>QX-Impex Kft. (Pécs)</b><br/>H-7623 - Pécs<br>Megyeri Út 59.");
        });
        return marker;
        }

        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();


        var point = new GLatLng(46.059727, 18.213573);
        map.addOverlay(createMarker(point, 1));

      }
}

function LoadBudapest() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(47.496102, 19.103026), 15);
        FullMenu = 1;
        map.addControl(new TextualZoomControl());

        GEvent.addListener(map, "moveend", function() {
        var center = map.getCenter();
        });

        var baseIcon = new GIcon();
        baseIcon.shadow = "http://maps.google.com/mapfiles/ms/icons/msmarker.shadow.png";
        baseIcon.iconSize = new GSize(32, 32);
        baseIcon.shadowSize = new GSize(59, 32);
        baseIcon.iconAnchor = new GPoint(9, 32);
        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 icon = new GIcon(baseIcon);
        icon.image = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png";
        var marker = new GMarker(point, icon);

        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml("<b>QX-Impex Kft. (Budapest)</b><br/>H-1087 - Budapest - VIII. ker.<br>Asztalos Sándor u. 9.");
        });
        return marker;
        }

        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();


        var point = new GLatLng(47.494602, 19.102026);
        map.addOverlay(createMarker(point, 1));

      }
}

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(kozelit));
     GEvent.addDomListener(zoomInDiv, "click", function() {
       map.zoomIn();
     });

     var zoomOutDiv = document.createElement("div");
     this.setButtonStyle_(zoomOutDiv);
     container.appendChild(zoomOutDiv);
     zoomOutDiv.appendChild(document.createTextNode(tavolit));
     GEvent.addDomListener(zoomOutDiv, "click", function() {
       map.zoomOut();
     });

  if (FullMenu == 1) {
     var normalDiv = document.createElement("div");
     this.setButtonStyle2_(normalDiv);
     container.appendChild(normalDiv);
     normalDiv.appendChild(document.createTextNode(terkep));
     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(mindket));
     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 #fff";
     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 #fff";
     button2.style.padding = "2px";
     button2.style.margin= "-58px 0 0 315px";
     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 #fff";
     button3.style.padding = "2px";
     button3.style.margin= "-58px 0 0 407px";
     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 #fff";
     button4.style.padding = "2px";
     button4.style.margin= "-58px 0 0 499px";
     button4.style.textAlign = "center";
     button4.style.width = "6em";
     button4.style.cursor = "pointer";
     button4.style.position = "absolute";
}