Cufon.replace('h1', {
	hover: true
});




/**
 * Flickr voting plugin
 */
(function(jQuery) {

	jQuery.gmcGallery = function(container) {

		var currentIndex = 0;

		// show next (or first) image
		var showNextImage = function(myself) {
			if ($(myself).next().length == 1) {
				currentIndex++;
				$(myself).fadeOut(100, function() {
					$(myself).next().fadeIn();
				});
			} else {
				currentIndex = 0;
				$(myself).fadeOut(100, function() {
					$("ul.gallery li:first", container).fadeIn();
				});
			}
			updateNumbers();
		};

		// show nth image
		var showImage = function(nth) {
			currentIndex = nth;
			$("ul.gallery li:visible", container).fadeOut(100, function() {
				$("ul.gallery li:nth(" + nth + ")", container).fadeIn();
			});
			updateNumbers();
		};

		// update navigation panel
		var updateNumbers = function() {
			$("ul.numbers li", container).removeClass("active");
			$("ul.numbers li:nth(" + currentIndex + ")", container).addClass("active");
		};

		// initialize
		var eachNumber = 0;
		jQuery("ul.gallery li", container).each(function() {
			$(this).css({
				"position": "absolute",
				"z-index": 1000 + eachNumber
			});
			$(this).click(function() {
				showNextImage(this);
			});
			eachNumber++;
		});

		// build navigation panel
		for (i=0; i<eachNumber; i++) {
			$("ul.numbers", container).append("<li><a href='#' rel='" + i + "'>" + (i + 1) + "</a></li>");
		}
		$("ul.numbers li", container).click(function() {
			var nth = $("a", this).attr("rel");
			showImage(nth);
			return false;
		});
		
		if (eachNumber <= 1) {
			$("ul.numbers").hide();
		}
		
		updateNumbers();

	};

})(jQuery);





jQuery(document).ready(function() {
	jQuery.gmcGallery(".gmcGallery");
});
