(function ($) {
	$.fn.iframeLightbox = function (params) {
		// options
		params = $.extend({
			width: '690px',
			height: '430px',
			scrolling: 'yes'
		}, params);
		
		$(this).click(function () {
			// set up a clean new stage
			$('#gallerySlideOverlay').remove();
			$('body').append('<div id="gallerySlideOverlay"></div>');
			$("#gallerySlideOverlay").css({'opacity': 0.8, 'height': $(document).height() + 'px'}).fadeIn('fast');
			$("body").append('<div id="gallerySlideContainer"></div>');
			var container = $("#gallerySlideContainer");
			
			// find first image and load it up
			container.html('<iframe scrolling="' + params['scrollbar'] + '" style="margin-top: 15px; width: ' + params['width'] + '; height: ' + params['height'] + '; border: 0px;" frameborder="0" src="' + $(this).attr('href') + '"></iframe>');
			
			container.find('iframe').load(function () {
				// position it based on new height
				var top = ($(window).height()/2) - (container.height()/2);
				var left = ($(window).width()/2) - (container.width()/2);
				container.css({'top': top + 'px', 'left': left + 'px'});
				container.fadeIn('fast');
			});
			
			// close button
			container.append('<a href="#" id="gallerySlideClose">x</a>');
			
			return false;
		});
		
		// close gallery
		$("#gallerySlideOverlay, #gallerySlideClose").live('click', function () {
			$("#gallerySlideOverlay, #gallerySlideContainer").fadeOut('fast', function () {
				$("#gallerySlideOverlay, #gallerySlideContainer").remove();
			});
			
			return false;
		});
	};
})(jQuery);
