/*
 * jQuery MiniGallery plugin
 *
 */
(function($) {

	// Write noscript style
	//document.write("<style type='text/css'>.noscript{display:none}</style>");

	var fadeSpeed = 400;

	$.fn.miniGallery = function()
	{
		$.extend(this,
		{
			fadeImage: function()
			{
				$("#mainPic").fadeTo(fadeSpeed, 0);
			},
			
			showImage: function(smallId, bigId)
			{
				$("div[id^='mainPic-']").attr('class', 'hide');
				//$("#mainPic-image"+bigId).attr('class', 'hide');
				$("#mainPic-image"+smallId).attr('class', 'show');
				$("#mainPic").fadeTo(fadeSpeed, 1);
				return this;
			}
		});
		var gallery = this;

		$(".small").click(function()
		{
			var smallId = $(this).attr('id').substring(6);
			var bigId = $("[class^='show']").attr('id').substring(13);
			//alert(smallId + ' '+ bigId);

			if (bigId != smallId)
			{
				gallery.fadeImage();
				setTimeout(function() { gallery.showImage(smallId, bigId); }, fadeSpeed);
			}
		});
	};
})(jQuery);
