
if (!CD3) var CD3 = {};
CD3.Slider = Class.create({
	initialize: function(container, prev, next, options){
		this.options = Object.extend({
			scroll_by:		0,
			scroll_type:	'horizontal',
			event:			'click',
			effectOptions:	{
				duration: 0.9, 
				queue: {scope: 'slider', limit:1}, 
				afterFinish: function() { this.sliding = false; }.bind(this)
			}
		}, options || {});
		
		this.container	= $(container);
		this.scroll		= this.options.scroll_type == 'vertical' ? ['top', 'offsetHeight'] : ['left', 'offsetWidth'];
		this.prevBtn	= this.bindEvent(prev, 1);
		this.nextBtn	= this.bindEvent(next, -1);
		this.sliding	= false;
	},
	bindEvent: function(a, dir){
		return $(a).observe(this.options.event, this.slide.bind(this, dir));
	},
	slide: function(dir){
		if (this.sliding) return;
		
		dir *= this.options.scroll_by;
					
		var side = this.container;
		var prop = parseInt(side.style[this.scroll[0]]) || 0;
		
		if (dir > 0 && (prop > -1 || !prop))						return;
		if (dir < 0 && (side[this.scroll[1]] + dir + prop < 10))	return;
		
		//this.prevBtn.style.visibility = !(prop+dir) ? 'hidden' : 'visible';
		//this.nextBtn.style.visibility = !(side[this.scroll[1]] + dir*2 + prop > 10) ? 'hidden' : 'visible';
		this.sliding = true;
		
		if (this.options.scroll_type == 'vertical')
			Effect.MoveBy(side, dir, 0, this.options.effectOptions);
		else
			Effect.MoveBy(side, 0, dir, this.options.effectOptions);
	}
});