var Zoomer=new Class({version:"1.9.3",Implements:[Options],options:{smooth:6,active:true},initialize:function(b,a){this.setOptions(a);this.small=b;if(!this.small.complete){this.small.addEvent("load",function(){this.prepareSmall()}.bind(this))}else{this.prepareSmall()}var d=this.options.big||this.small.get("big");var c={position:"absolute",top:0,left:0,opacity:0,cursor:"crosshair"};if(typeof d=="string"){this.big=new Element("img",{src:d,styles:c})}else{this.big=d;this.big.setStyles(c)}if(!this.big.complete){this.big.addEvent("load",function(){this.prepareBig()}.bind(this))}else{this.prepareBig()}},prepareSmall:function(){this.wrapper=new Element("div",{"class":"zoomer-wrapper"}).wraps(this.small);["margin","left","top","bottom","right","float","clear","border","padding"].each(function(d){var a=this.small.getStyle(d);var b="auto";if(["float","clear","border"].contains(d)){b="none"}if(d=="padding"){b="0"}try{this.small.setStyle(d,b);this.wrapper.setStyle(d,a)}catch(c){}},this);this.wrapper.setStyles({width:this.small.offsetWidth,height:this.small.offsetHeight,position:"relative",overflow:"hidden"});this.smallSize={width:this.small.width,height:this.small.height};if(this.bigPrepared){this.ready()}else{this.smallPrepared=true}},prepareBig:function(){this.bigSize={width:this.big.width,height:this.big.height};if(this.smallPrepared){this.ready()}else{this.bigPrepared=true}},ready:function(){this.big.inject(this.wrapper);this.bigWrapper=new Element("div",{"class":"zoomer-wrapper-big",styles:{position:"absolute",overflow:"hidden",top:this.small.getPosition().y-this.wrapper.getPosition().y-this.wrapper.getStyle("border-top-width").toInt(),left:this.small.getPosition().x-this.wrapper.getPosition().x-this.wrapper.getStyle("border-left-width").toInt(),width:this.small.offsetWidth,height:this.small.offsetHeight,background:'url("'+this.small.getAttribute("src")+'")',zIndex:(this.small.getStyle("zIndex").toInt()||0)+1},events:{mouseenter:this.startZoom.bind(this),mouseleave:this.stopZoom.bind(this),mousemove:this.move.bind(this)}}).wraps(this.big)},move:function(a){if(this.options.active){this.dstPos=a.page}},startZoom:function(){if(this.options.active){this.position=this.small.getPosition();this.ratio={x:1-this.bigSize.width/this.smallSize.width,y:1-this.bigSize.height/this.smallSize.height};this.current={left:this.big.getStyle("left").toInt(),top:this.big.getStyle("top").toInt()};this.timer=this.zoom.periodical(10,this);this.big.fade("in")}},stopZoom:function(){if(this.options.active){$clear(this.timer);this.big.fade("out")}},zoom:function(){if(!this.dstPos){return}var a=this.options.smooth;var b={left:parseInt((this.dstPos.x-this.position.x)*this.ratio.x,10),top:parseInt((this.dstPos.y-this.position.y)*this.ratio.y,10)};this.current.left-=(this.current.left-b.left)/a;this.current.top-=(this.current.top-b.top)/a;this.big.setStyles(this.current)}});
