/**
 * Pan/Zoom - it's just a quick hack, so don't expect too much
 * @author Andrew Hedges, andrew@hedges.name
 * @created 2009-12-27 12:27:09
 * @license MIT
 * @usage $.panzoom();
 * @requires jQuery (tested with versions 1.3.2 and 1.4.0)
 */
(function(c){var e,d;e={a:{position:"relative",overflow:"hidden",display:"inline-block",width:undefined,height:undefined},img:{position:"absolute",top:"0px",left:"0px"}};d={small:"Click to zoom in.",large:"Click to zoom out."};function f(n,m,o){return[Math.round(o[0]/(n[0]/m[0])),Math.round(o[1]/(n[1]/m[1]))];}function h(m,n){return(n.width()>m.width());}function a(n,m){var o;o=c(n).offset();return[m.pageX-o.left,m.pageY-o.top];}function g(n,o,m){var s,r,q,p;s=a(n,m);r=f(o.dimensions.small,o.dimensions.large,s);q=(0-(r[1]-s[1]))+"px";p=(0-(r[0]-s[0]))+"px";return[p,q];}function k(m,n){if(true!==n.applied_){e.a.width=n.dimensions.small[0]+"px";e.a.height=n.dimensions.small[1]+"px";m.css(e.a);n.css(e.img);n.applied_=true;}}function l(n){var m,o,p;m=n.data.a;o=n.data.img;p=g(m,o,n);o.css({top:p[1],left:p[0]});n.preventDefault();}function b(n,o,m){var p;p=g(n,o,m);o.animate({top:p[1],left:p[0],width:o.dimensions.large[0],height:o.dimensions.large[1]},"fast",function(){n.bind("mousemove",{a:n,img:o},l).attr("title",d.large);});o.attr("src",o.srcs.large);}function i(m,n){n.animate({top:"0px",left:"0px",width:n.dimensions.small[0],height:n.dimensions.small[1]},"fast",function(){m.unbind("mousemove",l).attr("title",d.small);n.attr("src",n.srcs.small);});}function j(m){m=m||".panzoom a";c.each(c(m),function(q,r){var o,p,n;o=c(this);p=c("img",o);n=new Image();n.onload=function(s){p.srcs={small:p.attr("src"),large:this.src};p.dimensions={small:[p.width(),p.height()],large:[n.width,n.height]};o.click(function(t){k(o,p);if(h(o,p)){i(o,p);}else{b(o,p,t);}t.preventDefault();}).attr("title",d.small);};n.src=o[0].href;});}c.extend({panzoom:j});})(jQuery);
