/* Sliding area by Jay Contonio
--------------------------------------------- */
var current_slide = 1; // first slide
var offset = 0;
var maskHeight;
var maxScrollHeight;

$(document).ready(function() {
	$('#scroll-up').click(function() { moveContainer("up");return false; });
	$('#scroll-down').click(function() { moveContainer("down");return false; });
	maskHeight = $('#wn1').height();
	$('.fourThumbs a').click(function() {
		return false;
	})
});

function resetValues()
{
	offset = 0;
	maxScrollHeight = 0;
}

function moveContainer(direction)
{
	// Set the max distance of scrolling each time (because this changes depending on the dropdown)
	maxScrollHeight = $('#lyr1 .thumbs-list:visible .mask').height() - maskHeight;
	
	if (direction == "down") {
		// This is sort of hacky but if we're at the bottom let's stop scrolling
		if(-(offset) >= maxScrollHeight) return;
		yVal = offset - 55;
	} else if (direction == "up") {
		// If offset is zero then we're at the top already so exit
		if(offset == 0) return;
		yVal = offset + 55;
	}
	// Set offset to our current position
	offset = yVal;
	
	// Animate the scrolling
	$('#lyr1').animate({ top: yVal + "px" }, "slow");
}