var numItems = 4; //Change this to change the amount of items shown
var animationSpeed = 1000 //milliseconds

$(document).ready(function() {
	var itemHeight = parseInt($(".explorationsitem").outerHeight());
	var destContent = $("#explorationscontent");
	$("#explorationswrapper").css("height", itemHeight * numItems);
	$(".previous").toggleClass("inactive");
	if ($(".explorationsitem").length > numItems) {
		$(".next").click(function() {
			if (parseInt($(destContent).css("top")) - (numItems * itemHeight) > -(parseInt($(destContent).height()))) {
				$("#explorationscontent:not(:animated)").animate(
					{
						top: parseInt($(destContent).css("top")) - (numItems * itemHeight)
					}, 
					animationSpeed, 
					"", 
					function() {
						if (-(parseInt($(destContent).css("top"))) + (numItems * itemHeight) > parseInt($(destContent).height())) {
							$(".next").addClass("inactive");
						}
						$(".previous").removeClass("inactive");			
					}
				);
			}
			return false;
		});
		$(".previous").click(function() {
			if (parseInt($(destContent).css("top")) + (numItems * itemHeight) <= 0) {
				$("#explorationscontent:not(:animated)").animate(
					{
						top: parseInt($(destContent).css("top")) + (numItems * itemHeight)
					}, 
					animationSpeed, 
					"", 
					function() {
						if (parseInt($(destContent).css("top")) + (numItems * itemHeight) > 0) {
							$(".previous").addClass("inactive");
						}
						$(".next").removeClass("inactive");
					}
				);
			}
			return false;
		});
	}
	else {
		$(".next, .previous").toggleClass("inactive");
	}
	$("#featureSlide h3:first-child").addClass("first");
	$("#content #static .gridRow .item:first-child").addClass("first");
});

