$(function() {
	$("#prev_button").click(function(e) {
		var scrolling = document.getElementById("thumbnails");
		var current_left = parseInt(scrolling.offsetLeft);
		var steps = 93;
		if (current_left + steps > 0) steps = current_left * -1; 
		if (current_left >= 0 || isNaN(current_left)) return false;
		current_left += steps;
		$("#thumbnails").animate({left: current_left + "px"}, 400);

		e.preventDefault();
	});
	
	$("#next_button").click(function(e) {	
		var scrolling = document.getElementById("thumbnails");
		var current_left = parseInt(scrolling.offsetLeft);
		var holder_width = $("#thumbnail_holder").width();
		var scrolling_width = $("#thumbnails").width();
		var max_left = (scrolling_width - holder_width) * -1;
		var steps = 93;
		if (current_left - steps < max_left) steps = current_left - max_left;
		/*alert(steps);*/
		if (current_left <= max_left || isNaN(current_left)) return false;
		current_left -= steps;
		$("#thumbnails").animate({left: current_left + "px"}, 400);
		
		e.preventDefault();
	});
	
	$("a[rel='thumbnail']").each(function() {
		var $this = $(this);
		$this.click(function(e) {
			//console.log($this.href);
			$("#large_picture").attr("src", $this.attr("href"));
			e.preventDefault();
		});
	});
});
