var SLIDERLENGTH = 150;
var MAXZOOM = 17;

function TRMControl() { }

TRMControl.prototype = new GControl();

TRMControl.prototype.setSlider = function(zoom) {
	var left = Math.round((SLIDERLENGTH/MAXZOOM*zoom));
	this.slide.left = left;
	this.knob.style.left = left+"px";
}

TRMControl.prototype.setZoom = function() {
	var z=Math.round(parseInt(this.slide.left)*MAXZOOM/SLIDERLENGTH);
	this.map.setZoom(z);
}


TRMControl.prototype.initialize = function(m) {
	var that=this;
	this.map = m;


	var RTrack = document.createElement("div");
	RTrack.className = "sliderTrackRight";

	var LTrack = document.createElement("div");
	LTrack.className = "sliderTrackLeft";

	this.knob = document.createElement("img"); 
	this.knob.src = "/Img/knob.png";
	LTrack.appendChild(this.knob);
	RTrack.appendChild(LTrack);

	this.slide=new GDraggableObject(this.knob, {container:RTrack});


 	m.getContainer().appendChild(RTrack);

 	GEvent.addListener(m, "zoomend", function(a,b) {that.setSlider(b)});

	GEvent.addListener(this.slide, "dragend", function() {that.setZoom()});
	//alert();

	return RTrack;
}

TRMControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(70, 13));
}
