// charset=utf-8
// $Id: ProductsSlider.js 74 2009-11-10 09:50:22Z dierker $
// +----------------------------------------------------------------------+
// | ProductsSlider                                                       |
// | (c) 2009 monsun media (http://www.monsun-media.com)                  |
// +----------------------------------------------------------------------+


/**
* ProductsSlider
*
* @author	md
*/
var ProductsSlider = {
	/**
	* move the timeline to a specific position
	*
	* @param	Event	evt
	* @param	int		newLeft
	*/
	goTo : function(evt,newLeft){
		var scrollable = document.getElementById('ProductsSliderPaneScrollable');
		scrollable.style.left = (-1*newLeft)+'px';
	}
	,
	/**
	* move the slider to the left
	*
	* @param	Event	evt
	* @return	void
	*/
	moveLeft : function(evt){
		ProductsSlider.move(1);
		mcm.cancelEvent(evt);
	}
	,
	/**
	* move the slider to the right
	*
	* @param	Event	evt
	* @return	void
	*/
	moveRight : function(evt){
		ProductsSlider.move(-1);
		mcm.cancelEvent(evt);
	}
	,
	/**
	* move the slider
	*
	* @param	int		$direction
	* @return	void
	*/
	move : function(direction){
		var container = document.getElementById('ProductsSliderPane');
		var scrollable = document.getElementById('ProductsSliderPaneScrollable');
		var newLeft = isNaN(parseInt(scrollable.offsetLeft)) ? 0 : parseInt(scrollable.offsetLeft);
		newLeft = newLeft + direction*128 - 1;
		if( newLeft>0 ){
			newLeft=0;
		};
		var scrollableWidth = parseInt(scrollable.offsetWidth);
		var containerWidth = parseInt(container.offsetWidth);
		
		var maxLeft = containerWidth-scrollableWidth;
		if( newLeft<maxLeft ){
			newLeft = maxLeft;
		};
		scrollable.style.left = newLeft+'px';
	}
}

