Type.registerNamespace("Sys.Extended.UI.Seadragon");Type.registerNamespace("Seadragon");(function(){var c="mouseup",d="mousedown",b=true,a=false;if(Seadragon.MouseTracker)return;var e=Seadragon.Utils.getBrowser()==Seadragon.Browser.IE,i=a,l=a,k={},f=[];function j(a){return Seadragon.Utils.getMousePosition(a)}function g(b,d){var c=Seadragon.Utils.getMousePosition(b),a=Seadragon.Utils.getElementPosition(d);return c.minus(a)}function h(c,b){var d=document.body;while(b&&c!=b&&d!=b)try{b=b.parentNode}catch(e){return a}return c==b}function m(){i=b}function n(){i=a}(function(){if(e){Seadragon.Utils.addEvent(document,d,m,a);Seadragon.Utils.addEvent(document,c,n,a)}else{Seadragon.Utils.addEvent(window,d,m,b);Seadragon.Utils.addEvent(window,c,n,b)}})();Seadragon.MouseTracker=function(m,H,G){var p="function",q="mousemove",t="mouseout",s="mouseover",o=null,r=this,n=r,A=o,F=Math.random(),m=Seadragon.Utils.getElement(m),y=a,u=a,w=a,x=a,z=o,J=o,I=o,H=H,G=G;r.target=m;r.enterHandler=o;r.exitHandler=o;r.pressHandler=o;r.releaseHandler=o;r.clickHandler=o;r.dragHandler=o;function R(){if(!y){Seadragon.Utils.addEvent(m,s,D,a);Seadragon.Utils.addEvent(m,t,E,a);Seadragon.Utils.addEvent(m,d,O,a);Seadragon.Utils.addEvent(m,c,v,a);Seadragon.Utils.addEvent(m,"click",N,a);y=b;k[F]=A}}function T(){if(y){Seadragon.Utils.removeEvent(m,s,D,a);Seadragon.Utils.removeEvent(m,t,E,a);Seadragon.Utils.removeEvent(m,d,O,a);Seadragon.Utils.removeEvent(m,c,v,a);Seadragon.Utils.removeEvent(m,"click",N,a);B();y=a;delete k[F]}}function S(){if(!u){if(e){Seadragon.Utils.removeEvent(m,c,v,a);Seadragon.Utils.addEvent(m,c,P,b);Seadragon.Utils.addEvent(m,q,L,b)}else{Seadragon.Utils.addEvent(window,c,K,b);Seadragon.Utils.addEvent(window,q,C,b)}u=b}}function B(){if(u){if(e){Seadragon.Utils.removeEvent(m,q,L,b);Seadragon.Utils.removeEvent(m,c,P,b);Seadragon.Utils.addEvent(m,c,v,a)}else{Seadragon.Utils.removeEvent(window,q,C,b);Seadragon.Utils.removeEvent(window,c,K,b)}u=a}}function M(c,d){var b=k;for(var a in b)b.hasOwnProperty(a)&&F!=a&&b[a][c](d)}function U(){return x}function D(a){var a=Seadragon.Utils.getEvent(a);e&&u&&!h(a.srcElement,m)&&M("onMouseOver",a);var d=a.target?a.target:a.srcElement,c=a.relatedTarget?a.relatedTarget:a.fromElement;if(!h(m,d)||h(m,c))return;x=b;if(typeof n.enterHandler==p)try{n.enterHandler(n,g(a,m),w,i)}catch(f){Seadragon.Debug.error(f.name+" while executing enter handler: "+f.message,f)}}function E(b){var b=Seadragon.Utils.getEvent(b);e&&u&&!h(b.srcElement,m)&&M("onMouseOut",b);var c=b.target?b.target:b.srcElement,d=b.relatedTarget?b.relatedTarget:b.toElement;if(!h(m,c)||h(m,d))return;x=a;if(typeof n.exitHandler==p)try{n.exitHandler(n,g(b,m),w,i)}catch(f){Seadragon.Debug.error(f.name+" while executing exit handler: "+f.message,f)}}function O(a){var a=Seadragon.Utils.getEvent(a);if(a.button==2)return;w=b;z=j(a);I=z;J=(new Date).getTime();if(typeof n.pressHandler==p)try{n.pressHandler(n,g(a,m))}catch(c){Seadragon.Debug.error(c.name+" while executing press handler: "+c.message,c)}(n.pressHandler||n.dragHandler)&&Seadragon.Utils.cancelEvent(a);if(!e||!l){S();l=b;f=[A]}else e&&f.push(A)}function v(b){var b=Seadragon.Utils.getEvent(b),d=w,c=x;if(b.button==2)return;w=a;if(typeof n.releaseHandler==p)try{n.releaseHandler(n,g(b,m),d,c)}catch(e){Seadragon.Debug.error(e.name+" while executing release handler: "+e.message,e)}d&&c&&Q(b)}function P(b){var b=Seadragon.Utils.getEvent(b);if(b.button==2)return;for(var c=0;c<f.length;c++){var d=f[c];!d.hasMouse()&&d.onMouseUp(b)}B();l=a;b.srcElement.fireEvent("on"+b.type,document.createEventObject(b));Seadragon.Utils.stopEvent(b)}function K(a){!x&&v(a);B()}function N(a){n.clickHandler&&Seadragon.Utils.cancelEvent(a)}function Q(a){var a=Seadragon.Utils.getEvent(a);if(a.button==2)return;var e=(new Date).getTime()-J,c=j(a),b=I.distanceTo(c),d=e<=H&&b<=G;if(typeof n.clickHandler==p)try{n.clickHandler(n,g(a,m),d,a.shiftKey)}catch(f){Seadragon.Debug.error(f.name+" while executing click handler: "+f.message,f)}}function C(a){var a=Seadragon.Utils.getEvent(a),b=j(a),c=b.minus(z);z=b;if(typeof n.dragHandler==p){try{n.dragHandler(n,g(a,m),c,a.shiftKey)}catch(d){Seadragon.Debug.error(d.name+" while executing drag handler: "+d.message,d)}Seadragon.Utils.cancelEvent(a)}}function L(b){for(var a=0;a<f.length;a++)f[a].onMouseMove(b);Seadragon.Utils.stopEvent(b)}(function(){A={hasMouse:U,onMouseOver:D,onMouseOut:E,onMouseUp:v,onMouseMove:C}})();r.isTracking=function(){return y};r.setTracking=function(a){if(a)R();else T()}}})();