function exgmSliderControl(){}

exgmSliderControl.prototype = new GControl();

exgmSliderControl.prototype.initialize = function(map) {
	
	this.map = map;
	var sliderObj = this;
	var container = document.createElement("div");
	
	map.getContainer().appendChild(container);
	
	Ext.ux.exgmSliderControlTip = Ext.extend(Ext.Tip, {
		minWidth: 10,
		offsets : [0, -10],
		init : function(slider){
			slider.on('dragstart', this.onSlide, this);
			slider.on('drag', this.onSlide, this);
			slider.on('dragend', this.hide, this);
			slider.on('destroy', this.destroy, this);
		},
		
		onSlide : function(slider){
			this.show();
			this.body.update(this.getText(slider));
			this.doAutoWidth();
			this.el.alignTo(slider.thumb, 'b-t?', this.offsets);
		},
		
		getText : function(slider){
			return slider.getValue();
		}
	});
	
    this.slider = new Ext.Slider({
        renderTo: container,
        height: 100,
        value:0,
        increment: 1,
        minValue: 0,
        vertical: true,
        maxValue: 17,
        plugins: new Ext.ux.exgmSliderControlTip(),
        listeners: {
			'change': {
				fn: this.setZoom,
				scope: this
			}
		}
    });

	GEvent.addListener(map, "zoomend", function(a,b) { sliderObj.setSlider(b) });
	
	return container;
}

exgmSliderControl.prototype.setZoom = function() {
	this.map.setZoom(this.slider.getValue());
}

exgmSliderControl.prototype.setSlider = function(zoom) {
	this.slider.setValue(zoom);
}

exgmSliderControl.prototype.getDefaultPosition = function() {
 	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}
