$(function () {
	$(".download-descriptions>div").hide();
	$(".download-thumbnails a").click (function () {
		var report = $(this).attr("href");
		$(report).show().siblings().hide();
		$(".download-thumbnails a img").removeClass("active");
		$(this).find("img").addClass('active');
		SMS_downloads.desaturate($(".download-thumbnails a img:not(.active)"));
		return false;
	});
	SMS_downloads.desaturate ($(".download-thumbnails img"));
	
	$("a", ".download-thumbnails").hover (function () {
		SMS_downloads.resaturate($(this).children());
	}, function () {
		SMS_downloads.desaturate($(this).find("img:not(.active)"));
	});
	
	SMS_downloads.desaturate ($(".report-download img"));
	$(".report-download").hover (function () {
		SMS_downloads.resaturate($(this).find("div").children());
	}, function () {
		SMS_downloads.desaturate($(this).find("img"));
	});
});

SMS_downloads = {
	desaturate: function (elems) {
		elems.each (function () {
			Pixastic.process ($(this)[0], "desaturate", {average: false});
		});
	},
	resaturate: function (elems) {
		elems.each (function () {
			Pixastic.revert ($(this)[0]);
		});
	}
};