/*
 * a class for zooming and centering the window to specific points.
 * the particulars are for now hard coded
 *
 * inspired by http://code.google.com/intl/de-CH/apis/maps/documentation/controls.html
 *
 * (c) David Buchmann, 2009
 */
function JumpToPlacesControl() {}

JumpToPlacesControl.prototype = new GControl();

/*
 * create a div for each control
 * places it into a div for the size and this into the div gmap2 uses to get our data.
 *
 * the container is added to the map container and return to the maps code for positioning.
 *
 * looks like jquery is not working to create nodes gmaps is happy with
 */
JumpToPlacesControl.prototype.initialize = function(map) {
    var container = document.createElement("div");
    var extradiv = document.createElement("div");
    extradiv.style.width = '160px';
    container.appendChild(extradiv);

    var jumpSwitzerland = document.createElement("div");
    this.setButtonStyle_(jumpSwitzerland);
    extradiv.appendChild(jumpSwitzerland);
    var s = document.createElement("img");
    s.setAttribute("alt", "Schweiz");
    s.setAttribute("title", "Schweiz");
    if ($.browser.msie && parseInt($.browser.version) < 7) {
        s.setAttribute("src", "img/switzerland.gif");
    } else {
        s.setAttribute("src", "img/switzerland.png");
    }
    jumpSwitzerland.appendChild(s);
    GEvent.addDomListener(jumpSwitzerland, "click", function() {
        map.setCenter(new GLatLng(46.977, 8.581), 7);
    });

    var jumpWorld = document.createElement("div");
    this.setButtonStyle_(jumpWorld);
    jumpWorld.style.position = "absolute";
    jumpWorld.style.top = "0px";
    jumpWorld.style.left = "60px";
    extradiv.appendChild(jumpWorld);
    var s = document.createElement("img");
    s.setAttribute("alt", "Welt");
    s.setAttribute("title", "Welt");
    if ($.browser.msie && parseInt($.browser.version) < 7) {
        s.setAttribute("src", "img/world.gif");
    } else {
        s.setAttribute("src", "img/world.png");
    }

    jumpWorld.appendChild(s);
    GEvent.addDomListener(jumpWorld, "click", function() {
        map.setCenter(new GLatLng(26.977, 10.581), 2);
    });

    map.getContainer().appendChild(container);
    return container;
}

/* standard position: right of the move and zoom control */
JumpToPlacesControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(70, 7));
}

/* define css */
JumpToPlacesControl.prototype.setButtonStyle_ = function(button) {
button.style.textAlign = "center";
    button.style.width = "60px";
    button.style.cursor = "pointer";
}

