// Call this constructor function with an object defining the following properties:
// .sliderobj = the object to act on
// .pausebutton = the pause button to use with this
function tbSliderDiv(inob)
{
	// the value that is added or subtracted from the slider object scrollwidth
	var clipleft = 0;
	// the value tha tis added or subtracted from the slider object scrollheight
	var cliptop = 0;
	// the interval timer for the timer's movements.
	var timer;
	// determines whether we're adding or subtracting clipleft or cliptop, the change is multiplied by 1 or -1
	var multiplier = 1;
	// is the slider currently moving?
	var slidermoving = false;
	// the left, right, up or down button pressed to activate the slider
	var currentbutton;
	// the sliding object containing the thumbnails
	var sliderobj = Object.isElement(inob.sliderobj) ? inob.sliderobj : null;
	var wi = sliderobj.getWidth();
	var hi = sliderobj.getHeight();
	// hold on to the enter image's 'src' value
	var src = '';
	// the current image object to update
	var currentimg = null;
	// the stop/pause button
	var pausebutton = inob.pausebutton;
	// The left/right slide action is performed in here
	function slideViewLeftRight()
	{
		var stopsliding = false;
		clipleft += (3 * multiplier);
		if(clipleft < 0)
		{
			clipleft = 0;
			stopsliding = true;
		}
		else if(clipleft > sliderobj.scrollWidth - wi)
		{
			clipleft = sliderobj.scrollWidth - wi;
			stopsliding = true;
		}
		sliderobj.scrollLeft = clipleft;
		if(stopsliding)
		{
			_startStopSlider({ob:currentbutton,m:0,w:'leftright'});
		}
	}
	// The up/down slide action is performed in here
	function slideViewUpDown()
	{
		var stopsliding = false;
		cliptop += (3 * multiplier);
		if(cliptop < 0)
		{
			cliptop = 0;
			stopsliding = true;
		}
		else if(cliptop > sliderobj.scrollHeight - hi)
		{
			cliptop = sliderobj.scrollHeight - hi;
			stopsliding = true;
		}
		sliderobj.scrollTop = cliptop;
		if(stopsliding)
		{
			_startStopSlider({o:currentbutton,m:0,w:'updown'});
		}
	}
	// inob should contain:
	// .o = the button that activated this
	// .m = the multiplier that will be used, use 1 to move right or down, use -1 to move left or up
	// .w = one of two values: 'leftright' or 'updown' depending upon the direction of the slide
	// .i = the image that will be changed to reflect the sliding status.
	function _startStopSlider(inob)
	{
		if(sliderobj == null) return;
		if(!slidermoving || inob.o != currentbutton)
		{
			var sliderfunc = null;
			if(inob.w == 'leftright')
				sliderfunc = slideViewLeftRight;
			else if(inob.w == 'updown')
				sliderfunc = slideViewUpDown;
			else
				return;
			slidermoving = true;
			multiplier = inob.m;
			clearInterval(timer);
			timer = setInterval(sliderfunc, 30);
			if(currentimg != null && currentimg != 'undefined')
				currentimg.src = src;
			if(inob.i.src != null && inob.i.src != 'undefined')
			{
				src = inob.i.src;
				inob.i.src = pausebutton;
				currentimg = inob.i;
			}
		}
		else
		{
			if(inob.o == currentbutton)
			{
				clearInterval(timer);
				slidermoving = false;
				currentimg.src = src;
			}
			else
			{
				clearInterval(timer);
				slidermoving = false;
			}
		}
		currentbutton = inob.o;
	}
	this.startStopSlider = _startStopSlider;
}
