(function($) {	$.fn.thumbPopup = function(options)	{		//Combine the passed in options with the default settings		settings = jQuery.extend({			popupId: "thumbPopup",			popupCSS: {'border': '1px solid rgb(114, 101, 98);', 'background': 'rgb(114, 101, 98);'},			imgSmallFlag: "_t",			imgLargeFlag: "_l",			cursorTopOffset: 0,			cursorLeftOffset: 0,			loadingHtml: "<!--<span style='padding: 5px;'>...</span>-->"		}, options);						//Create our popup element		popup =		$("<div rel='shadowbox'/>")		.css(settings.popupCSS)		.attr("id", settings.popupId)		//.css ("width", 593)		//.css ("height", 293)		.css("position", "absolute")		.css("index", 50)		.css("left", document.getElementById('thumbs').offsetLeft - 539)		.css("top", document.getElementById('thumbs').offsetTop + 1)		.appendTo("body").hide();				//Attach hover events that manage the popup		$(this)		//.hover(setPopup)		.click(setPopup);		//.mousemove(updatePopupPosition)		//.mouseout(hidePopup);				function setPopup(event)		{			var fullImgURL = $(this).attr("src").replace(settings.imgSmallFlag, settings.imgLargeFlag);						$(this).data("hovered", true);						//Load full image in popup			$("<img />").bind("load", {thumbImage: this}, function(event)			{				//Only display the larger image if the thumbnail is still being hovered				if ($(event.data.thumbImage).data("hovered") == true) {					$(popup).empty().append(this);					//updatePopupPosition(event); // was taken out ot keep popup in place					$(popup).fadeIn(500);				}				$(event.data.thumbImage).data("cached", false); // was set to false, otherwise fade only works on first image							})			.attr("src", fullImgURL);									//If no image has been loaded yet then place a loading message			if ($(this).data("cached") != true) {				//$(popup).append($(settings.loadingHtml)); //taken out - no span showing				//$(popup).empty(); //this was added - without it fade would only work on first image				$(popup).fadeIn(500);			} 			//updatePopupPosition(event);//was taken out to keep popup in place		}				function updatePopupPosition(event)		{			var windowSize = getWindowSize();			var popupSize = getPopupSize();								if (windowSize.width + windowSize.scrollLeft < event.pageX + popupSize.width + settings.cursorLeftOffset){				$(popup).css("left", event.pageX - popupSize.width - settings.cursorLeftOffset);			} else {				$(popup).css("left", event.pageX + settings.cursorLeftOffset);			}			if (windowSize.height + windowSize.scrollTop < event.pageY + popupSize.height + settings.cursorTopOffset){				$(popup).css("top", event.pageY - popupSize.height - settings.cursorTopOffset);			} else {				$(popup).css("top", event.pageY + settings.cursorTopOffset);			}		}				function hidePopup(event)		{			$(this).data("hovered", false);			$(popup).empty().fadeOut(500);		}				function getWindowSize() {			return {				scrollLeft: $(window).scrollLeft(),				scrollTop: $(window).scrollTop(),				width: $(window).width(),				height: $(window).height()			};		}				function getPopupSize() {			return {				width: $(popup).width(),				height: $(popup).height()			};		}		//Return original selection for chaining		return this;	};})(jQuery);