(function($){$.fn.thumbPopup=function(options)
{settings=jQuery.extend({popupId:"thumbPopup",popupCSS:{'border':'1px solid #000000','background':'#FFFFFF'},imgSmallFlag:"t",imgLargeFlag:"",cursorTopOffset:15,cursorLeftOffset:15},options);popup=$("<div />").css(settings.popupCSS).attr("id",settings.popupId).css("position","absolute").appendTo("body").hide();$(this).hover(setPopup).mousemove(updatePopupPosition).mouseout(hidePopup);function str_replace(haystack,needle,replacement){var temp=haystack.split(needle);return temp.join(replacement);}
function setPopup(event)
{var fullImgURL=$(this).attr("src");var fullImgURL=str_replace(fullImgURL,"t.jpg",".jpg");$(this).data("hovered",true);$("<img />").bind("load",{thumbImage:this},function(event)
{if($(event.data.thumbImage).data("hovered")==true){$(popup).empty().append(this);updatePopupPosition(event);$(popup).show();}
$(event.data.thumbImage).data("cached",true);}).attr("src",fullImgURL);if($(this).data("cached")!=true){$(popup).append($(settings.loadingHtml));$(popup).show();}
updatePopupPosition(event);}
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);}else{$(popup).css("top",event.pageY);}}
function hidePopup(event)
{$(this).data("hovered",false);$(popup).empty().hide();}
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 this;};})(jQuery);