var Zoomer=function(b,d){this.initialize.apply(this,arguments);return this}; Zoomer.prototype={version:"1.8.2",initialize:function(b,d){this.options=$.extend({smooth:6},d||{});this.small=$(b);var a=this;this.small[0].complete?this.prepareSmall():this.small.bind("load",function(){a.prepareSmall()});var c=this.options.big||this.small.attr("big"),e=new Image;e.src=c;this.big=$(e).css({position:"absolute",top:0,left:0,cursor:"crosshair"}).hide();this.big[0].complete?this.prepareBig():this.big.bind("load",function(){a.prepareBig()})},prepareSmall:function(){this.small.wrap('<div class="zoomer-wrapper"></div>'); this.wrapper=this.small.parent();var b=this;$.each("margin,left,top,bottom,right,float,clear,border,padding".split(","),function(d,a){var c;$.inArray(a,["left","top","bottom","right"])!=-1?(c=b.small[0],c=c.currentStyle?c.currentStyle[a]:(c=document.defaultView.getComputedStyle(c,null))?c.getPropertyValue(a):null):c=b.small.css(a);if(!(a=="margin"&&c=="auto")){var e="auto";$.inArray(a,["float","clear","border"])!=-1&&(e="none");a=="padding"&&(e="0");try{b.small.css(a,e),b.wrapper.css(a,c)}catch(f){}}}); this.wrapper.css({width:this.small[0].offsetWidth,height:this.small[0].offsetHeight,position:"relative",overflow:"hidden"});this.smallSize={width:this.small[0].width,height:this.small[0].height};this.bigPrepared?this.ready():this.smallPrepared=true},prepareBig:function(){this.bigSize={width:this.big[0].width,height:this.big[0].height};this.smallPrepared?this.ready():this.bigPrepared=true},ready:function(){this.big.appendTo(this.wrapper);this.big.wrap('<div class="zoomer-wrapper-big"></div>');this.bigWrapper= this.big.parent();this.bigWrapper.css({position:"absolute",overflow:"hidden",top:this.small.offset().top-this.wrapper.offset().top-parseInt(this.wrapper.css("border-top-width"),10)||0,left:this.small.offset().left-this.wrapper.offset().left-parseInt(this.wrapper.css("border-left-width"),10)||0,width:this.small[0].offsetWidth,height:this.small[0].offsetHeight,background:'url("'+this.small.attr("src")+'")'}).mouseenter($.proxy(this.startZoom,this)).mouseleave($.proxy(this.stopZoom,this)).mousemove($.proxy(this.move, this))},move:function(b){this.dstPos={x:b.pageX,y:b.pageY}},startZoom:function(){this.position=this.small.offset();this.ratio={x:1-this.bigSize.width/this.smallSize.width,y:1-this.bigSize.height/this.smallSize.height};this.current={left:parseInt(this.big.css("left"),10),top:parseInt(this.big.css("top"),10)};this.timer=setInterval($.proxy(this.zoom,this),10);this.big.fadeIn()},stopZoom:function(){clearInterval(this.timer);this.big.fadeOut()},zoom:function(){if(this.dstPos){var b=this.options.smooth, d=parseInt((this.dstPos.x-this.position.left)*this.ratio.x,10),a=parseInt((this.dstPos.y-this.position.top)*this.ratio.y,10);this.current.left-=(this.current.left-d)/b;this.current.top-=(this.current.top-a)/b;this.big.css(this.current)}}};$.fn.zoomer=function(b){for(var d=0,a=this.length;d<a;d++)new Zoomer(this[d],b)};
