$(document).ready(function() { 
  $('div.gallerywrapper').css({overflow: 'hidden'});
	var ulPadding = -106;
  $('div.gallerywrapper').mousemove(function(e){
        var divWidth = $(this).width();
		
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var lastLi = $(this).find('ul.gallery').find('li:last-child');
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - $(this).offset().left) * (ulWidth-divWidth) / divWidth;
		$(this).scrollLeft(left);
	});
}); 

