//-----------------------------------------------------------
//		Basic Pagination for Yahoo! Store - jquery plugin
//		Author: FastPivot (http://www.fastpivot.com)
// 
//		Version: 1.0 (1.4.2010)
//-----------------------------------------------------------

(function($) {
	    
	$.fn.basicProductScroller = function(options){
	
		var defaults = {
			scrollerRows: 1,
			scrollerImgWidth: 100,
			scrollerSkip: 1,
			scrollerOffset: 0
		};
		
		var options = $.extend(defaults, options);

			var scrollerReel = $(this).find("#reel");
			var lengthReel = scrollerReel.width();
			var heightReel = scrollerReel.height();
			var lengthScroll = (options.scrollerImgWidth + 40) * options.scrollerSkip;
			var scrollerOffset = options.scrollerOffset;
			
			/* Set Height of Lens */
			$(this).find("#lens").css("height", heightReel + "px");

			/* Right Scroller Arrow */
			$("#productScroller-rightArrow a").click(function(){
				
				if((lengthReel - scrollerOffset) > lengthScroll){
					if(scrollerOffset == 0){
						$("#productScroller-leftArrow").fadeTo("fast", 1);
					}
					scrollerOffset = scrollerOffset + lengthScroll;
					scrollerReel.animate({"left":"-" + scrollerOffset + "px"}, "slow");
					if((lengthReel - scrollerOffset) <= lengthScroll){
						$("#productScroller-rightArrow").fadeTo("fast", 0.50);
					}
				}
				
				return false;
			});

			/* Left Scroller Arrow */
			$("#productScroller-leftArrow a").click(function(){
				
				if(scrollerOffset != 0){
					if((lengthReel - scrollerOffset) <= lengthScroll){
						$("#productScroller-rightArrow").fadeTo("fast", 1);
					}
					scrollerOffset = scrollerOffset - lengthScroll;
					scrollerReel.animate({"left":"-" + scrollerOffset + "px"}, "slow");
					if(scrollerOffset == 0){
						$("#productScroller-leftArrow").fadeTo("fast", 0.50);
					}
				}
				
				return false;
			});

	}

})(jQuery);

