$(document).ready(function() {
	$('div.sliderGallery').each(function () {
		var ul = $('.items', this);
		var handleButton = $('.handle', this);
		var fakehandle = $('.fakehandle',this);
		var productWidth = ul.innerWidth() - $(this).outerWidth();
		var barWidth = $('.slider',this).innerWidth() - handleButton.outerWidth();
		
		var slider = $('.slider', this).slider({
			handle: '.handle',
			'min': 0, 
      		'max': productWidth, 
			slide: function (ev, ui) {
        		ul.css('left', ui.value * -1);
				fakehandle.css('left', Math.round((ui.value / productWidth) * barWidth) + 'px');
      		}, 
      		stop: function (ev, ui) {
       			ul.animate({'left' : ui.value * -1 }, 500);
				fakehandle.animate({'left': Math.round((ui.value / productWidth) * barWidth) + 'px'},500);
      		}
		})
	})
})
