(function($){$.fn.kbZoom=function(options){var opts=$.extend({},$.fn.kbZoom.defaults,options);return this.each(function(){$this=$(this);$this.o=opts;$this.data("opt",$this.o);$this.step=2;$this.crtX=0;$this.crtY=0;$this.crtFX=0;$this.crtFY=0;$this.css({display:'block',position:'relative',overflow:'hidden',width:$this.o.width,height:$this.o.height});$this.find("img").css({position:'absolute',left:0,top:0,width:$this.o.width,height:$this.o.height});$this.mousemove(function(e){var xp0=$(this).position().left;var yp0=$(this).position().top;var x=e.pageX - xp0;var y=e.pageY - yp0;if($this.step==1){var tt=$(this).data("opt");if(x<tt.ignoreX)x=tt.ignoreX;if(y<tt.ignoreY)y=tt.ignoreY;if(x>tt.width - tt.ignoreX)x=tt.width-tt.ignoreX;if(y>tt.height - tt.ignoreY)y=tt.height-tt.ignoreY;var xi=-(x-tt.ignoreX)*(tt.widthLarge-tt.width)/(tt.width-tt.ignoreX-tt.ignoreX);var yi=-(y-tt.ignoreY)*(tt.heightLarge-tt.height)/(tt.height-tt.ignoreY-tt.ignoreY);$(this).find("img").css("left",xi).css("top",yi);}else if($this.step==0){$this.crtX=x;$this.crtY=y;}else if($this.step==2){var oo=$(this);var tt=$(this).data("opt");$(this).find("img").css({left:0,top:0,width:tt.width,height:tt.height});if($.fn.kbZoom.tmObj>0){clearTimeout($.fn.kbZoom.tmObj);$.fn.kbZoom.tmObj=0;}$(this).find("img").attr('src',$(this).find("img").attr("longdesc"));$.fn.kbZoom.tmObj=setTimeout(function(){var x=$this.crtX;var y=$this.crtY;var obj=oo;var obj2=tt;$this.crtFX=-x*(obj2.widthLarge-obj2.width)/obj2.width;$this.crtFY=-y*(obj2.heightLarge-obj2.height)/obj2.height;obj.find("img").animate({width:obj2.widthLarge,height:obj2.heightLarge,left:$this.crtFX,top:$this.crtFY},obj2.timeZoomIn,function(){$this.step=1;});},tt.timeToWait);$this.step=0;}}).mouseout(function(e){var tt=$(this).data("opt");$(this).find('img').animate({width:tt.width,height:tt.height,left:0,top:0},tt.timeZoomOut,"linear");$this.step=2;if($.fn.kbZoom.tmObj>0){clearTimeout($.fn.kbZoom.tmObj);$.fn.kbZoom.tmObj=0;}});});};$.fn.kbZoom.tmObj=0;$.fn.kbZoom.defaults={width:150,height:150,widthLarge:250,heightLarge:250,ignoreX:25,ignoreY:25,timeZoomIn:700,timeZoomOut:200,timeToWait:500};})(jQuery); 