﻿(function($) {
	$.fn.extend({
		gat_imageViewer: function(options) {
			var defaults = {
				selector: '.rotatorItems a',
				caption: '#imageViewerCaption'
			};

			var options = $.extend(defaults, options);

			return this.each(function() {
				var frame = $(this);
				var imgFullView = $('img', frame);

				$(options.selector).attr('href', 'javascript:{}').click(function(event) {
					event.preventDefault();

					var thumbnail = $('img', this);

					$(imgFullView).fadeOut('fast', function() {
						window.setTimeout($(this).attr('src', $(thumbnail).attr('full-url')).gat_center($(frame), $(thumbnail).attr('full-height')).fadeIn('fast'), 1000);
					});

					$(options.caption).html($(thumbnail).attr('alt'));
				});

				$(options.selector).eq(0).click();
			});
		}
	});
})(jQuery);