jQuery.imgzoom=function(b){var a=jQuery.extend({speed:200,dontFadeIn:1,hideClicked:1,loading:"Loading..."},b);a.doubleSpeed=a.speed/4;jQuery(document.body).click(function(j){$(".imgzoom a").click();var g=jQuery(j.target);var f=g.is("a")?g:g.parents("a");f=(f&&f.is("a")&&f.attr("href").search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)/gi)!=-1)?f:false;var h=(f&&f.find("img").length)?f.find("img"):false;if(f){f.oldText=f.text();f.setLoadingImg=function(){if(h){h.css({opacity:"0.5"})}else{f.text(a.loading)}};f.setNotLoadingImg=function(){if(h){h.css({opacity:"1"})}else{f.text(f.oldText)}};var c=f.attr("href");if(jQuery('div.imgzoom img[src="'+c+'"]').length){return false}var i=function(){f.setNotLoadingImg();var n=f.find("img").length;var t=n?f.find("img"):f;var p=n?a.hideClicked:0;var o=t.offset();var l={width:t.outerWidth(),height:t.outerHeight(),left:o.left,top:o.top};var m=jQuery('<div><img src="'+c+'" alt="" /></div>').css({position:"absolute"}).appendTo(document.body);var k={width:m.outerWidth(),height:m.outerHeight()};var r={width:jQuery(window).width(),height:jQuery(window).height()};if(k.width>r.width){var q=r.width-100;k.height=(q/k.width)*k.height;k.width=q}if(k.height>r.height){var s=r.height-100;k.width=(s/k.height)*k.width;k.height=s}k.left=(r.width-k.width)/2+jQuery(window).scrollLeft();k.top=(r.height-k.height)/2+jQuery(window).scrollTop();var e=jQuery('<a href="#">Close</a>').appendTo(m).hide();if(p){f.css({visibility:"hidden"})}m.addClass("imgzoom").css(l).animate(k,a.speed,function(){e.fadeIn(a.doubleSpeed)});var u=function(){e.fadeOut(a.doubleSpeed,function(){m.animate(l,a.speed,function(){f.css({visibility:"visible"});m.remove()})});return false};m.click(u);e.click(u)};var d=new Image();d.src=c;if(d.complete){i()}else{f.setLoadingImg();d.onload=i}return false}})};
