var LARGE_MAP_WIDTH = 720;
var ENLARGE_MAP_TITLE = "js_enlarge_map_title";
var REDUCE_MAP_TITLE = "js_reduce_map_title";

// We define the function first
function ResizeMapControl() {
	this.full = false;
	this.self = this;
}

// To "subclass" the GControl, we set the prototype object to
// an instance of the GControl object
ResizeMapControl.prototype = new GControl();

// Creates an IMG Element as our control element. We add the control to
// to the map container and return the element for the map class to
// position properly.
ResizeMapControl.prototype.initialize = function(map) {
  var controlImg = document.createElement("img");
  controlImg.setAttribute("src", "../../img/enlarge.gif");
  controlImg.setAttribute("title",i8nMessages[ENLARGE_MAP_TITLE]);
  GEvent.addDomListener(controlImg, "click", function() {
    if (self.full) {
    	resizeMapDiv(mapWidth);
    	self.full = false;
    	controlImg.setAttribute("src", "../../img/enlarge.gif");
    	controlImg.setAttribute("title",i8nMessages[ENLARGE_MAP_TITLE]);
    } else {
    	resizeMapDiv(LARGE_MAP_WIDTH);
    	self.full = true;
    	controlImg.setAttribute("src", "../../img/reduce.gif");
    	controlImg.setAttribute("title",i8nMessages[REDUCE_MAP_TITLE]);
    }
  });
  map.getContainer().appendChild(controlImg);
  return controlImg;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
ResizeMapControl.prototype.getDefaultPosition = function() {
	var mapHeight = mapWidth / 2;
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, mapHeight));
}

