$(document).ready(function() {
	
	var sliderWidth=$('#thumbScroller').width();
	var itemWidth=$('#thumbScroller  .ngg-gallery-thumbnail-box').width();
	$('#thumbScroller .ngg-gallery-thumbnail-box').each(function (i) {
			totalContent=i*itemWidth;	
			$('#thumbScroller .container').css("width",totalContent+itemWidth);
	});
	
	$('#thumbScroller').mousemove(function(e){
		  var mouseCoords=(e.pageX - this.offsetLeft);
		  var mousePercentY=mouseCoords/sliderWidth;
		  var destY=-(((totalContent-(sliderWidth-itemWidth))-sliderWidth)*(mousePercentY));
		  var thePosA=mouseCoords-destY;
		  var thePosB=destY-mouseCoords;
	
		  if(mouseCoords==destY && totalContent>700){
			  $('#thumbScroller .container').stop();
		  }
		  if(mouseCoords>destY && totalContent>700){
			  $('#thumbScroller .container').css('left',-thePosA);
		  }
		  if(mouseCoords<destY && totalContent>700){
			  $('#thumbScroller .container').css('left',thePosB);
		  }
	});
	$('#thumbScroller  .thumb').each(function () {
			$(this).fadeTo(fadeSpeed, 0.5);
	});
	var fadeSpeed=200;
		$('#thumbScroller .thumb').hover(
			function(){ //mouse over
				$(this).stop().fadeTo(fadeSpeed, 1);
			},
			function(){ //mouse out
				$(this).stop().fadeTo(fadeSpeed, 0.5);
			}
		);
		
		$('#page-selector .thumb-select').hover(
				function(){ //mouse over
					$(this).stop().fadeTo(fadeSpeed, 1);
				},
				function(){ //mouse out
					$(this).stop().fadeTo(fadeSpeed, 0.75);
				}
		);

});/* document.ready() */


