/**
 * @author toby
 */
var CustomControl = function(thismap){
	this.setText("zoom in");
	this.setTextOff("zoom in");
	this.setWidth(100);
	this.setHeight(15);
	this.setClassname("map-button");
	this.setAnchor(G_ANCHOR_TOP_LEFT);
	this.setOffsetx(5);
	this.setOffsety(5);
	this.setType("zoomin");
	this.thismap = thismap;
}

CustomControl.prototype = new GControl(true);

CustomControl.prototype.initialize = function(map){

	this.container_ = document.createElement("div");
	this.container_.innerHTML = this.getText();
	this.container_.style.width = this.getWidth() + "px";
	this.container_.style.height = this.getHeight() + "px";
	this.container_.className = this.getClassname();
	this.container_.style.cursor =  "pointer";

	var customcontrol = this;
	var thismap = this.thismap;

	switch(this.getType()){
		
		/* Zoom In button */
		case "zoomin":
		GEvent.addDomListener(this.container_, "click", function(){
			var currentzoom = map.getZoom();
			if(currentzoom < 20){
				map.setZoom(currentzoom + 1);	
			}
			thismap.addMarkers();	
		});
		break;
		
		/* Zoom Out button */
		case "zoomout":
		GEvent.addDomListener(this.container_, "click", function(){
			var currentzoom = map.getZoom();
			if(currentzoom > 1){
				map.setZoom(currentzoom - 1);
			}
			thismap.addMarkers();		
		});
		break;
		
		/* Jump In Full button */
		case "jumpin":
		GEvent.addDomListener(this.container_, "click", function(){
			var currentzoom = map.getZoom();
			map.setZoom(17);
			thismap.addMarkers();		
		});
		break;
		
		/* Jump Out Full button */
		case "jumpout":
		GEvent.addDomListener(this.container_, "click", function(){
			var currentzoom = map.getZoom();
			map.setZoom(initZoom);
			thismap.addMarkers();		
		});
		break;
		
		case "showplacenames":
		GEvent.addDomListener(this.container_, "click", function(){
			var state = customcontrol.getState();
			if(state == "show"){
				customcontrol.setState("hide");
				customcontrol.container_.innerHTML = customcontrol.getTextOff();
				map.setMapType(G_HYBRID_MAP);
			}
			else{
				customcontrol.setState("show");
				customcontrol.container_.innerHTML = customcontrol.getText();
				map.setMapType(myMap.getMapType());
			}
		});
		break;
		
		case "reset":
		this.container_.setAttribute("id","resetbutton");
		GEvent.addDomListener(this.container_, "click", function(){
				map.clearOverlays();
				thismap.setLatitude(initLat);
				thismap.setLongitude(initLng);
				thismap.setLocation();
				thismap.setZoomLevel(initZoom);
				map.setCenter(thismap.getLocation(), thismap.getZoomLevel());
				thismap.markermngr.refresh();
		});
		break;
		
	}
	map.getContainer().appendChild(this.container_);
	return this.container_;
}

CustomControl.prototype.getDefaultPosition = function(){
	return new GControlPosition(this.anchor_, new GSize(this.offsetx_, this.offsety_));
}

CustomControl.prototype.setText = function(text){
	this.text_ = text;
}

CustomControl.prototype.getText = function(){
	return this.text_;
}

CustomControl.prototype.setTextOff = function(textoff){
	this.textoff_ = textoff;
}

CustomControl.prototype.getTextOff = function(){
	return this.textoff_;
}

CustomControl.prototype.setWidth = function(width){
	this.width_ = width;
}

CustomControl.prototype.getWidth = function(){
	return this.width_;
}

CustomControl.prototype.setHeight = function(height){
	this.height_ = height;
}

CustomControl.prototype.getHeight = function(){
	return this.height_;
}

CustomControl.prototype.setClassname = function(classname){
	this.classname_ = classname;
}

CustomControl.prototype.getClassname = function(){
	return this.classname_;
}

CustomControl.prototype.setAnchor = function(anchor){
	this.anchor_ = anchor;
}

CustomControl.prototype.getAnchor= function(){
	return this.anchor_;
}

CustomControl.prototype.setOffsetx = function(offsetx){
	this.offsetx_ = offsetx;
}

CustomControl.prototype.getOffsetx = function(){
	return this.offsetx_;
}

CustomControl.prototype.setOffsety = function(offsety){
	this.offsety_ = offsety;
}

CustomControl.prototype.getOffsety = function(){
	return this.offsety_;
}

CustomControl.prototype.setType = function(type){
	this.type_ = type;
}

CustomControl.prototype.getType = function(){
	return this.type_;
}

CustomControl.prototype.setState = function(state){
	this.state_ = state;
}

CustomControl.prototype.getState = function(){
	return this.state_;
}

