$(document).ready(function(){
  $("#ngg-galleryslider").slider({
    animate: true,
    change: handleSliderChange,
    slide: handleSliderSlide
  });
});

function handleSliderChange(e, ui)
{
  var maxScroll = $("#ngg-galleryscroller").attr("scrollWidth") - $("#ngg-galleryscroller").width();
  $("#ngg-galleryscroller").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#ngg-galleryscroller").attr("scrollWidth") - $("#ngg-galleryscroller").width();
  $("#ngg-galleryscroller").attr({scrollLeft: ui.value * (maxScroll / 100) });
}