!function(a){var b="magnifier",c={magnifier:".magnifier",container:".magnifier-container",containerImg:".images-cover",view:".magnifier-view",width:400,height:400,moveView:".move-view",moveWidth:null,zoom:4,thumbnail:".magnifier-line > ul",assembly:".magnifier-btn",index:0};window[b]=function(b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;if("object"==typeof b)for(d in b)c[d]=b[d];return e=this,e.magnifier=a(c.magnifier),e.container=e.magnifier.find(c.container),e.view=e.magnifier.find(c.view),e.moveView=e.magnifier.find(c.moveView),e.thumbnail=e.magnifier.find(c.thumbnail),e.assembly=e.magnifier.find(c.assembly),e.containerImg=e.magnifier.find(c.containerImg),f=e.containerImg,e.magnifier.css({width:c.width}),e.container.css({width:c.width,height:c.height}),e.view.css({width:c.width,height:c.height}),g=c.moveWidth?c.moveWidth:c.width/c.zoom,h=g,e.moveView.css({width:g,height:h}),e.eqImg=function(){function d(){0==a.width&&(a.onload=d);var p;a.width>a.height?(m=c.width,n=a.height/(a.width/c.width),p="top:50%;margin-top:"+-n/2+"px"):(m=a.width/(a.height/c.width),n=c.width,p="left:50%;margin-left:"+-m/2+"px"),f.empty().append('<img src="'+b+'" width="'+m+'" height="'+n+'" style="'+p+'" />'),o=c.width/g,e.view.empty().append('<img src="'+b+'" width="'+m*o+'" height="'+n*o+'" />'),i=(c.width-m)/2,j=c.width-i-g+1,k=(c.height-n)/2,l=c.height-k-h+1}var a=new Image,b=e.thumbnail.find("img").eq(c.index).attr("src").replace("thumbnails","images");a.src=b,containerWidth=c.width,containerHeight=c.height,e.thumbnail.find(">*").removeClass("active").eq(c.index).addClass("active"),d()},e.eqImg(),e.moveFn=function(b){var d=b.clientX-e.magnifier.offset().left-g/2,f=b.clientY-e.magnifier.offset().top+a(document).scrollTop()-h/2;endX=d>i?j>d?d:j:i,endY=f>k?l>f?f:l:k,endY=endY>0?endY>c.width-h?c.height-h:endY:0,e.moveView.css({left:endX,top:endY,display:"block"}),positionX=(endX-(c.width-m)/2)*o,positionY=(endY-(c.height-n)/2)*o,e.view.css({display:"block"}).find("img").css({"margin-left":-positionX,"margin-top":-positionY})},e.container.on("mousemove",function(a){e.moveFn(a)}).on("mouseleave",function(){e.moveView.hide(),e.view.hide()}),p=e.thumbnail.find(">*"),q=p.length,e.imgMove=function(a){var b,d;return a?c.index++:c.index--,b=Math.ceil(c.width/p.width()/2),b>q?!1:(c.index<0?c.index=0:c.index>q-b?c.index=q-b:c.index,d=p.width()*c.index-p.width(),e.thumbnail.css({left:(d>0?-d:0)+"px"}),void 0)},e.assembly.find(">*").on("click",function(){e.imgMove(a(this).index())}),p.on("click",function(){c.index=a(this).index(),e.eqImg(),e.imgMove(c.index)}),e.setIndex=function(a){c.index=a?a:0},e}}(jQuery);