(function($){var fnname="magnifier";var magnifier={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[fnname]=function(magnifierattr){if(typeof(magnifierattr)=="object"){for(var n in magnifierattr){magnifier[n]=magnifierattr[n]}}var _this=this;_this.magnifier=$(magnifier.magnifier);_this.container=_this.magnifier.find(magnifier.container);_this.view=_this.magnifier.find(magnifier.view);_this.moveview=_this.magnifier.find(magnifier.moveview);_this.thumbnail=_this.magnifier.find(magnifier.thumbnail);_this.assembly=_this.magnifier.find(magnifier.assembly);_this.containerimg=_this.magnifier.find(magnifier.containerimg);var imgbox=_this.containerimg;_this.magnifier.css({"width":magnifier.width});_this.container.css({"width":magnifier.width,"height":magnifier.height});_this.view.css({"width":magnifier.width,"height":magnifier.height});var boxmoveviewwidth,boxmoveviewheight;if(magnifier.movewidth){boxmoveviewwidth=magnifier.movewidth}else{boxmoveviewwidth=magnifier.width/magnifier.zoom}boxmoveviewheight=magnifier.height/magnifier.zoom;_this.moveview.css({"width":boxmoveviewwidth,"height":boxmoveviewheight});var deviationxl,deviationxr,deviationyt,deviationyb,imgwidth,imghieght,multiple;_this.eqimg=function(){var img=new image(),src=_this.thumbnail.find("img").eq(magnifier.index).attr("src");img.src=src;containerwidth=magnifier.width;containerheight=magnifier.height;_this.thumbnail.find(">*").removeclass("active").eq(magnifier.index).addclass("active");function imgloadend(){if(img.width==0){img.onload=imgloadend}var stylecss;if(img.width>img.height){imgwidth=magnifier.width;imghieght=img.height/(img.width/magnifier.width);stylecss="top:50%;margin-top:"+(-imghieght/2)+"px"}else{imgwidth=img.width/(img.height/magnifier.width);imghieght=magnifier.width;stylecss="left:50%;margin-left:"+(-imgwidth/2)+"px"}imgbox.empty().append('');multiple=magnifier.width/boxmoveviewwidth;_this.view.empty().append('');deviationxl=(magnifier.width-imgwidth)/2;deviationxr=magnifier.width-deviationxl-boxmoveviewwidth+1;deviationyt=(magnifier.height-imghieght)/2;deviationyb=magnifier.height-deviationyt-boxmoveviewheight+1}imgloadend()};_this.eqimg();_this.movefn=function(e){var x=(e.clientx-_this.magnifier.offset().left)-boxmoveviewwidth/2,y=(e.clienty-_this.magnifier.offset().top+$(document).scrolltop())-boxmoveviewheight/2;endx=(x>deviationxl)?(xdeviationyt)?(y0)?(endy>(magnifier.width-boxmoveviewheight))?(magnifier.height-boxmoveviewheight):endy:0;_this.moveview.css({"left":endx,"top":endy,"display":"block"});positionx=(endx-(magnifier.width-imgwidth)/2)*multiple;positiony=(endy-(magnifier.height-imghieght)/2)*multiple;_this.view.css({"display":"block"}).find("img").css({"margin-left":-positionx,"margin-top":-positiony})};_this.container.on("mousemove",function(e){_this.movefn(e)}).on("mouseleave",function(){_this.moveview.hide();_this.view.hide()});var thumbnailimg=_this.thumbnail.find(">*"),linelenght=thumbnailimg.length;_this.imgmove=function(_boole){(_boole)?magnifier.index++:magnifier.index--;var _deviation=math.ceil(magnifier.width/thumbnailimg.width()/2);if(linelenght<_deviation){return false}(magnifier.index<0)?magnifier.index=0:(magnifier.index>linelenght-_deviation)?magnifier.index=linelenght-_deviation:magnifier.index;var endleft=(thumbnailimg.width()*magnifier.index)-thumbnailimg.width();_this.thumbnail.css({"left":((endleft>0)?-endleft:0)+"px"})};_this.assembly.find(">*").on("click",function(){_this.imgmove($(this).index())});thumbnailimg.on("mouseover",function(){magnifier.index=$(this).index();_this.eqimg()});thumbnailimg.on("click",function(){magnifier.index=$(this).index();_this.eqimg();_this.imgmove(magnifier.index)});_this.setindex=function(n){magnifier.index=(n)?n:0};return _this}})(jquery);