(function($) {
	$.fn.thumbs = function() {
		/*
		WHAT IT DOES: provides rollover functionality for thumbnails
		HOW IT WORKS: $(".thumb").thumbs();
		*/

		// constants
		var duration = 500;
		var easing = "easeOutExpo";
		var hoverFrag = '<span class="thumb-hover"></span>'

		this.each(init);

		// INIT ======================================================
		function init() {
			var $highlight = null;
			var $a = $(this);
			var $container = $a.parent();

			// append the highlight
			$a.append(hoverFrag);
			$highlight = $a.find(".thumb-hover");
			$highlight.hide();

			// add behaviours to the containing <li>
			$container.hover(
				function() {
					$(this).addClass("thumb-li-hover");

					if ($.support.opacity) {
						$highlight.stop(true, true).fadeIn(duration, easing);
					} else {
						$highlight.show();
					}

					$a.stop(true, true).animate({ top: -9 }, duration / 2, easing);
				},
				function() {
					$(this).removeClass("thumb-li-hover");

					if ($.support.opacity) {
						$highlight.stop(true, true).fadeOut(duration, easing);
					} else {
						$highlight.hide();
					}

					$a.stop(true, true).animate({ top: 0 }, duration / 2, easing);
				}
			).click(function() {
				window.location = $(this).find("a:first").attr("href");
			})
		}
	}
})(jQuery);

