
jQuery(function(){
	if (jQuery.fn.jCarouselLite)
	{
		var slideshow = jQuery('#product_scroll');
		if (slideshow.length)
		{
			var sl = slideshow.find('.scrollable');
			var to_int = function(s) { return parseInt(s.replace('px')); }
			var set_width = sl.width() - to_int(sl.css('margin-left')) -  to_int(sl.css('margin-right'));
		
			var sides = jQuery('.product_sides');
			var speed = 600;
			sl.jCarouselLite({
				btnPrev: '#product_nav a.prev',
				btnNext: '#product_nav a.next',
				visible: 4,
				scroll: 1,
				speed: speed,
				circular: true,
				beforeStart : function() {
					//custom tweak to add side covers for the products then remove during animation
					sides.fadeOut(100,function(){ setTimeout(function() { sides.fadeIn(100); },(speed - 450)); });
				}
			});
			sl.width(set_width - 1);
		}
	}
});
