$(document).ready(function() {
	var galleryWidth = $('#wrapper #gallery').outerWidth();
	var itemsWidth = 0;
	var step = 5; //Edit for more or less scroll distance
	var steps = galleryWidth/step;
	var startPos = 0;
	var endPos = (galleryWidth-itemsWidth)-178;
	var xPos=0;
	
	 $('#wrapper #gallery .container li').each(function() {
		itemsWidth += $(this).outerWidth();
	});

	$('a.next').click(function() {
		if(xPos>=endPos){
			
		} else {
			xPos+=steps;
			//$('.test').html(itemsWidth+' ,'+xPos+' ,'+endPos);
			$('div.container').animate({
				marginLeft: '-='+steps+'',
			  }, 400, function() {
				// Animation complete.
			});
		}
	})
	$('a.prev').click(function() {
		if(xPos<=0){
			
		} else {
			xPos-=steps;
			//$('.test').html(itemsWidth+' ,'+xPos+' ,'+endPos);
			$('div.container').animate({
				marginLeft: '+='+steps+'',
			  }, 400, function() {
				// Animation complete.
			});
		}
	})
});
