$(document).ready(function() {

	$("#featurePane").hover( function() {

			$("#shadeSpecialsContainer").stop();
			$("#shadeSpecialsContainer").animate( { top: "360px" }, 500);
		},

		function() {

			$("#shadeSpecialsContainer").stop();
			$("#shadeSpecialsContainer").animate( { top: "467px" }, 500);
		}
	);

	var scrollPage = 0;

	var numThumbs = ($("#shadeSpecialsScrollerDiv > div.thumb").size());
	var numPages = Math.floor(numThumbs / 6);

	if ((numThumbs % 6) > 0) {

		numPages += 1;
	}

	checkScrollArrows(numPages, scrollPage);

	$("#shadeSpecialsScrollLeftButton").click( function() {

			if (scrollPage == 0) {

				return false;
			}

			else {

				scrollPage--;
				newLeft = (scrollPage * -636) + "px";
				$("#shadeSpecialsScrollerDiv").animate({left: newLeft}, "normal");
				checkScrollArrows(numPages, scrollPage);
			}

			return false;
		}
	);

	$("#shadeSpecialsScrollRightButton").click( function() {

			if (scrollPage == numPages - 1) {

				return false;
			}

			else {

				scrollPage++;
				newLeft = (scrollPage * -636) + "px";
				$("#shadeSpecialsScrollerDiv").animate({left: newLeft}, "normal");
				checkScrollArrows(numPages, scrollPage);
			}

			return false;
		}
	);
});

function checkScrollArrows(numPages, scrollPage) {

	if (scrollPage == 0) {

		$("#shadeSpecialsScrollLeftButton > img").attr("src", "images/large_arrow_l_gray.png");
	}

	else {

		$("#shadeSpecialsScrollLeftButton > img").attr("src", "images/large_arrow_l_pink.png");
	}

	if (scrollPage == numPages - 1) {

		$("#shadeSpecialsScrollRightButton > img").attr("src", "images/large_arrow_r_gray.png");
	}

	else {

		$("#shadeSpecialsScrollRightButton > img").attr("src", "images/large_arrow_r_pink.png");
	}
}
