﻿/**
 * tcBarScroller
 *
 * @version		1.02		29.09.10	-	added getWidth
 *
 * @param		String		rscoller name
 * @param		String		lscoller namee
 * @param		Object		Object to scroll
 * @param		String		Container Name (optional)
 */

function	tcBarScroller(  zizzer, slidername, knobname, slidersteps, cname)	{

	this._setHasClicked		=	function()	{
		this.zizzer.setHasClicked();
	}

	this._scrollTo			=	function( value )	{
		newx	=	this.each_slide_click_advance * value;
		this.zizzer.scrollToLocation( newx, 0);
	}

	this.scrollToLocation	=	function( value )	{
		this.slider.set(value);
	}

	this.getWidth	=	function()	{
		return	this.slider_steps;
	}

	this.updateLocation	=	function( value )	{
		this.updating = 1;
		this.slider.set( value );
	}

	this.zizzer				=	zizzer;
	this.slider_el			=	$(slidername);
	this.knob_el			=	$(knobname);
	this.scroll_width		=	this.zizzer.getPixelsOffRhs();
	this.slider_steps		=	slidersteps;
	this.updating			=	0;
	
	this.each_slide_click_advance	=	this.scroll_width / slidersteps;

	this.slider		=	new Slider( this.slider_el, this.knob_el, {
		steps: this.slider_steps,
		range: [0],

		onChange: function( value )	{
			if( !this.updating )	{
				newx	=	this.each_slide_click_advance * value;
				this.zizzer.scrollToLocation( newx, 0);
			}
			this.updating = 0;
		}.bind(this),

		onComplete : function()	{}
	}).set(0);

	this.knob_el.addEvent( 'mousedown',  this._setHasClicked.bind(this) );
	this.slider_el.addEvent( 'mousedown',  this._setHasClicked.bind(this) );
}

