
RevertControl.prototype = new MQA.Control();
RevertControl.prototype.constructor = RevertControl;
function RevertControl(){

	this.zIndex = 100;
	this.imageSrc = "img/MISC/revert_off.png";

	this.position = new MQA.MapCornerPlacement(MQA.MapCorner.BOTTOM_LEFT, new MQA.Size(40, 5));
	this.map = null;
	
	this._render = function(){
		
		this.elem = document.createElement("div"); 
		this.elem.style.height = "22px";
		this.elem.style.width = "26px";
		
		if(this.elem.style.overflow)
			this.elem.style.overflow = "none";
		else 
			this.elem.style.cssText = "overflow: none;";
		
		this.elem.style.position = "absolute"; 
	
		this.div = document.createElement("div");
		this.div.id = "container";
		this.div.style.height = "22px";
		this.div.style.width = "26px";
		this.div.style.zIndex = this.zIndex;
		this.div.style.position = "relative";
		this.elem.appendChild(this.div);
				
		this.layerImage = document.createElement("img");
		this.layerImage.type = "image";
		this.layerImage.src = this.imageSrc;
		this.layerImage.style.cssText = "height:" + "22px; width:" + "26px;";
		this.layerImage.border= "0px";
		this.div.appendChild(this.layerImage);
	}
	
	this._render();
	
}

RevertControl.prototype.initialize = function(map){
		this.map = map;
		
		SeisanEventHandler(this.layerImage, "click", this.eventmonitor, this);
		SeisanEventHandler(this.layerImage, "mouseout", this.eventmonitor, this);
		SeisanEventHandler(this.layerImage, "mouseover", this.eventmonitor, this);
		
	
		//Event.observe(this.layerImage, "click", this.eventCallback("eventmonitor"));
		//Event.observe(this.layerImage, "mouseout", this.eventCallback("eventmonitor"));
		//Event.observe(this.layerImage, "mouseover", this.eventCallback("eventmonitor"));
}

RevertControl.prototype.eventmonitor = function(evt){
	switch(evt.type){
		case "click":
			try
			{
				this.map.getInfoWindow().hide();
			}
			catch(ex)
			{}
			this.map.restoreState();
			
			break;
		case "mouseout":
			this.layerImage.src = "img/MISC/revert_off.png";
			break;
		case "mouseover":
			this.layerImage.src = "img/MISC/revert_on.png";
			break;
	}
	return true;	
}

RevertControl.prototype.eventCallback = function(f_0){
	var c21 = this;
	return function(event){if(!event){event = window.event;}c21[f_0](event);};
}
