var MojoZoom=function(){function n(a,d,b){var h=function(q){return b(q||window.event)};if(a.addEventListener)a.addEventListener(d,h,false);else a.attachEvent&&a.attachEvent("on"+d,h)}function s(a){var d=a.offsetLeft,b=a.offsetTop;for(a=a.offsetParent;a;){d+=a.offsetLeft;b+=a.offsetTop;a=a.offsetParent}return{x:d,y:b}}function I(a,d){var b=document.body.scrollLeft||document.documentElement.scrollLeft,h=document.body.scrollTop||document.documentElement.scrollTop;if(d.currentTarget){a=s(a);return{x:d.clientX- a.x+b,y:d.clientY-a.y+h}}return{x:d.offsetX,y:d.offsetY}}function w(a,d,b,h,q,t){if(!a.complete&&!a.__mojoZoomQueued)n(a,"load",function(){a.__mojoZoomQueued=true;setTimeout(function(){w(a,d,b,h,q,t)},1)});else{a.__mojoZoomQueued=false;setTimeout(function(){var z=!!document.all&&!!window.attachEvent&&!window.opera,k=a.offsetWidth,r=a.offsetHeight,o=a.parentNode;if(o.nodeName!="A"){var j=l("a");j.setAttribute("href",d);o.replaceChild(j,a);j.appendChild(a)}else j=o;j.style.position="relative";j.style.display= "block";j.style.width=k+"px";j.style.height=r+"px";var A=a.offsetLeft,B=a.offsetTop,i=l("div");i.className="mojozoom_marker";var e=l("img");e.className="mojozoom_img";e.style.position="absolute";e.style.left="-9999px";e.style.top="-9999px";document.body.appendChild(e);var p=a.parentNode,m=l("div");with(m.style){position="absolute";left=A+"px";top=B+"px";width=k+"px";height=r+"px";overflow="hidden";display="none"}m.appendChild(i);p.appendChild(m);a.__mojoZoomOverlay&&p.removeChild(a.__mojoZoomOverlay); a.__mojoZoomOverlay=m;a.__mojoZoomImage&&a.__mojoZoomImage.parentNode&&a.__mojoZoomImage.parentNode.removeChild(a.__mojoZoomImage);a.__mojoZoomImage=e;var C=false;if(!b){b=l("div");b.className="mojozoom_imgctr";o=s(a);b.style.left=k+o.x+"px";b.style.top=o.y+"px";b.style.width=(h?h:J)+"px";b.style.height=(q?q:K)+"px";document.body.appendChild(b);C=true}b.style.overflow="hidden";if(!t)b.style.visibility="hidden";n(e,"load",function(){if(e.parentNode){var D=b.offsetWidth,E=b.offsetHeight,F=e.offsetWidth/ k,G=e.offsetHeight/r,x=Math.round(D/F),y=Math.round(E/G);x/=3;y/=3;document.body.removeChild(e);b.appendChild(e);var H=l("div");H.className="mojozoom_fill";i.appendChild(H);var u=l("div");u.className="mojozoom_border";i.appendChild(u);i.style.width=x+"px";i.style.height=y+"px";if(t){i.style.left="0px";i.style.top="0px";e.style.left="0px";e.style.top="0px"}var v=false;if(!t){n(p,"mouseout",function(c){var g=c.target||c.srcElement;if(g)if(g.nodeName=="DIV")if(c=c.relatedTarget||c.toElement){for(;c!= g&&c.nodeName!="BODY"&&c.parentNode;)c=c.parentNode;if(c!=g){v=false;m.style.display="none";b.style.visibility="hidden"}}});n(document.body,"mouseover",function(c){if(v&&!(c.toElement==u||c.target==u)){m.style.display="none";b.style.visibility="hidden";v=false}})}n(p,"mousemove",function(c){v=true;var g=s(a);if(C){b.style.left=k+g.x+"px";b.style.top=g.y+"px"}m.style.display="block";b.style.visibility="visible";var f=I(p,c);if(c.srcElement&&z){if(c.srcElement==i)return;if(c.srcElement!=p){c=s(c.srcElement); f.x-=g.x-c.x;f.y-=g.y-c.y}}g=x/2;c=y/2;if(!z){f.x-=A;f.y-=B}if(f.x<g)f.x=g;if(f.x>k-g)f.x=k-g;if(f.y<c)f.y=c;if(f.y>r-c)f.y=r-c;c=f.y-c|0;i.style.left=(f.x-g|0)+"px";i.style.top=c+"px";e.style.left=-(f.x*F-D/2|0)+"px";e.style.top=-(f.y*G-E/2|0)+"px"})}});setTimeout(function(){e.src=d},1)},1)}}function L(){for(var a=document.getElementsByTagName("img"),d=0;d<a.length;d++){var b=a[d],h=b.getAttribute("data-zoomsrc");h&&w(b,h,document.getElementById(b.getAttribute("id")+"_zoom"),null,null,b.getAttribute("data-zoomalwaysshow")== "true")}}var l=function(a){return document.createElement(a)},J=450,K=450;return{addEvent:n,init:L,makeZoomable:w}}();MojoZoom.addEvent(window,"load",MojoZoom.init);