﻿/*
 * 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 a").click(function()
		{
			var smallId = $(this).attr('id');
			var bigId = $("[class^='show']").attr('id');
			bigId = bigId.substring(13);
			//alert(smallId + ' '+ bigId);
			if (bigId != smallId)
			{
				gallery.fadeImage();
				setTimeout(function() { gallery.showImage(smallId, bigId); }, fadeSpeed);
			}
		});
	};

})(jQuery);
