(function(b,c){function a(x,d){var m={id:"zoom-panel",parent:"body",error:'
There has been a problem attempting to loading the image.
',loading:'Loading
',cursor:"crosshair",touch:true}; this.opts=b.extend({},m,d);var q=this,u=false,p=true,y=false,f,e,n,l,k,j,i,h,g,r;function v(){q.ele={$target:b(x),$source:b("img",x),$parent:b(q.opts.parent),$loader:b(q.opts.loading),$panel:b('')}; o(q.ele.$target.attr("href"));q.ele.$target.on("click",function(z){z.preventDefault();}).on("mouseenter",function(z){y=true;w(z);}).on("mousemove",function(z){if(!y){y=true; w(z);}else{s(z);}}).on("mouseleave",function(){q.hide();y=false;});if(q.opts.touch&&"ontouchstart" in document.documentElement){x.addEventListener("touchstart",function(z){if(z.touches.length===1){z.preventDefault(); y=true;w(z);}},false);x.addEventListener("touchmove",function(z){if(z.touches.length===1){z.preventDefault();s(z);}},false);x.addEventListener("touchend",function(){q.hide(); y=false;},false);}return q;}function o(z){u=false;q.ele.$target.css("cursor","progress");q.ele.$loader.appendTo(q.ele.$target);q.ele.$zoomed=q.loadimg(z).on("error",function(){p=false; t();}).on("load",function(){u=true;q.ele.$target.css("cursor",q.opts.cursor);q.ele.$loader.detach();q.ele.$panel.html(q.ele.$zoomed.css("position","absolute")); if(y){q.ele.$target.trigger("mouseenter");}});}function t(){q.ele.$panel.html(q.opts.error);}function s(D){if(D.type.indexOf("touch")===0){f=D.touches[0].pageX; e=D.touches[0].pageY;}else{f=D.pageX||f;e=D.pageY||e;}var C=q.ele.$source.offset(),A=f-C.left,B=e-C.top,E=A*g,z=B*r;E=(E>k)?k:E;z=(z>h)?h:z;if(E>0&&z>0){q.ele.$zoomed.css({left:-E,top:-z}); }}function w(z){if(q.ele.$panel.parent().length===0){q.ele.$panel.appendTo(q.ele.$parent).css("opacity",0);}q.ele.$panel.stop().animate({opacity:1},200); n=q.ele.$source.width();j=q.ele.$source.height();l=q.ele.$panel.width();i=q.ele.$panel.height();k=q.ele.$zoomed.width()-l;h=q.ele.$zoomed.height()-i;g=k/n; r=h/j;s(z);}this.loadimg=function(A){var z=new Image();z.src=A+"?"+(new Date()).getTime();z.onload=function(){z=null;};return b(z);};this.hide=function(){if(q.ele.$panel.parent().length){q.ele.$panel.stop().animate({opacity:0},200,function(){q.ele.$panel=q.ele.$panel.detach(); });}};this.update=function(z){this.hide();o(z);};return x.tagName.toLowerCase()==="a"?v():c;}b.fn.easyZoom=function(d){return this.each(function(){b.data(this,"easyZoom",new a(this,d)); });};a.prototype.gallery=function(d,g){var f=this,e=g?b(g):this.ele.$parent;e.on("click",d,function(j){j.preventDefault();var i=b(this).addClass("thumbnail-loading"),k=i.attr("href"),h=i.data("easyzoomSource"); f.loadimg(h).on("load",function(){f.ele.$source.attr("src",h);f.ele.$target.attr("href",k);f.update(k);i.removeClass("thumbnail-loading");});});};})(jQuery);