-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOpenSeadragon.js
2 lines (2 loc) · 69.9 KB
/
OpenSeadragon.js
1
2
// (c) 2010 OpenSeadragon, (c) 2010 CodePlex Foundation
Array.prototype.add=function(a,b){a[a.length]=b};Array.prototype.clear=function(a){a.length=0};Array.prototype.clone=function(a){return a.length===1?[a[0]]:Array.apply(null,a)};SArray=Array();if(!window.Function)window.Function={};Function.prototype.createDelegate=function(b,a){return function(){if(arguments===undefined)arguments=[];return a.apply(b,arguments)}};function String(){}String.format=function(){return String._toFormattedString(false,arguments)};String._toFormattedString=function(l,j){for(var c="",e=j[0],a=0;true;){var f=e.indexOf("{",a),d=e.indexOf("}",a);if(f<0&&d<0){c+=e.slice(a);break}if(d>0&&(d<f||f<0)){c+=e.slice(a,d+1);a=d+2;continue}c+=e.slice(a,f);a=f+1;if(e.charAt(a)==="{"){c+="{";a++;continue}if(d<0)break;var h=e.substring(a,d),g=h.indexOf(":"),k=parseInt(g<0?h:h.substring(0,g),10)+1,i=g<0?"":h.substring(g+1),b=j[k];if(typeof b==="undefined"||b===null)b="";if(b.toFormattedString)c+=b.toFormattedString(i);else if(l&&b.localeFormat)c+=b.localeFormat(i);else if(b.format)c+=b.format(i);else c+=b.toString();a=d+1}return c};function Observer(){}Observer.prototype={_getContext:function(b,c){var a=b._observerContext;return a?a():c?(b._observerContext=this._createContext())():null},_createContext:function(){var a={events:new EventHandlerList};return function(){return a}}};var EventHandlerList=function(){this._list={}};EventHandlerList.prototype={_addHandler:function(b,a){SArray.add(this._getEvent(b,true),a)},addHandler:function(b,a){this._addHandler(b,a)},_removeHandler:function(c,b){var a=this._getEvent(c);if(!a)return;SArray.remove(a,b)},_removeHandlers:function(b){if(!b)this._list={};else{var a=this._getEvent(b);if(!a)return;a.length=0}},removeHandler:function(b,a){this._removeHandler(b,a)},getHandler:function(b){var a=this._getEvent(b);if(!a||!a.length)return null;a=SArray.clone(a);return function(c,d){for(var b=0,e=a.length;b<e;b++)a[b](c,d)}},_getEvent:function(b,c){var a=this._list[b];if(!a){if(!c)return null;this._list[b]=a=[]}return a}};var Seadragon=new function(){};Seadragon.Utils=function(){var a=null,f="number",i=true,e=false,b=this,d={UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5};Seadragon.Browser=d;var c=b,l=["Msxml2.XMLHTTP","Msxml3.XMLHTTP","Microsoft.XMLHTTP"],n={bmp:e,jpeg:i,jpg:i,png:i,tif:e,wdp:e},g=d.UNKNOWN,h=0,j=e,m={};(function(){var e=navigator.appName,r=navigator.appVersion,a=navigator.userAgent;if(e=="Microsoft Internet Explorer"&&!!window.attachEvent&&!!window.ActiveXObject){var l=a.indexOf("MSIE");g=d.IE;h=parseFloat(a.substring(l+5,a.indexOf(";",l)))}else if(e=="Netscape"&&!!window.addEventListener){var k=a.indexOf("Firefox"),b=a.indexOf("Safari"),o=a.indexOf("Chrome");if(k>=0){g=d.FIREFOX;h=parseFloat(a.substring(k+8))}else if(b>=0){var q=a.substring(0,b).lastIndexOf("/");g=o>=0?d.CHROME:d.SAFARI;h=parseFloat(a.substring(q+1,b))}}else if(e=="Opera"&&!!window.opera&&!!window.attachEvent){g=d.OPERA;h=parseFloat(r)}for(var p=window.location.search.substring(1),n=p.split("&"),i=0;i<n.length;i++){var c=n[i],f=c.indexOf("=");if(f>0)m[c.substring(0,f)]=decodeURIComponent(c.substring(f+1))}j=g==d.IE||g==d.CHROME&&h<2})();function k(a,b){return b&&a!=document.body?document.body:a.offsetParent}b.getBrowser=function(){return g};b.getBrowserVersion=function(){return h};b.getElement=function(a){if(typeof a=="string")a=document.getElementById(a);return a};b.getElementPosition=function(a){var a=c.getElement(a),b=new Seadragon.Point,d=c.getElementStyle(a).position=="fixed",e=k(a,d);while(e){b.x+=a.offsetLeft;b.y+=a.offsetTop;if(d)b=b.plus(c.getPageScroll());a=e;d=c.getElementStyle(a).position=="fixed";e=k(a,d)}return b};b.getElementSize=function(a){var a=c.getElement(a);return new Seadragon.Point(a.clientWidth,a.clientHeight)};b.getElementStyle=function(a){var a=c.getElement(a);if(a.currentStyle)return a.currentStyle;else if(window.getComputedStyle)return window.getComputedStyle(a,"");else Seadragon.Debug.fail("Unknown element style, no known technique.")};b.getEvent=function(a){return a?a:window.event};b.getMousePosition=function(a){var a=c.getEvent(a),b=new Seadragon.Point;if(typeof a.pageX==f){b.x=a.pageX;b.y=a.pageY}else if(typeof a.clientX==f){b.x=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;b.y=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}else Seadragon.Debug.fail("Unknown event mouse position, no known technique.");return b};b.getPageScroll=function(){var a=new Seadragon.Point,b=document.documentElement||{},c=document.body||{};if(typeof window.pageXOffset==f){a.x=window.pageXOffset;a.y=window.pageYOffset}else if(c.scrollLeft||c.scrollTop){a.x=c.scrollLeft;a.y=c.scrollTop}else if(b.scrollLeft||b.scrollTop){a.x=b.scrollLeft;a.y=b.scrollTop}return a};b.getWindowSize=function(){var a=new Seadragon.Point,b=document.documentElement||{},c=document.body||{};if(typeof window.innerWidth==f){a.x=window.innerWidth;a.y=window.innerHeight}else if(b.clientWidth||b.clientHeight){a.x=b.clientWidth;a.y=b.clientHeight}else if(c.clientWidth||c.clientHeight){a.x=c.clientWidth;a.y=c.clientHeight}else Seadragon.Debug.fail("Unknown window size, no known technique.");return a};b.imageFormatSupported=function(a){var a=a?a:"";return!!n[a.toLowerCase()]};b.makeCenteredNode=function(g){var b="border:none; margin:0px; padding:0px;",g=Seadragon.Utils.getElement(g),d=c.makeNeutralElement("div"),a=[];a.push('<div style="display:table; height:100%; width:100%;');a.push(b);a.push('#position:relative; overflow:hidden; text-align:left;">');a.push('<div style="#position:absolute; #top:50%; width:100%; ');a.push(b);a.push('display:table-cell; vertical-align:middle;">');a.push('<div style="#position:relative; #top:-50%; width:100%; ');a.push(b);a.push('text-align:center;"></div></div></div>');d.innerHTML=a.join("");d=d.firstChild;var f=d,e=d.getElementsByTagName("div");while(e.length>0){f=e[0];e=f.getElementsByTagName("div")}f.appendChild(g);return d};b.makeNeutralElement=function(c){var b=document.createElement(c),a=b.style;a.background="transparent none";a.border="none";a.margin="0px";a.padding="0px";a.position="static";return b};b.makeTransparentImage=function(f){var e=c.makeNeutralElement("img"),b=a;if(g==d.IE&&h<7){b=c.makeNeutralElement("span");b.style.display="inline-block";e.onload=function(){b.style.width=b.style.width||e.width+"px";b.style.height=b.style.height||e.height+"px";e.onload=a;e=a};e.src=f;b.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+f+"', sizingMethod='scale')"}else{b=e;b.src=f}return b};b.setElementOpacity=function(a,b,g){var a=c.getElement(a);if(g&&j)b=Math.round(b);if(b<1)a.style.opacity=b;else a.style.opacity="";if(b==1){var f=a.style.filter||"";a.style.filter=f.replace(/alpha\(.*?\)/g,"");return}var d=Math.round(100*b),e=" alpha(opacity="+d+") ";try{if(a.filters&&a.filters.alpha)a.filters.alpha.opacity=d;else a.style.filter+=e}catch(h){a.style.filter+=e}};b.addEvent=function(a,d,e,b){var a=c.getElement(a);if(a.addEventListener)a.addEventListener(d,e,b);else if(a.attachEvent){a.attachEvent("on"+d,e);b&&a.setCapture&&a.setCapture()}else Seadragon.Debug.fail("Unable to attach event handler, no known technique.")};b.removeEvent=function(a,d,e,b){var a=c.getElement(a);if(a.removeEventListener)a.removeEventListener(d,e,b);else if(a.detachEvent){a.detachEvent("on"+d,e);b&&a.releaseCapture&&a.releaseCapture()}else Seadragon.Debug.fail("Unable to detach event handler, no known technique.")};b.cancelEvent=function(a){var a=c.getEvent(a);a.preventDefault&&a.preventDefault();a.cancel=i;a.returnValue=e};b.stopEvent=function(a){var a=c.getEvent(a);a.stopPropagation&&a.stopPropagation();a.cancelBubble=i};b.createCallback=function(d,c){for(var b=[],a=2;a<arguments.length;a++)b.push(arguments[a]);return function(){for(var e=b.concat([]),a=0;a<arguments.length;a++)e.push(arguments[a]);return c.apply(d,e)}};b.getUrlParameter=function(c){var b=m[c];return b?b:a};b.makeAjaxRequest=function(g,d){var c=typeof d=="function",b=a;if(c)var f=d,d=function(){window.setTimeout(Seadragon.Utils.createCallback(a,f,b),1)};if(window.ActiveXObject)for(var e=0;e<l.length;e++)try{b=new ActiveXObject(l[e]);break}catch(h){continue}else if(window.XMLHttpRequest)b=new XMLHttpRequest;!b&&Seadragon.Debug.fail("Browser doesn't support XMLHttpRequest.");if(c)b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=new function(){};d()}};try{b.open("GET",g,c);b.send(a)}catch(h){Seadragon.Debug.log(h.name+" while making AJAX request: "+h.message);b.onreadystatechange=a;b=a;c&&d()}return c?a:b};b.parseXml=function(c){var b=a;if(window.ActiveXObject)try{b=new ActiveXObject("Microsoft.XMLDOM");b.async=e;b.loadXML(c)}catch(f){Seadragon.Debug.log(f.name+" while parsing XML (ActiveX): "+f.message)}else if(window.DOMParser)try{var d=new DOMParser;b=d.parseFromString(c,"text/xml")}catch(f){Seadragon.Debug.log(f.name+" while parsing XML (DOMParser): "+f.message)}else Seadragon.Debug.fail("Browser doesn't support XML DOM.");return b}};Seadragon.Utils=new Seadragon.Utils;(function(){var c="mouseup",d="mousedown",b=true,a=false;if(Seadragon.MouseTracker)return;var f=Seadragon.Utils.getBrowser()==Seadragon.Browser.IE,i=a,l=a,k={},g=[];function j(a){return Seadragon.Utils.getMousePosition(a)}function e(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(f){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,K,J){var p="function",q="mousemove",v="mousewheel",u="DOMMouseScroll",t="mouseout",s="mouseover",o=null,r=this,n=r,D=o,I=Math.random(),m=Seadragon.Utils.getElement(m),A=a,w=a,y=a,z=a,C=o,M=o,L=o,K=K,J=J;r.target=m;r.enterHandler=o;r.exitHandler=o;r.pressHandler=o;r.releaseHandler=o;r.scrollHandler=o;r.clickHandler=o;r.dragHandler=o;function U(){if(!A){Seadragon.Utils.addEvent(m,s,G,a);Seadragon.Utils.addEvent(m,t,H,a);Seadragon.Utils.addEvent(m,d,R,a);Seadragon.Utils.addEvent(m,c,x,a);Seadragon.Utils.addEvent(m,"click",Q,a);Seadragon.Utils.addEvent(m,u,B,a);Seadragon.Utils.addEvent(m,v,B,a);A=b;k[I]=D}}function W(){if(A){Seadragon.Utils.removeEvent(m,s,G,a);Seadragon.Utils.removeEvent(m,t,H,a);Seadragon.Utils.removeEvent(m,d,R,a);Seadragon.Utils.removeEvent(m,c,x,a);Seadragon.Utils.removeEvent(m,"click",Q,a);Seadragon.Utils.removeEvent(m,u,B,a);Seadragon.Utils.removeEvent(m,v,B,a);E();A=a;delete k[I]}}function V(){if(!w){if(f){Seadragon.Utils.removeEvent(m,c,x,a);Seadragon.Utils.addEvent(m,c,S,b);Seadragon.Utils.addEvent(m,q,O,b)}else{Seadragon.Utils.addEvent(window,c,N,b);Seadragon.Utils.addEvent(window,q,F,b)}w=b}}function E(){if(w){if(f){Seadragon.Utils.removeEvent(m,q,O,b);Seadragon.Utils.removeEvent(m,c,S,b);Seadragon.Utils.addEvent(m,c,x,a)}else{Seadragon.Utils.removeEvent(window,q,F,b);Seadragon.Utils.removeEvent(window,c,N,b)}w=a}}function P(c,d){var b=k;for(var a in b)b.hasOwnProperty(a)&&I!=a&&b[a][c](d)}function X(){return z}function G(a){var a=Seadragon.Utils.getEvent(a);f&&w&&!h(a.srcElement,m)&&P("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;z=b;if(typeof n.enterHandler==p)try{n.enterHandler(n,e(a,m),y,i)}catch(g){Seadragon.Debug.error(g.name+" while executing enter handler: "+g.message,g)}}function H(b){var b=Seadragon.Utils.getEvent(b);f&&w&&!h(b.srcElement,m)&&P("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;z=a;if(typeof n.exitHandler==p)try{n.exitHandler(n,e(b,m),y,i)}catch(g){Seadragon.Debug.error(g.name+" while executing exit handler: "+g.message,g)}}function R(a){var a=Seadragon.Utils.getEvent(a);if(a.button==2)return;y=b;C=j(a);L=C;M=(new Date).getTime();if(typeof n.pressHandler==p)try{n.pressHandler(n,e(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(!f||!l){V();l=b;g=[D]}else f&&g.push(D)}function x(b){var b=Seadragon.Utils.getEvent(b),d=y,c=z;if(b.button==2)return;y=a;if(typeof n.releaseHandler==p)try{n.releaseHandler(n,e(b,m),d,c)}catch(f){Seadragon.Debug.error(f.name+" while executing release handler: "+f.message,f)}d&&c&&T(b)}function S(b){var b=Seadragon.Utils.getEvent(b);if(b.button==2)return;for(var c=0;c<g.length;c++){var d=g[c];if(!d.hasMouse())d.onMouseUp(b)}E();l=a;b.srcElement.fireEvent("on"+b.type,document.createEventObject(b));Seadragon.Utils.stopEvent(b)}function N(a){!z&&x(a);E()}function Q(a){n.clickHandler&&Seadragon.Utils.cancelEvent(a)}function B(a){var b=0;if(!a)a=window.event;if(a.wheelDelta){b=a.wheelDelta;if(window.opera)b=-b}else if(a.detail)b=-a.detail;b=b>0?1:-1;if(typeof n.scrollHandler==p){try{n.scrollHandler(n,e(a,m),b,a.shiftKey)}catch(c){Seadragon.Debug.error(c.name+" while executing scroll handler: "+c.message,c)}Seadragon.Utils.cancelEvent(a)}}function T(a){var a=Seadragon.Utils.getEvent(a);if(a.button==2)return;var f=(new Date).getTime()-M,c=j(a),b=L.distanceTo(c),d=f<=K&&b<=J;if(typeof n.clickHandler==p)try{n.clickHandler(n,e(a,m),d,a.shiftKey)}catch(g){Seadragon.Debug.error(g.name+" while executing click handler: "+g.message,g)}}function F(a){var a=Seadragon.Utils.getEvent(a),b=j(a),c=b.minus(C);C=b;if(typeof n.dragHandler==p){try{n.dragHandler(n,e(a,m),c,a.shiftKey)}catch(d){Seadragon.Debug.error(d.name+" while executing drag handler: "+d.message,d)}Seadragon.Utils.cancelEvent(a)}}function O(b){for(var a=0;a<g.length;a++)g[a].onMouseMove(b);Seadragon.Utils.stopEvent(b)}(function(){D={hasMouse:X,onMouseOver:G,onMouseOut:H,onMouseUp:x,onMouseMove:F}})();r.isTracking=function(){return A};r.setTracking=function(a){if(a)U();else W()}}})();if(!window.SIGNAL)window.SIGNAL="----seadragon----";Seadragon.ControlAnchor=function(){throw Error.invalidOperation();};Seadragon.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4};Seadragon.ControlAnchor=Seadragon.ControlAnchor;Seadragon.OverlayPlacement=function(){throw Error.invalidOperation();};Seadragon.OverlayPlacement={CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8};Seadragon.OverlayPlacement=Seadragon.OverlayPlacement;Seadragon.NavControl=function(c){var b=null,a=this;a._group=b;a._zooming=false;a._zoomFactor=b;a._lastZoomTime=b;a._viewer=c;a.config=a._viewer.config;a.elmt=b;a.initialize()};Seadragon.NavControl.prototype={initialize:function(){var a=this,e=Function.createDelegate(a,a._beginZoomingIn),c=Function.createDelegate(a,a._endZooming),g=Function.createDelegate(a,a._doSingleZoomIn),d=Function.createDelegate(a,a._beginZoomingOut),f=Function.createDelegate(a,a._doSingleZoomOut),i=Function.createDelegate(a,a._onHome),h=Function.createDelegate(a,a._onFullPage),b=a._viewer.config.navImages,m=new Seadragon.Button({config:a._viewer.config,tooltip:Seadragon.Strings.getString("Tooltips.ZoomIn"),srcRest:a._resolveUrl(b.zoomIn.REST),srcGroup:a._resolveUrl(b.zoomIn.GROUP),srcHover:a._resolveUrl(b.zoomIn.HOVER),srcDown:a._resolveUrl(b.zoomIn.DOWN)},{onPress:e,onRelease:c,onClick:g,onEnter:e,onExit:c}),k=new Seadragon.Button({config:a._viewer.config,tooltip:Seadragon.Strings.getString("Tooltips.ZoomOut"),srcRest:a._resolveUrl(b.zoomOut.REST),srcGroup:a._resolveUrl(b.zoomOut.GROUP),srcHover:a._resolveUrl(b.zoomOut.HOVER),srcDown:a._resolveUrl(b.zoomOut.DOWN)},{onPress:d,onRelease:c,onClick:f,onEnter:d,onExit:c}),l=new Seadragon.Button({config:a._viewer.config,tooltip:Seadragon.Strings.getString("Tooltips.Home"),srcRest:a._resolveUrl(b.home.REST),srcGroup:a._resolveUrl(b.home.GROUP),srcHover:a._resolveUrl(b.home.HOVER),srcDown:a._resolveUrl(b.home.DOWN)},{onRelease:i}),j=new Seadragon.Button({config:a._viewer.config,tooltip:Seadragon.Strings.getString("Tooltips.FullPage"),srcRest:a._resolveUrl(b.fullpage.REST),srcGroup:a._resolveUrl(b.fullpage.GROUP),srcHover:a._resolveUrl(b.fullpage.HOVER),srcDown:a._resolveUrl(b.fullpage.DOWN)},{onRelease:h});a._group=new Seadragon.ButtonGroup({config:a._viewer.config,buttons:[m,k,l,j]});a.elmt=a._group.get_element();a.elmt[SIGNAL]=true;a._viewer.add_open(Function.createDelegate(a,a._lightUp))},dispose:function(){},get_events:function(){return this._events},set_events:function(a){this._events=a},_resolveUrl:function(a){return String.format("{1}",this._viewer.get_prefixUrl(),a)},_beginZoomingIn:function(){var a=this;a._lastZoomTime=(new Date).getTime();a._zoomFactor=a.config.zoomPerSecond;a._zooming=true;a._scheduleZoom()},_beginZoomingOut:function(){var a=this;a._lastZoomTime=(new Date).getTime();a._zoomFactor=1/a.config.zoomPerSecond;a._zooming=true;a._scheduleZoom()},_endZooming:function(){this._zooming=false},_scheduleZoom:function(){window.setTimeout(Function.createDelegate(this,this._doZoom),10)},_doZoom:function(){var a=this;if(a._zooming&&a._viewer.viewport){var b=(new Date).getTime(),d=b-a._lastZoomTime,c=Math.pow(a._zoomFactor,d/1e3);a._viewer.viewport.zoomBy(c);a._viewer.viewport.applyConstraints();a._lastZoomTime=b;a._scheduleZoom()}},_doSingleZoomIn:function(){var a=this;if(a._viewer.viewport){a._zooming=false;a._viewer.viewport.zoomBy(a.config.zoomPerClick/1);a._viewer.viewport.applyConstraints()}},_doSingleZoomOut:function(){var a=this;if(a._viewer.viewport){a._zooming=false;a._viewer.viewport.zoomBy(1/a.config.zoomPerClick);a._viewer.viewport.applyConstraints()}},_lightUp:function(){this._group.emulateEnter();this._group.emulateExit()},_onHome:function(){this._viewer.viewport&&this._viewer.viewport.goHome()},_onFullPage:function(){var a=this;a._viewer.setFullPage(!a._viewer.isFullPage());a._group.emulateExit();a._viewer.viewport&&a._viewer.viewport.applyConstraints()}};Seadragon.Control=function(d,c,b){var a=this;a.elmt=d;a.anchor=c;a.container=b;a.wrapper=Seadragon.Utils.makeNeutralElement("span");a.wrapper.style.display="inline-block";a.wrapper.appendChild(a.elmt);if(a.anchor==Seadragon.ControlAnchor.NONE)a.wrapper.style.width=a.wrapper.style.height="100%";if(a.anchor==Seadragon.ControlAnchor.TOP_RIGHT||a.anchor==Seadragon.ControlAnchor.BOTTOM_RIGHT)a.container.insertBefore(a.wrapper,a.container.firstChild);else a.container.appendChild(a.wrapper)};Seadragon.Control.prototype={destroy:function(){var a=this;a.wrapper.removeChild(a.elmt);a.container.removeChild(a.wrapper)},isVisible:function(){return this.wrapper.style.display!="none"},setVisible:function(a){this.wrapper.style.display=a?"inline-block":"none"},setOpacity:function(a){if(this.elmt[SIGNAL]&&Seadragon.Utils.getBrowser()==Seadragon.Browser.IE)Seadragon.Utils.setElementOpacity(this.elmt,a,true);else Seadragon.Utils.setElementOpacity(this.wrapper,a,true)}};Seadragon.Viewer=function(h,g,d,e,f,c){var b=null,a=this;a.config=new Seadragon.Config;a._prefixUrl=d?d:"";a._element=document.getElementById(h);a._controls=e?e:[];a._customControls=[];a._overlays=f?f:[];a._overlayControls=c?c:[];a._container=b;a._canvas=b;a._controlsTL=b;a._controlsTR=b;a._controlsBR=b;a._controlsBL=b;a._bodyWidth=b;a._bodyHeight=b;a._bodyOverflow=b;a._docOverflow=b;a._fsBoundsDelta=b;a._prevContainerSize=b;a._lastOpenStartTime=0;a._lastOpenEndTime=0;a._animating=false;a._forceRedraw=false;a._mouseInside=false;a._xmlPath=g?g:undefined;a.source=b;a.drawer=b;a.viewport=b;a.profiler=b;a.initialize()};Seadragon.Viewer.prototype={initialize:function(){var n="absolute",b="0px",h="100%",d="div",a=this;a._observer=new Observer;a._container=Seadragon.Utils.makeNeutralElement(d);a._canvas=Seadragon.Utils.makeNeutralElement(d);a._controlsTL=Seadragon.Utils.makeNeutralElement(d);a._controlsTR=Seadragon.Utils.makeNeutralElement(d);a._controlsBR=Seadragon.Utils.makeNeutralElement(d);a._controlsBL=Seadragon.Utils.makeNeutralElement(d);var f=new Seadragon.MouseTracker(a._canvas,a.config.clickTimeThreshold,a.config.clickDistThreshold),g=new Seadragon.MouseTracker(a._container,a.config.clickTimeThreshold,a.config.clickDistThreshold);a._bodyWidth=document.body.style.width;a._bodyHeight=document.body.style.height;a._bodyOverflow=document.body.style.overflow;a._docOverflow=document.documentElement.style.overflow;a._fsBoundsDelta=new Seadragon.Point(1,1);var e=a._canvas.style,c=a._container.style,l=a._controlsTL.style,m=a._controlsTR.style,k=a._controlsBR.style,j=a._controlsBL.style;c.width=h;c.height=h;c.position="relative";c.left=b;c.top=b;c.textAlign="left";e.width=h;e.height=h;e.overflow="hidden";e.position=n;e.top=b;e.left=b;l.position=m.position=k.position=j.position=n;l.top=m.top=b;l.left=j.left=b;m.right=k.right=b;j.bottom=k.bottom=b;f.clickHandler=Function.createDelegate(a,a._onCanvasClick);f.dragHandler=Function.createDelegate(a,a._onCanvasDrag);f.releaseHandler=Function.createDelegate(a,a._onCanvasRelease);f.scrollHandler=Function.createDelegate(a,a._onCanvasScroll);f.setTracking(true);if(a.get_showNavigationControl()){navControl=(new Seadragon.NavControl(a)).elmt;navControl.style.marginRight="4px";navControl.style.marginBottom="4px";a.addControl(navControl,Seadragon.ControlAnchor.BOTTOM_RIGHT)}for(var i=0;i<a._customControls.length;i++)a.addControl(a._customControls[i].id,a._customControls[i].anchor);g.enterHandler=Function.createDelegate(a,a._onContainerEnter);g.exitHandler=Function.createDelegate(a,a._onContainerExit);g.releaseHandler=Function.createDelegate(a,a._onContainerRelease);g.setTracking(true);window.setTimeout(Function.createDelegate(a,a._beginControlsAutoHide),1);a._container.appendChild(a._canvas);a._container.appendChild(a._controlsTL);a._container.appendChild(a._controlsTR);a._container.appendChild(a._controlsBR);a._container.appendChild(a._controlsBL);a.get_element().appendChild(a._container);a._xmlPath&&a.openDzi(a._xmlPath)},get_events:function(){return this._observer._getContext(this,true).events},_raiseEvent:function(c,a){var b=this.get_events().getHandler(c);if(b){if(!a)a={};b(this,a)}},_beginControlsAutoHide:function(){var a=this;if(!a.config.autoHideControls)return;a._controlsShouldFade=true;a._controlsFadeBeginTime=(new Date).getTime()+a._controlsFadeDelay;window.setTimeout(Function.createDelegate(a,a._scheduleControlsFade),a._controlsFadeDelay)},_scheduleControlsFade:function(){window.setTimeout(Function.createDelegate(this,this._updateControlsFade),20)},_updateControlsFade:function(){var b=this;if(b._controlsShouldFade){var d=(new Date).getTime(),e=d-b._controlsFadeBeginTime,a=1-e/b._controlsFadeLength;a=Math.min(1,a);a=Math.max(0,a);for(var c=b._controls.length-1;c>=0;c--)b._controls[c].setOpacity(a);a>0&&b._scheduleControlsFade()}},_onCanvasClick:function(g,c,e,f){var a=this;if(a.viewport&&e){var b=a.config.zoomPerClick,d=f?1/b:b;a.viewport.zoomBy(d,a.viewport.pointFromPixel(c,true));a.viewport.applyConstraints()}},_onCanvasDrag:function(c,b,a){this.viewport&&this.viewport.panBy(this.viewport.deltaPointsFromPixels(a.negate()))},_onCanvasRelease:function(d,c,a){a&&this.viewport&&this.viewport.applyConstraints()},_onCanvasScroll:function(e,b,d){var a=this;if(a.viewport){var c=Math.pow(a.config.zoomPerScroll,d);a.viewport.zoomBy(c,a.viewport.pointFromPixel(b,true));a.viewport.applyConstraints()}},_onContainerExit:function(d,c,a){if(!a){this._mouseInside=false;!this._animating&&this._beginControlsAutoHide()}},_onContainerRelease:function(d,c,b,a){if(!a){this._mouseInside=false;!this._animating&&this._beginControlsAutoHide()}},_getControlIndex:function(b){for(var a=this._controls.length-1;a>=0;a--)if(this._controls[a].elmt==b)return a;return-1},_abortControlsAutoHide:function(){this._controlsShouldFade=false;for(var a=this._controls.length-1;a>=0;a--)this._controls[a].setOpacity(1)},_onContainerEnter:function(){this._mouseInside=true;this._abortControlsAutoHide()},_updateOnce:function(){var a=this;if(!a.source)return;a.profiler.beginUpdate();var c=Seadragon.Utils.getElementSize(a._container);if(!c.equals(a._prevContainerSize)){a.viewport.resize(c,true);a._prevContainerSize=c;a._raiseEvent("resize",a)}var b=a.viewport.update();if(!a._animating&&b){a._raiseEvent("animationstart",self);a._abortControlsAutoHide()}if(b){a.drawer.update();a._raiseEvent("animation",self)}else if(a._forceRedraw||a.drawer.needsUpdate()){a.drawer.update();a._forceRedraw=false}else a.drawer.idle();if(a._animating&&!b){a._raiseEvent("animationfinish",a);!a._mouseInside&&a._beginControlsAutoHide()}a._animating=b;a.profiler.endUpdate()},_onClose:function(){var b=null,a=this;a.source=b;a.viewport=b;a.drawer=b;a.profiler=b;a._canvas.innerHTML=""},_beforeOpen:function(){var a=this;a.source&&a._onClose();a._lastOpenStartTime=(new Date).getTime();window.setTimeout(Function.createDelegate(a,function(){this._lastOpenStartTime>this._lastOpenEndTime&&this._setMessage(Seadragon.Strings.getString("Messages.Loading"))}),2e3);return a._lastOpenStartTime},_setMessage:function(d){var b="normal",c=document.createTextNode(d);this._canvas.innerHTML="";this._canvas.appendChild(Seadragon.Utils.makeCenteredNode(c));var a=c.parentNode.style;a.color="white";a.fontFamily="verdana";a.fontSize="13px";a.fontSizeAdjust="none";a.fontStyle=b;a.fontStretch=b;a.fontVariant=b;a.fontWeight=b;a.lineHeight="1em";a.textAlign="center";a.textDecoration="none"},_onOpen:function(f,d,e){var a=this;a._lastOpenEndTime=(new Date).getTime();if(f<a._lastOpenStartTime){Seadragon.Debug.log("Ignoring out-of-date open.");a._raiseEvent("ignore");return}else if(!d){a._setMessage(e);a._raiseEvent("error");return}a._canvas.innerHTML="";a._prevContainerSize=Seadragon.Utils.getElementSize(a._container);a.source=d;a.viewport=new Seadragon.Viewport(a._prevContainerSize,a.source.dimensions,a.config);a.drawer=new Seadragon.Drawer(a.source,a.viewport,a._canvas);a.profiler=new Seadragon.Profiler;a._animating=false;a._forceRedraw=true;a._scheduleUpdate(a._updateMulti);for(var c=0;c<a._overlayControls.length;c++){var b=a._overlayControls[c];if(b.point!=null)a.drawer.addOverlay(b.id,new Seadragon.Point(b.point.X,b.point.Y),Seadragon.OverlayPlacement.TOP_LEFT);else a.drawer.addOverlay(b.id,new Seadragon.Rect(b.rect.Point.X,b.rect.Point.Y,b.rect.Width,b.rect.Height),b.placement)}a._raiseEvent("open")},_scheduleUpdate:function(c,a){if(this._animating)return window.setTimeout(Function.createDelegate(this,c),1);var b=(new Date).getTime(),a=a?a:b,d=a+1e3/60,e=Math.max(1,d-b);return window.setTimeout(Function.createDelegate(this,c),e)},_updateMulti:function(){if(!this.source)return;var a=(new Date).getTime();this._updateOnce();this._scheduleUpdate(arguments.callee,a)},_updateOnce:function(){var a=this;if(!a.source)return;a.profiler.beginUpdate();var c=Seadragon.Utils.getElementSize(a._container);if(!c.equals(a._prevContainerSize)){a.viewport.resize(c,true);a._prevContainerSize=c;a._raiseEvent("resize")}var b=a.viewport.update();if(!a._animating&&b){a._raiseEvent("animationstart");a._abortControlsAutoHide()}if(b){a.drawer.update();a._raiseEvent("animation")}else if(a._forceRedraw||a.drawer.needsUpdate()){a.drawer.update();a._forceRedraw=false}else a.drawer.idle();if(a._animating&&!b){a._raiseEvent("animationfinish");!a._mouseInside&&a._beginControlsAutoHide()}a._animating=b;a.profiler.endUpdate()},getNavControl:function(){return this._navControl},get_element:function(){return this._element},get_xmlPath:function(){return this._xmlPath},set_xmlPath:function(a){this._xmlPath=a},get_debugMode:function(){return this.config.debugMode},set_debugMode:function(a){this.config.debugMode=a},get_animationTime:function(){return this.config.animationTime},set_animationTime:function(a){this.config.animationTime=a},get_blendTime:function(){return this.config.blendTime},set_blendTime:function(a){this.config.blendTime=a},get_alwaysBlend:function(){return this.config.alwaysBlend},set_alwaysBlend:function(a){this.config.alwaysBlend=a},get_autoHideControls:function(){return this.config.autoHideControls},set_autoHideControls:function(a){this.config.autoHideControls=a},get_immediateRender:function(){return this.config.immediateRender},set_immediateRender:function(a){this.config.immediateRender=a},get_wrapHorizontal:function(){return this.config.wrapHorizontal},set_wrapHorizontal:function(a){this.config.wrapHorizontal=a},get_wrapVertical:function(){return this.config.wrapVertical},set_wrapVertical:function(a){this.config.wrapVertical=a},get_minZoomImageRatio:function(){return this.config.minZoomImageRatio},set_minZoomImageRatio:function(a){this.config.minZoomImageRatio=a},get_maxZoomPixelRatio:function(){return this.config.maxZoomPixelRatio},set_maxZoomPixelRatio:function(a){this.config.maxZoomPixelRatio=a},get_visibilityRatio:function(){return this.config.visibilityRatio},set_visibilityRatio:function(a){this.config.visibilityRatio=a},get_springStiffness:function(){return this.config.springStiffness},set_springStiffness:function(a){this.config.springStiffness=a},get_imageLoaderLimit:function(){return this.config.imageLoaderLimit},set_imageLoaderLimit:function(a){this.config.imageLoaderLimit=a},get_clickTimeThreshold:function(){return this.config.clickTimeThreshold},set_clickTimeThreshold:function(a){this.config.clickTimeThreshold=a},get_clickDistThreshold:function(){return this.config.clickDistThreshold},set_clickDistThreshold:function(a){this.config.clickDistThreshold=a},get_zoomPerClick:function(){return this.config.zoomPerClick},set_zoomPerClick:function(a){this.config.zoomPerClick=a},get_zoomPerSecond:function(){return this.config.zoomPerSecond},set_zoomPerSecond:function(a){this.config.zoomPerSecond=a},get_zoomPerScroll:function(){return this.config.zoomPerScroll},set_zoomPerScroll:function(a){this.config.zoomPerScroll=a},get_maxImageCacheCount:function(){return this.config.maxImageCacheCount},set_maxImageCacheCount:function(a){this.config.maxImageCacheCount=a},get_showNavigationControl:function(){return this.config.showNavigationControl},set_showNavigationControl:function(a){this.config.showNavigationControl=a},get_minPixelRatio:function(){return this.config.minPixelRatio},set_minPixelRatio:function(a){this.config.minPixelRatio=a},get_mouseNavEnabled:function(){return this.config.mouseNavEnabled},set_mouseNavEnabled:function(a){this.config.mouseNavEnabled=a},get_controls:function(){return this._customControls},set_controls:function(a){this._customControls=a},get_overlays:function(){return this._overlayControls},set_overlays:function(a){this._overlayControls=a},get_prefixUrl:function(){return this._prefixUrl},set_prefixUrl:function(a){this._prefixUrl=a},add_open:function(a){this.get_events().addHandler("open",a)},remove_open:function(a){this.get_events().removeHandler("open",a)},add_error:function(a){this.get_events().addHandler("error",a)},remove_error:function(a){this.get_events().removeHandler("error",a)},add_ignore:function(a){this.get_events().addHandler("ignore",a)},remove_ignore:function(a){this.get_events().removeHandler("ignore",a)},add_resize:function(a){this.get_events().addHandler("resize",a)},remove_resize:function(a){this.get_events().removeHandler("resize",a)},add_animationstart:function(a){this.get_events().addHandler("animationstart",a)},remove_animationstart:function(a){this.get_events().removeHandler("animationstart",a)},add_animation:function(a){this.get_events().addHandler("animation",a)},remove_animation:function(a){this.get_events().removeHandler("animation",a)},add_animationfinish:function(a){this.get_events().addHandler("animationfinish",a)},remove_animationfinish:function(a){this.get_events().removeHandler("animationfinish",a)},addControl:function(a,e){var d="relative",b=this,a=Seadragon.Utils.getElement(a);if(b._getControlIndex(a)>=0)return;var c=null;switch(e){case Seadragon.ControlAnchor.TOP_RIGHT:c=b._controlsTR;a.style.position=d;break;case Seadragon.ControlAnchor.BOTTOM_RIGHT:c=b._controlsBR;a.style.position=d;break;case Seadragon.ControlAnchor.BOTTOM_LEFT:c=b._controlsBL;a.style.position=d;break;case Seadragon.ControlAnchor.TOP_LEFT:c=b._controlsTL;a.style.position=d;break;case Seadragon.ControlAnchor.NONE:default:c=b._container;a.style.position="absolute"}b._controls.push(new Seadragon.Control(a,e,c));a.style.display="inline-block"},isOpen:function(){return!!this.source},openDzi:function(c,b){var a=this._beforeOpen();Seadragon.DziTileSourceHelper.createFromXml(c,b,Seadragon.Utils.createCallback(null,Function.createDelegate(this,this._onOpen),a))},openTileSource:function(b){var a=beforeOpen();window.setTimeout(Function.createDelegate(this,function(){onOpen(a,b)}),1)},close:function(){if(!this.source)return;this._onClose()},removeControl:function(b){var b=Seadragon.Utils.getElement(b),a=this._getControlIndex(b);if(a>=0){this._controls[a].destroy();this._controls.splice(a,1)}},clearControls:function(){while(this._controls.length>0)this._controls.pop().destroy()},isDashboardEnabled:function(){for(var a=this._controls.length-1;a>=0;a--)if(this._controls[a].isVisible())return true;return false},isFullPage:function(){return this._container.parentNode==document.body},isMouseNavEnabled:function(){return this._innerTracker.isTracking()},isVisible:function(){return this._container.style.visibility!="hidden"},setDashboardEnabled:function(b){for(var a=this._controls.length-1;a>=0;a--)this._controls[a].setVisible(b)},setFullPage:function(f){var a=this;if(f==a.isFullPage())return;var i=document.body,b=i.style,e=document.documentElement.style,c=a._container.style,d=a._canvas.style;if(f){bodyOverflow=b.overflow;docOverflow=e.overflow;b.overflow="hidden";e.overflow="hidden";bodyWidth=b.width;bodyHeight=b.height;b.width="100%";b.height="100%";d.backgroundColor="black";d.color="white";c.position="fixed";c.zIndex="99999999";i.appendChild(a._container);a._prevContainerSize=Seadragon.Utils.getWindowSize();a._onContainerEnter()}else{b.overflow=bodyOverflow;e.overflow=docOverflow;b.width=bodyWidth;b.height=bodyHeight;d.backgroundColor="";d.color="";c.position="relative";c.zIndex="";a.get_element().appendChild(a._container);a._prevContainerSize=Seadragon.Utils.getElementSize(a.get_element());a._onContainerExit()}if(a.viewport){var h=a.viewport.getBounds();a.viewport.resize(a._prevContainerSize);var g=a.viewport.getBounds();if(f)a._fsBoundsDelta=new Seadragon.Point(g.width/h.width,g.height/h.height);else{a.viewport.update();a.viewport.zoomBy(Math.max(a._fsBoundsDelta.x,a._fsBoundsDelta.y),null,true)}a._forceRedraw=true;a._raiseEvent("resize",a);a._updateOnce()}},setMouseNavEnabled:function(a){this._innerTracker.setTracking(a)},setVisible:function(a){this._container.style.visibility=a?"":"hidden"}};Seadragon.Strings={Errors:{Failure:"Sorry, but Seadragon Ajax can't run on your browser!\nPlease try using IE 7 or Firefox 3.\n",Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Empty:"You asked us to open nothing, so we did just that.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",Unknown:"Whoops, something inexplicably went wrong. Sorry!"},Messages:{Loading:"Loading..."},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out"},getString:function(e){for(var c=e.split("."),a=Seadragon.Strings,b=0;b<c.length;b++)a=a[c[b]]||{};if(typeof a!="string")a="";var d=arguments;return a.replace(/\{\d+\}/g,function(b){var a=parseInt(b.match(/\d+/))+1;return a<d.length?d[a]:""})},setString:function(e,d){for(var c=e.split("."),b=Seadragon.Strings,a=0;a<c.length-1;a++){if(!b[c[a]])b[c[a]]={};b=b[c[a]]}b[c[a]]=d}};Seadragon.Strings=Seadragon.Strings;Seadragon.Point=Seadragon.Point=function(a,b){this.x=typeof a=="number"?a:0;this.y=typeof b=="number"?b:0};Seadragon.Point.prototype={plus:function(a){return new Seadragon.Point(this.x+a.x,this.y+a.y)},minus:function(a){return new Seadragon.Point(this.x-a.x,this.y-a.y)},times:function(a){return new Seadragon.Point(this.x*a,this.y*a)},divide:function(a){return new Seadragon.Point(this.x/a,this.y/a)},negate:function(){return new Seadragon.Point(-this.x,-this.y)},distanceTo:function(a){return Math.sqrt(Math.pow(this.x-a.x,2)+Math.pow(this.y-a.y,2))},apply:function(a){return new Seadragon.Point(a(this.x),a(this.y))},equals:function(a){return a instanceof Seadragon.Point&&this.x===a.x&&this.y===a.y},toString:function(){return"("+this.x+","+this.y+")"}};Seadragon.Profiler=function(){var a=this;a._midUpdate=false;a._numUpdates=0;a._lastBeginTime=null;a._lastEndTime=null;a._minUpdateTime=Infinity;a._avgUpdateTime=0;a._maxUpdateTime=0;a._minIdleTime=Infinity;a._avgIdleTime=0;a._maxIdleTime=0};Seadragon.Profiler.prototype={getAvgUpdateTime:function(){return this._avgUpdateTime},getMinUpdateTime:function(){return this._minUpdateTime},getMaxUpdateTime:function(){return this._maxUpdateTime},getAvgIdleTime:function(){return this._avgIdleTime},getMinIdleTime:function(){return this._minIdleTime},getMaxIdleTime:function(){return this._maxIdleTime},isMidUpdate:function(){return this._midUpdate},getNumUpdates:function(){return this._numUpdates},beginUpdate:function(){var a=this;a._midUpdate&&a.endUpdate();a._midUpdate=true;a._lastBeginTime=(new Date).getTime();if(a._numUpdates<1)return;var b=a._lastBeginTime-a._lastEndTime;a._avgIdleTime=(a._avgIdleTime*(a._numUpdates-1)+b)/a._numUpdates;if(b<a._minIdleTime)a._minIdleTime=b;if(b>a._maxIdleTime)a._maxIdleTime=b},endUpdate:function(){var a=this;if(!a._midUpdate)return;a._lastEndTime=(new Date).getTime();a._midUpdate=false;var b=a._lastEndTime-a._lastBeginTime;a._numUpdates++;a._avgUpdateTime=(a._avgUpdateTime*(a._numUpdates-1)+b)/a._numUpdates;if(b<a._minUpdateTime)a._minUpdateTime=b;if(b>a._maxUpdateTime)a._maxUpdateTime=b},clearProfile:function(){var a=this;a._midUpdate=false;a._numUpdates=0;a._lastBeginTime=null;a._lastEndTime=null;a._minUpdateTime=Infinity;a._avgUpdateTime=0;a._maxUpdateTime=0;a._minIdleTime=Infinity;a._avgIdleTime=0;a._maxIdleTime=0}};Seadragon.Job=function(c,b){var a=this;a._image=null;a._timeout=null;a._src=c;a._callback=b;a.TIMEOUT=5e3};Seadragon.Job.prototype={_finish:function(d){var b=null,a=this;a._image.onload=b;a._image.onabort=b;a._image.onerror=b;a._timeout&&window.clearTimeout(a._timeout);var e=a._image,c=a._callback;window.setTimeout(function(){c(this._src,d?e:b)},1)},_onloadHandler:function(){this._finish(true)},_onerrorHandler:function(){this._finish(false)},start:function(){var a=this;a._image=new Image;a._image.onload=Function.createDelegate(a,a._onloadHandler);a._image.onabort=Function.createDelegate(a,a._onerrorHandler);a._image.onerror=Function.createDelegate(a,a._onerrorHandler);a._timeout=window.setTimeout(Function.createDelegate(a,a._onerrorHandler),a.TIMEOUT);a._image.src=a._src}};Seadragon.ImageLoader=function(a){this._downloading=0;this.imageLoaderLimit=a};Seadragon.ImageLoader.prototype={_onComplete:function(a,c,b){this._downloading--;if(typeof a=="function")try{a(b)}catch(d){Seadragon.Debug.error(d.name+" while executing "+c+" callback: "+d.message,d)}},loadImage:function(e,b){var a=this;if(a._downloading>=a.imageLoaderLimit)return false;var c=Seadragon.Utils.createCallback(null,Function.createDelegate(a,a._onComplete),b),d=new Seadragon.Job(e,c);a._downloading++;d.start();return true}};Seadragon.TileSource=function(c,b,g,d,f,e){var a=this;a.aspectRatio=c/b;a.dimensions=new Seadragon.Point(c,b);a.minLevel=f?f:0;a.maxLevel=e?e:Math.ceil(Math.log(Math.max(c,b))/Math.log(2));a.tileSize=g?g:0;a.tileOverlap=d?d:0};Seadragon.TileSource.prototype={getLevelScale:function(a){return 1/(1<<this.maxLevel-a)},getNumTiles:function(c){var a=this,b=a.getLevelScale(c),d=Math.ceil(b*a.dimensions.x/a.tileSize),e=Math.ceil(b*a.dimensions.y/a.tileSize);return new Seadragon.Point(d,e)},getPixelRatio:function(b){var a=this.dimensions.times(this.getLevelScale(b)),c=1/a.x,d=1/a.y;return new Seadragon.Point(c,d)},getTileAtPoint:function(c,d){var a=this,b=d.times(a.dimensions.x).times(a.getLevelScale(c)),e=Math.floor(b.x/a.tileSize),f=Math.floor(b.y/a.tileSize);return new Seadragon.Point(e,f)},getTileBounds:function(j,f,g){var a=this,c=a.dimensions.times(a.getLevelScale(j)),h=f===0?0:a.tileSize*f-a.tileOverlap,i=g===0?0:a.tileSize*g-a.tileOverlap,d=a.tileSize+(f===0?1:2)*a.tileOverlap,e=a.tileSize+(g===0?1:2)*a.tileOverlap;d=Math.min(d,c.x-h);e=Math.min(e,c.y-i);var b=1/c.x;return new Seadragon.Rect(h*b,i*b,d*b,e*b)},getTileUrl:function(){throw new Error("Method not implemented.");},tileExists:function(a,c,d){var b=this.getNumTiles(a);return a>=this.minLevel&&a<=this.maxLevel&&c>=0&&d>=0&&c<b.x&&d<b.y}};Seadragon.DziError=function(a){Error.apply(this,arguments);this.message=a};Seadragon.DziError.prototype=new Error;Seadragon.DziError.constructor=Seadragon.DziError;Seadragon.DziTileSource=function(h,g,e,c,f,d,b){var a=this;Seadragon.TileSource.call(a,h,g,e,c,null,null);a._levelRects={};a.tilesUrl=f;a.fileFormat=d;a.displayRects=b;a.initialize()};Seadragon.DziTileSource.prototype=new Seadragon.TileSource;Seadragon.DziTileSource.prototype.constructor=Seadragon.DziTileSource;Seadragon.DziTileSource.prototype.initialize=function(){var a=this;if(!a.displayRects)return;for(var d=a.displayRects.length-1;d>=0;d--)for(var c=a.displayRects[d],b=c.minLevel;b<=c.maxLevel;b++){if(!a._levelRects[b])a._levelRects[b]=[];a._levelRects[b].push(c)}};Seadragon.DziTileSource.prototype.getTileUrl=function(a,b,c){return[this.tilesUrl,a,"/",b,"_",c,".",this.fileFormat].join("")};Seadragon.DziTileSource.prototype.tileExists=function(c,k,l){var a=this,d=a._levelRects[c];if(!d||!d.length)return true;for(var j=d.length-1;j>=0;j--){var b=d[j];if(c<b.minLevel||c>b.maxLevel)continue;var e=a.getLevelScale(c),f=b.x*e,g=b.y*e,h=f+b.width*e,i=g+b.height*e;f=Math.floor(f/a.tileSize);g=Math.floor(g/a.tileSize);h=Math.ceil(h/a.tileSize);i=Math.ceil(i/a.tileSize);if(f<=k&&k<h&&g<=l&&l<i)return true}return false};Seadragon._DziTileSourceHelper=function(){};Seadragon._DziTileSourceHelper.prototype={createFromXml:function(h,e,f){var b=null,a=this,i=typeof f=="function",d=b;if(!h){a.error=Seadragon.Strings.getString("Errors.Empty");if(i){window.setTimeout(function(){f(b,d)},1);return b}throw new Seadragon.DziError(d);}var c=h.split("/"),j=c[c.length-1],l=j.lastIndexOf(".");if(l>-1)c[c.length-1]=j.slice(0,l);var m=c.join("/")+"_files/";function g(a,c){try{return a(c,m)}catch(e){if(i){d=this.getError(e).message;return b}else throw this.getError(e);}}if(i){if(e){var k=Function.createDelegate(a,a.processXml);window.setTimeout(function(){var a=g(k,Seadragon.Utils.parseXml(e));f(a,d)},1)}else{var k=Function.createDelegate(a,a.processResponse);Seadragon.Utils.makeAjaxRequest(h,function(b){var a=g(k,b);f(a,d)})}return b}return e?g(Function.createDelegate(a,a.processXml),Seadragon.Utils.parseXml(e)):g(Function.createDelegate(a,a.processResponse),Seadragon.Utils.makeAjaxRequest(h))},processResponse:function(a,e){if(!a)throw new Seadragon.DziError(Seadragon.Strings.getString("Errors.Security"));else if(a.status!==200&&a.status!==0){var c=a.status,d=c==404?"Not Found":a.statusText;throw new Seadragon.DziError(Seadragon.Strings.getString("Errors.Status",c,d));}var b=null;if(a.responseXML&&a.responseXML.documentElement)b=a.responseXML;else if(a.responseText)b=Seadragon.Utils.parseXml(a.responseText);return this.processXml(b,e)},processXml:function(c,e){var a="Errors.Dzi";if(!c||!c.documentElement)throw new Seadragon.DziError(Seadragon.Strings.getString("Errors.Xml"));var d=c.documentElement,b=d.tagName;if(b=="Image")try{return this.processDzi(d,e)}catch(g){var f=Seadragon.Strings.getString(a);throw g instanceof Seadragon.DziError?g:new Seadragon.DziError(f);}else if(b=="Collection")throw new Seadragon.DziError(Seadragon.Strings.getString("Errors.Dzc"));else if(b=="Error")return this.processError(d);throw new Seadragon.DziError(Seadragon.Strings.getString(a));},processDzi:function(a,k){var c=a.getAttribute("Format");if(!Seadragon.Utils.imageFormatSupported(c))throw new Seadragon.DziError(Seadragon.Strings.getString("Errors.ImageFormat",c.toUpperCase()));for(var h=a.getElementsByTagName("Size")[0],e=a.getElementsByTagName("DisplayRect"),m=parseInt(h.getAttribute("Width"),10),l=parseInt(h.getAttribute("Height"),10),j=parseInt(a.getAttribute("TileSize")),i=parseInt(a.getAttribute("Overlap")),g=[],d=0;d<e.length;d++){var f=e[d],b=f.getElementsByTagName("Rect")[0];g.push(new Seadragon.DisplayRect(parseInt(b.getAttribute("X"),10),parseInt(b.getAttribute("Y"),10),parseInt(b.getAttribute("Width"),10),parseInt(b.getAttribute("Height"),10),0,parseInt(f.getAttribute("MaxLevel"),10)))}return new Seadragon.DziTileSource(m,l,j,i,k,c,g)},processError:function(b){var a=b.getElementsByTagName("Message")[0],c=a.firstChild.nodeValue;throw new Seadragon.DziError(c);},getError:function(a){if(!(a instanceof DziError)){Seadragon.Debug.error(a.name+" while creating DZI from XML: "+a.message);a=new Seadragon.DziError(Seadragon.Strings.getString("Errors.Unknown"))}}};Seadragon.DziTileSourceHelper=new Seadragon._DziTileSourceHelper;Seadragon.ButtonState=function(){throw Error.invalidOperation();};Seadragon.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3};Seadragon.Button=function(b,c){var a=this;a._tooltip=b.tooltip;a._srcRest=b.srcRest;a._srcGroup=b.srcGroup;a._srcHover=b.srcHover;a._srcDown=b.srcDown;a._button=b.button;a.config=b.config;a.initialize(c)};Seadragon.Button.prototype={initialize:function(b){var a=this;a._observer=new Observer;b.onPress!=undefined&&a.add_onPress(b.onPress);b.onRelease!=undefined&&a.add_onRelease(b.onRelease);b.onClick!=undefined&&a.add_onClick(b.onClick);b.onEnter!=undefined&&a.add_onEnter(b.onEnter);b.onExit!=undefined&&a.add_onExit(b.onExit);a._button=Seadragon.Utils.makeNeutralElement("span");a._currentState=Seadragon.ButtonState.GROUP;a._tracker=new Seadragon.MouseTracker(a._button,a.config.clickTimeThreshold,a.config.clickDistThreshold);a._imgRest=Seadragon.Utils.makeTransparentImage(a._srcRest);a._imgGroup=Seadragon.Utils.makeTransparentImage(a._srcGroup);a._imgHover=Seadragon.Utils.makeTransparentImage(a._srcHover);a._imgDown=Seadragon.Utils.makeTransparentImage(a._srcDown);a._fadeDelay=0;a._fadeLength=2e3;a._fadeBeginTime=null;a._shouldFade=false;a._button.style.display="inline-block";a._button.style.position="relative";a._button.title=a._tooltip;a._button.appendChild(a._imgRest);a._button.appendChild(a._imgGroup);a._button.appendChild(a._imgHover);a._button.appendChild(a._imgDown);var f=a._imgRest.style,e=a._imgGroup.style,c=a._imgHover.style,d=a._imgDown.style;e.position=c.position=d.position="absolute";e.top=c.top=d.top="0px";e.left=c.left=d.left="0px";c.visibility=d.visibility="hidden";if(Seadragon.Utils.getBrowser()==Seadragon.Browser.FIREFOX&&Seadragon.Utils.getBrowserVersion()<3)e.top=c.top=d.top="";a._tracker.enterHandler=Function.createDelegate(a,a._enterHandler);a._tracker.exitHandler=Function.createDelegate(a,a._exitHandler);a._tracker.pressHandler=Function.createDelegate(a,a._pressHandler);a._tracker.releaseHandler=Function.createDelegate(a,a._releaseHandler);a._tracker.clickHandler=Function.createDelegate(a,a._clickHandler);a._tracker.setTracking(true);a._outTo(Seadragon.ButtonState.REST)},dispose:function(){},_scheduleFade:function(){window.setTimeout(Function.createDelegate(this,this._updateFade),20)},_updateFade:function(){var b=this;if(b._shouldFade){var c=(new Date).getTime(),d=c-b._fadeBeginTime,a=1-d/b._fadeLength;a=Math.min(1,a);a=Math.max(0,a);Seadragon.Utils.setElementOpacity(b._imgGroup,a,true);a>0&&b._scheduleFade()}},_beginFading:function(){var a=this;a._shouldFade=true;a._fadeBeginTime=(new Date).getTime()+a._fadeDelay;window.setTimeout(Function.createDelegate(a,a._scheduleFade),a._fadeDelay)},_stopFading:function(){this._shouldFade=false;Seadragon.Utils.setElementOpacity(this._imgGroup,1,true)},_inTo:function(b){var a=this;if(b>=Seadragon.ButtonState.GROUP&&a._currentState==Seadragon.ButtonState.REST){a._stopFading();a._currentState=Seadragon.ButtonState.GROUP}if(b>=Seadragon.ButtonState.HOVER&&a._currentState==Seadragon.ButtonState.GROUP){a._imgHover.style.visibility="";a._currentState=Seadragon.ButtonState.HOVER}if(b>=Seadragon.ButtonState.DOWN&&a._currentState==Seadragon.ButtonState.HOVER){a._imgDown.style.visibility="";a._currentState=Seadragon.ButtonState.DOWN}},_outTo:function(b){var a=this;if(b<=Seadragon.ButtonState.HOVER&&a._currentState==Seadragon.ButtonState.DOWN){a._imgDown.style.visibility="hidden";a._currentState=Seadragon.ButtonState.HOVER}if(b<=Seadragon.ButtonState.GROUP&&a._currentState==Seadragon.ButtonState.HOVER){a._imgHover.style.visibility="hidden";a._currentState=Seadragon.ButtonState.GROUP}if(a._newState<=Seadragon.ButtonState.REST&&a._currentState==Seadragon.ButtonState.GROUP){a._beginFading();a._currentState=Seadragon.ButtonState.REST}},_enterHandler:function(e,d,b,c){var a=this;if(b){a._inTo(Seadragon.ButtonState.DOWN);a._raiseEvent("onEnter",a)}else!c&&a._inTo(Seadragon.ButtonState.HOVER)},_exitHandler:function(d,c,a){this._outTo(Seadragon.ButtonState.GROUP);a&&this._raiseEvent("onExit",this)},_pressHandler:function(){this._inTo(Seadragon.ButtonState.DOWN);this._raiseEvent("onPress",this)},_releaseHandler:function(e,d,b,c){var a=this;if(b&&c){a._outTo(Seadragon.ButtonState.HOVER);a._raiseEvent("onRelease",a)}else if(b)a._outTo(Seadragon.ButtonState.GROUP);else a._inTo(Seadragon.ButtonState.HOVER)},_clickHandler:function(c,b,a){a&&this._raiseEvent("onClick",this)},get_events:function(){return this._observer._getContext(this,true).events},_raiseEvent:function(c,a){var b=this.get_events().getHandler(c);if(b){if(!a)a={};b(this,a)}},get_element:function(){return this._button},get_tooltip:function(){return this._tooltip},set_tooltip:function(a){this._tooltip=a},get_config:function(){return this.config},set_config:function(a){this.config=a},get_srcRest:function(){return this._srcRest},set_srcRest:function(a){this._srcRest=a},get_srcGroup:function(){return this._srcGroup},set_srcGroup:function(a){this._srcGroup=a},get_srcHover:function(){return this._srcHover},set_srcHover:function(a){this._srcHover=a},get_srcDown:function(){return this._srcDown},set_srcDown:function(a){this._srcDown=a},add_onPress:function(a){this.get_events().addHandler("onPress",a)},remove_onPress:function(a){this.get_events().removeHandler("onPress",a)},add_onClick:function(a){this.get_events().addHandler("onClick",a)},remove_onClick:function(a){this.get_events().removeHandler("onClick",a)},add_onEnter:function(a){this.get_events().addHandler("onEnter",a)},remove_onEnter:function(a){this.get_events().removeHandler("onEnter",a)},add_onRelease:function(a){this.get_events().addHandler("onRelease",a)},remove_onRelease:function(a){this.get_events().removeHandler("onRelease",a)},add_onExit:function(a){this.get_events().addHandler("onExit",a)},remove_onExit:function(a){this.get_events().removeHandler("onExit",a)},notifyGroupEnter:function(){this._inTo(Seadragon.ButtonState.GROUP)},notifyGroupExit:function(){this._outTo(Seadragon.ButtonState.REST)}};Seadragon.ButtonGroup=function(b){var a=this;a._buttons=b.buttons;a._group=b.group;a.config=b.config;a.initialize()};Seadragon.ButtonGroup.prototype={initialize:function(){var a=this;a._group=Seadragon.Utils.makeNeutralElement("span");var d=a._buttons.concat([]),b=new Seadragon.MouseTracker(a._group,a.config.clickTimeThreshold,a.config.clickDistThreshold);a._group.style.display="inline-block";for(var c=0;c<d.length;c++)a._group.appendChild(d[c].get_element());b.enterHandler=Function.createDelegate(a,a._enterHandler);b.exitHandler=Function.createDelegate(a,a._exitHandler);b.releaseHandler=Function.createDelegate(a,a._releaseHandler);b.setTracking(true)},dispose:function(){},get_buttons:function(){return this._buttons},set_buttons:function(a){this._buttons=a},get_element:function(){return this._group},get_config:function(){return this.config},set_config:function(a){this.config=a},_enterHandler:function(){for(var a=0;a<this._buttons.length;a++)this._buttons[a].notifyGroupEnter()},_exitHandler:function(e,d,b){if(!b)for(var a=0;a<this._buttons.length;a++)this._buttons[a].notifyGroupExit()},_releaseHandler:function(e,d,c,b){if(!b)for(var a=0;a<this._buttons.length;a++)this._buttons[a].notifyGroupExit()},emulateEnter:function(){this._enterHandler()},emulateExit:function(){this._exitHandler()}};Seadragon.Config=function(){var c=false,b=true,a=this;a.debugMode=b;a.animationTime=1.5;a.blendTime=.5;a.alwaysBlend=c;a.autoHideControls=b;a.immediateRender=c;a.wrapHorizontal=c;a.wrapVertical=c;a.minZoomImageRatio=.8;a.maxZoomPixelRatio=2;a.visibilityRatio=.5;a.springStiffness=5;a.imageLoaderLimit=2;a.clickTimeThreshold=200;a.clickDistThreshold=5;a.zoomPerClick=2;a.zoomPerScroll=1.2;a.zoomPerSecond=2;a.showNavigationControl=b;a.maxImageCacheCount=100;a.minPixelRatio=.5;a.mouseNavEnabled=b;a.navImages={zoomIn:{REST:"/Scripts/images/zoomin_rest.png",GROUP:"/Scripts/images/zoomin_grouphover.png",HOVER:"/Scripts/images/zoomin_hover.png",DOWN:"/Scripts/images/zoomin_pressed.png"},zoomOut:{REST:"/Scripts/images/zoomout_rest.png",GROUP:"/Scripts/images/zoomout_grouphover.png",HOVER:"/Scripts/images/zoomout_hover.png",DOWN:"/Scripts/images/zoomout_pressed.png"},home:{REST:"/Scripts/images/home_rest.png",GROUP:"/Scripts/images/home_grouphover.png",HOVER:"/Scripts/images/home_hover.png",DOWN:"/Scripts/images/home_pressed.png"},fullpage:{REST:"/Scripts/images/fullpage_rest.png",GROUP:"/Scripts/images/fullpage_grouphover.png",HOVER:"/Scripts/images/fullpage_hover.png",DOWN:"/Scripts/images/fullpage_pressed.png"}}};Seadragon.Rect=function(e,f,d,c){var a="number",b=this;b.x=typeof e==a?e:0;b.y=typeof f==a?f:0;b.width=typeof d==a?d:0;b.height=typeof c==a?c:0};Seadragon.Rect.prototype={getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new Seadragon.Point(this.x,this.y)},getBottomRight:function(){var a=this;return new Seadragon.Point(a.x+a.width,a.y+a.height)},getCenter:function(){var a=this;return new Seadragon.Point(a.x+a.width/2,a.y+a.height/2)},getSize:function(){return new Seadragon.Point(this.width,this.height)},equals:function(a){var b=this;return a instanceof Seadragon.Rect&&b.x===a.x&&b.y===a.y&&b.width===a.width&&b.height===a.height},toString:function(){var a=this;return"["+a.x+","+a.y+","+a.width+"x"+a.height+"]"}};Seadragon.DisplayRect=function(e,f,d,c,b,a){Seadragon.Rect.apply(this,[e,f,d,c]);this.minLevel=b;this.maxLevel=a};Seadragon.DisplayRect.prototype=new Seadragon.Rect;Seadragon.DisplayRect.prototype.constructor=Seadragon.DisplayRect;Seadragon.Spring=Seadragon.Spring=function(b,c){var a=this;a._currentValue=typeof b=="number"?b:0;a._startValue=a._currentValue;a._targetValue=a._currentValue;a.config=c;a._currentTime=(new Date).getTime();a._startTime=a._currentTime;a._targetTime=a._currentTime};Seadragon.Spring.prototype={_transform:function(b){var a=this.config.springStiffness;return(1-Math.exp(-b*a))/(1-Math.exp(-a))},getCurrent:function(){return this._currentValue},getTarget:function(){return this._targetValue},resetTo:function(b){var a=this;a._targetValue=b;a._targetTime=a._currentTime;a._startValue=a._targetValue;a._startTime=a._targetTime},springTo:function(b){var a=this;a._startValue=a._currentValue;a._startTime=a._currentTime;a._targetValue=b;a._targetTime=a._startTime+1e3*a.config.animationTime},shiftBy:function(a){this._startValue+=a;this._targetValue+=a},update:function(){var a=this;a._currentTime=(new Date).getTime();a._currentValue=a._currentTime>=a._targetTime?a._targetValue:a._startValue+(a._targetValue-a._startValue)*a._transform((a._currentTime-a._startTime)/(a._targetTime-a._startTime))}};var QUOTA=100,MIN_PIXEL_RATIO=.5,browser=Seadragon.Utils.getBrowser(),browserVer=Seadragon.Utils.getBrowserVersion(),subpixelRenders=browser==Seadragon.Browser.FIREFOX||browser==Seadragon.Browser.OPERA||browser==Seadragon.Browser.SAFARI&&browserVer>=4||browser==Seadragon.Browser.CHROME&&browserVer>=2,useCanvas=typeof document.createElement("canvas").getContext=="function"&&subpixelRenders;Seadragon.Tile=function(e,g,h,c,d,f){var b=null,a=this;a.level=e;a.x=g;a.y=h;a.bounds=c;a.exists=d;a.loaded=false;a.loading=false;a.elmt=b;a.image=b;a.url=f;a.style=b;a.position=b;a.size=b;a.blendStart=b;a.opacity=b;a.distance=b;a.visibility=b;a.beingDrawn=false;a.lastTouchTime=0};Seadragon.Tile.prototype={dispose:function(){},toString:function(){return this.level+"/"+this.x+"_"+this.y},drawHTML:function(e){var b="px",a=this;if(!a.loaded){Seadragon.Debug.error("Attempting to draw tile "+a.toString()+" when it's not yet loaded.");return}if(!a.elmt){a.elmt=Seadragon.Utils.makeNeutralElement("img");a.elmt.src=a.url;a.style=a.elmt.style;a.style.position="absolute";a.style.msInterpolationMode="nearest-neighbor"}var d=a.elmt,c=a.style,f=a.position.apply(Math.floor),g=a.size.apply(Math.ceil);d.parentNode!=e&&e.appendChild(d);c.left=f.x+b;c.top=f.y+b;c.width=g.x+b;c.height=g.y+b;Seadragon.Utils.setElementOpacity(d,a.opacity)},drawCanvas:function(c){var a=this;if(!a.loaded){Seadragon.Debug.error("Attempting to draw tile "+a.toString()+" when it's not yet loaded.");return}var b=a.position,d=a.size;c.globalAlpha=a.opacity;c.drawImage(a.image,b.x,b.y,d.x,d.y)},unload:function(){var a=this;a.elmt&&a.elmt.parentNode&&a.elmt.parentNode.removeChild(a.elmt);a.elmt=null;a.image=null;a.loaded=false;a.loading=false}};Seadragon.Overlay=function(c,a,d){var b=this;b.elmt=c;b.scales=a instanceof Seadragon.Rect;b.bounds=new Seadragon.Rect(a.x,a.y,a.width,a.height);b.placement=a instanceof Seadragon.Point?d:Seadragon.OverlayPlacement.TOP_LEFT;b.position=new Seadragon.Point(a.x,a.y);b.size=new Seadragon.Point(a.width,a.height);b.style=c.style};Seadragon.Overlay.prototype={adjust:function(a,b){switch(this.placement){case Seadragon.OverlayPlacement.TOP_LEFT:break;case Seadragon.OverlayPlacement.TOP:a.x-=b.x/2;break;case Seadragon.OverlayPlacement.TOP_RIGHT:a.x-=b.x;break;case Seadragon.OverlayPlacement.RIGHT:a.x-=b.x;a.y-=b.y/2;break;case Seadragon.OverlayPlacement.BOTTOM_RIGHT:a.x-=b.x;a.y-=b.y;break;case Seadragon.OverlayPlacement.BOTTOM:a.x-=b.x/2;a.y-=b.y;break;case Seadragon.OverlayPlacement.BOTTOM_LEFT:a.y-=b.y;break;case Seadragon.OverlayPlacement.LEFT:a.y-=b.y/2;break;case Seadragon.OverlayPlacement.CENTER:default:a.x-=b.x/2;a.y-=b.y/2}},destroy:function(){var b=this.elmt,a=this.style;b.parentNode&&b.parentNode.removeChild(b);a.top="";a.left="";a.position="";if(this.scales){a.width="";a.height=""}},drawHTML:function(g){var e="px",a=this,f=a.elmt,c=a.style,h=a.scales;f.parentNode!=g&&g.appendChild(f);if(!h)a.size=Seadragon.Utils.getElementSize(f);var b=a.position,d=a.size;a.adjust(b,d);b=b.apply(Math.floor);d=d.apply(Math.ceil);c.left=b.x+e;c.top=b.y+e;c.position="absolute";if(h){c.width=d.x+e;c.height=d.y+e}},update:function(a,b){this.scales=a instanceof Seadragon.Rect;this.bounds=new Seadragon.Rect(a.x,a.y,a.width,a.height);this.placement=a instanceof Seadragon.Point?b:Seadragon.OverlayPlacement.TOP_LEFT}};Seadragon.Drawer=function(b,c,d){var a=this;a._container=Seadragon.Utils.getElement(d);a._canvas=Seadragon.Utils.makeNeutralElement(useCanvas?"canvas":"div");a._context=useCanvas?a._canvas.getContext("2d"):null;a._viewport=c;a._source=b;a.config=a._viewport.config;a._imageLoader=new Seadragon.ImageLoader(a.config.imageLoaderLimit);a._profiler=new Seadragon.Profiler;a._minLevel=b.minLevel;a._maxLevel=b.maxLevel;a._tileSize=b.tileSize;a._tileOverlap=b.tileOverlap;a._normHeight=b.dimensions.y/b.dimensions.x;a._cacheNumTiles={};a._cachePixelRatios={};a._tilesMatrix={};a._tilesLoaded=[];a._coverage={};a._overlays=[];a._lastDrawn=[];a._lastResetTime=0;a._midUpdate=false;a._updateAgain=true;a.elmt=a._container;a._init()};Seadragon.Drawer.prototype={dispose:function(){},_init:function(){var a=this;a._canvas.style.width="100%";a._canvas.style.height="100%";a._canvas.style.position="absolute";a._container.style.textAlign="left";a._container.appendChild(a._canvas)},_compareTiles:function(b,a){if(!b)return a;if(a.visibility>b.visibility)return a;else if(a.visibility==b.visibility)if(a.distance<b.distance)return a;return b},_getNumTiles:function(b){var a=this;if(!a._cacheNumTiles[b])a._cacheNumTiles[b]=a._source.getNumTiles(b);return a._cacheNumTiles[b]},_getPixelRatio:function(b){var a=this;if(!a._cachePixelRatios[b])a._cachePixelRatios[b]=a._source.getPixelRatio(b);return a._cachePixelRatios[b]},_getTile:function(b,c,d,l,e,f){var a=this;if(!a._tilesMatrix[b])a._tilesMatrix[b]={};if(!a._tilesMatrix[b][c])a._tilesMatrix[b][c]={};if(!a._tilesMatrix[b][c][d]){var g=(e+c%e)%e,h=(f+d%f)%f,i=a._source.getTileBounds(b,g,h),k=a._source.tileExists(b,g,h),m=a._source.getTileUrl(b,g,h);i.x+=1*(c-g)/e;i.y+=a._normHeight*(d-h)/f;a._tilesMatrix[b][c][d]=new Seadragon.Tile(b,c,d,i,k,m)}var j=a._tilesMatrix[b][c][d];j.lastTouchTime=l;return j},_loadTile:function(a,b){a.loading=this._imageLoader.loadImage(a.url,Seadragon.Utils.createCallback(null,Function.createDelegate(this,this._onTileLoad),a,b))},_onTileLoad:function(b,m,j){var a=this;b.loading=false;if(a._midUpdate){Seadragon.Debug.error("Tile load callback in middle of drawing routine.");return}else if(!j){Seadragon.Debug.log("Tile "+b+" failed to load: "+b.url);b.exists=false;return}else if(m<a._lastResetTime){Seadragon.Debug.log("Ignoring tile "+b+" loaded before reset: "+b.url);return}b.loaded=true;b.image=j;var g=a._tilesLoaded.length;if(a._tilesLoaded.length>=QUOTA){for(var n=Math.ceil(Math.log(a._tileSize)/Math.log(2)),c=null,f=-1,e=a._tilesLoaded.length-1;e>=0;e--){var d=a._tilesLoaded[e];if(d.level<=a._cutoff||d.beingDrawn)continue;else if(!c){c=d;f=e;continue}var i=d.lastTouchTime,h=c.lastTouchTime,l=d.level,k=c.level;if(i<h||i==h&&l>k){c=d;f=e}}if(c&&f>=0){c.unload();g=f}}a._tilesLoaded[g]=b;a._updateAgain=true},_clearTiles:function(){this._tilesMatrix={};this._tilesLoaded=[]},_providesCoverage:function(b,c,f){var a=this;if(!a._coverage[b])return false;if(c===undefined||f===undefined){var e=a._coverage[b];for(var g in e)if(e.hasOwnProperty(g)){var d=e[g];for(var h in d)if(d.hasOwnProperty(h)&&!d[h])return false}return true}return a._coverage[b][c]===undefined||a._coverage[b][c][f]===undefined||a._coverage[b][c][f]===true},_isCovered:function(b,c,d){var a=this;return c===undefined||d===undefined?a._providesCoverage(b+1):a._providesCoverage(b+1,2*c,2*d)&&a._providesCoverage(b+1,2*c,2*d+1)&&a._providesCoverage(b+1,2*c+1,2*d)&&a._providesCoverage(b+1,2*c+1,2*d+1)},_setCoverage:function(a,c,e,d){var b=this;if(!b._coverage[a]){Seadragon.Debug.error("Setting coverage for a tile before its level's coverage has been reset: "+a);return}if(!b._coverage[a][c])b._coverage[a][c]={};b._coverage[a][c][e]=d},_resetCoverage:function(a){this._coverage[a]={}},_compareTiles:function(b,a){if(!b)return a;if(a.visibility>b.visibility)return a;else if(a.visibility==b.visibility)if(a.distance<b.distance)return a;return b},_getOverlayIndex:function(b){for(var a=this._overlays.length-1;a>=0;a--)if(this._overlays[a].elmt==b)return a;return-1},_updateActual:function(){var c=true,e=false,a=this;a._updateAgain=e;var r=a._canvas,Q=a._context,fb=a._container,J=useCanvas,m=a._lastDrawn;while(m.length>0){var b=m.pop();b.beingDrawn=e}var G=a._viewport.getContainerSize(),E=G.x,C=G.y;r.innerHTML="";if(J){r.width=E;r.height=C;Q.clearRect(0,0,E,C)}var B=a._viewport.getBounds(c),h=B.getTopLeft(),g=B.getBottomRight();if(!a.config.wrapHorizontal&&(g.x<0||h.x>1))return;else if(!a.config.wrapVertical&&(g.y<0||h.y>a._normHeight))return;var jb=Math.abs,kb=Math.ceil,T=Math.floor,t=Math.log,x=Math.max,f=Math.min,ab=a.config.alwaysBlend,A=1e3*a.config.blendTime,V=a.config.immediateRender,D=a.config.wrapHorizontal,H=a.config.wrapVertical;if(!D){h.x=x(h.x,0);g.x=f(g.x,1)}if(!H){h.y=x(h.y,0);g.y=f(g.y,a._normHeight)}var s=null,p=e,n=(new Date).getTime(),X=a._viewport.pixelFromPoint(a._viewport.getCenter()),eb=a._viewport.deltaPixelsFromPoints(a._source.getPixelRatio(0),e).x,y=V?1:eb,o=x(a._minLevel,T(t(a.config.minZoomImageRatio)/t(2))),db=a._viewport.deltaPixelsFromPoints(a._source.getPixelRatio(0),c).x,F=f(a._maxLevel,T(t(db/MIN_PIXEL_RATIO)/t(2)));o=f(o,F);for(var d=F;d>=o;d--){var L=e,z=a._viewport.deltaPixelsFromPoints(a._source.getPixelRatio(d),c).x;if(!p&&z>=MIN_PIXEL_RATIO||d==o){L=c;p=c}else if(!p)continue;a._resetCoverage(d);var Y=f(1,(z-.5)/.5),U=a._viewport.deltaPixelsFromPoints(a._source.getPixelRatio(d),e).x,W=y/jb(y-U),S=a._source.getTileAtPoint(d,h),k=a._source.getTileAtPoint(d,g),P=a._getNumTiles(d),M=P.x,N=P.y;if(!D)k.x=f(k.x,M-1);if(!H)k.y=f(k.y,N-1);for(var i=S.x;i<=k.x;i++)for(var j=S.y;j<=k.y;j++){var b=a._getTile(d,i,j,n,M,N),u=L;a._setCoverage(d,i,j,e);if(!b.exists)continue;if(p&&!u)if(a._isCovered(d,i,j))a._setCoverage(d,i,j,c);else u=c;if(!u)continue;var O=b.bounds.getTopLeft(),I=b.bounds.getSize(),gb=a._viewport.pixelFromPoint(O,c),w=a._viewport.deltaPixelsFromPoints(I,c);if(!a._tileOverlap)w=w.plus(new Seadragon.Point(1,1));var hb=a._viewport.pixelFromPoint(O,e),ib=a._viewport.deltaPixelsFromPoints(I,e),cb=hb.plus(ib.divide(2)),Z=X.distanceTo(cb);b.position=gb;b.size=w;b.distance=Z;b.visibility=W;if(b.loaded){if(!b.blendStart)b.blendStart=n;var K=n-b.blendStart,v=f(1,K/A);if(ab)v*=Y;b.opacity=v;m.push(b);if(v==1)a._setCoverage(d,i,j,c);else if(K<A)updateAgain=c}else if(!b.Loading)s=a._compareTiles(s,b)}if(a._providesCoverage(d))break}for(var l=m.length-1;l>=0;l--){var b=m[l];if(J)b.drawCanvas(Q);else b.drawHTML(r);b.beingDrawn=c}for(var bb=a._overlays.length,l=0;l<bb;l++){var q=a._overlays[l],R=q.bounds;q.position=a._viewport.pixelFromPoint(R.getTopLeft(),c);q.size=a._viewport.deltaPixelsFromPoints(R.getSize(),c);q.drawHTML(fb)}if(s){a._loadTile(s,n);a._updateAgain=c}},addOverlay:function(a,c,b){var a=Seadragon.Utils.getElement(a);if(this._getOverlayIndex(a)>=0)return;this._overlays.push(new Seadragon.Overlay(a,c,b));this._updateAgain=true},updateOverlay:function(a,d,c){var a=Seadragon.Utils.getElement(a),b=this._getOverlayIndex(a);if(b>=0){this._overlays[b].update(d,c);this._updateAgain=true}},removeOverlay:function(c){var a=this,c=Seadragon.Utils.getElement(c),b=a._getOverlayIndex(c);if(b>=0){a._overlays[b].destroy();a._overlays.splice(b,1);a._updateAgain=true}},clearOverlays:function(){while(this._overlays.length>0){this._overlays.pop().destroy();this._updateAgain=true}},needsUpdate:function(){return this._updateAgain},numTilesLoaded:function(){return this._tilesLoaded.length},reset:function(){this._clearTiles();this._lastResetTime=(new Date).getTime();this._updateAgain=true},update:function(){var a=this;a._profiler.beginUpdate();a._midUpdate=true;a._updateActual();a._midUpdate=false;a._profiler.endUpdate()},idle:function(){}};Seadragon.Viewport=function(c,b,d){var a=this;a.zoomPoint=null;a.config=d;a._containerSize=c;a._contentSize=b;a._contentAspect=b.x/b.y;a._contentHeight=b.y/b.x;a._centerSpringX=new Seadragon.Spring(0,a.config);a._centerSpringY=new Seadragon.Spring(0,a.config);a._zoomSpring=new Seadragon.Spring(1,a.config);a._homeBounds=new Seadragon.Rect(0,0,1,a._contentHeight);a.goHome(true);a.update()};Seadragon.Viewport.prototype={_getHomeZoom:function(){var a=this._contentAspect/this.getAspectRatio();return a>=1?1:a},_getMinZoom:function(){var a=this._getHomeZoom(),b=this.config.minZoomImageRatio*a;return Math.min(b,a)},_getMaxZoom:function(){var a=this,b=a._contentSize.x*a.config.maxZoomPixelRatio/a._containerSize.x;return Math.max(b,a._getHomeZoom())},getAspectRatio:function(){return this._containerSize.x/this._containerSize.y},getContainerSize:function(){return new Seadragon.Point(this._containerSize.x,this._containerSize.y)},getBounds:function(b){var c=this.getCenter(b),a=1/this.getZoom(b),d=a/this.getAspectRatio();return new Seadragon.Rect(c.x-a/2,c.y-d/2,a,d)},getCenter:function(l){var a=this,b=new Seadragon.Point(a._centerSpringX.getCurrent(),a._centerSpringY.getCurrent()),d=new Seadragon.Point(a._centerSpringX.getTarget(),a._centerSpringY.getTarget());if(l)return b;else if(!a.zoomPoint)return d;var k=a.pixelFromPoint(a.zoomPoint,true),g=a.getZoom(),c=1/g,f=c/a.getAspectRatio(),e=new Seadragon.Rect(b.x-c/2,b.y-f/2,c,f),j=a.zoomPoint.minus(e.getTopLeft()).times(a._containerSize.x/e.width),h=j.minus(k),i=h.divide(a._containerSize.x*g);return d.plus(i)},getZoom:function(a){return a?this._zoomSpring.getCurrent():this._zoomSpring.getTarget()},applyConstraints:function(i){var b=this,j=b.getZoom(),g=Math.max(Math.min(j,b._getMaxZoom()),b._getMinZoom());j!=g&&b.zoomTo(g,b.zoomPoint,i);var a=b.getBounds(),h=b.config.visibilityRatio,c=h*a.width,d=h*a.height,m=a.x+a.width,l=1-a.x,n=a.y+a.height,k=b._contentHeight-a.y,e=0;if(!b.config.wrapHorizontal)if(m<c)e=c-m;else if(l<c)e=l-c;var f=0;if(!b.config.wrapVertical)if(n<d)f=d-n;else if(k<d)f=k-d;if(e||f){a.x+=e;a.y+=f;b.fitBounds(a,i)}},ensureVisible:function(a){this.applyConstraints(a)},fitBounds:function(c,h){var d=true,a=this,f=a.getAspectRatio(),g=c.getCenter(),b=new Seadragon.Rect(c.x,c.y,c.width,c.height);if(b.getAspectRatio()>=f){b.height=c.width/f;b.y=g.y-b.height/2}else{b.width=c.height*f;b.x=g.x-b.width/2}a.panTo(a.getCenter(d),d);a.zoomTo(a.getZoom(d),null,d);var e=a.getBounds(),k=a.getZoom(),i=1/b.width;if(i==k||b.width==e.width){a.panTo(g,h);return}var j=e.getTopLeft().times(a._containerSize.x/e.width).minus(b.getTopLeft().times(a._containerSize.x/b.width)).divide(a._containerSize.x/e.width-a._containerSize.x/b.width);a.zoomTo(i,j,h)},goHome:function(c){var a=this,b=a.getCenter();if(a.config.wrapHorizontal){b.x=(1+b.x%1)%1;a._centerSpringX.resetTo(b.x);a._centerSpringX.update()}if(a.config.wrapVertical){b.y=(a._contentHeight+b.y%a._contentHeight)%a._contentHeight;a._centerSpringY.resetTo(b.y);a._centerSpringY.update()}a.fitBounds(a._homeBounds,c)},panBy:function(c,a){var b=new Seadragon.Point(this._centerSpringX.getTarget(),this._centerSpringY.getTarget());this.panTo(b.plus(c),a)},panTo:function(a,c){var b=this;if(c){b._centerSpringX.resetTo(a.x);b._centerSpringY.resetTo(a.y)}else{b._centerSpringX.springTo(a.x);b._centerSpringY.springTo(a.y)}},zoomBy:function(c,b,a){this.zoomTo(this._zoomSpring.getTarget()*c,b,a)},zoomTo:function(b,a,c){if(c)this._zoomSpring.resetTo(b);else this._zoomSpring.springTo(b);this.zoomPoint=a instanceof Seadragon.Point?a:null},resize:function(c,f){var a=this,d=a.getBounds(),b=d,e=c.x/a._containerSize.x;a._containerSize=new Seadragon.Point(c.x,c.y);if(f){b.width=d.width*e;b.height=b.width/a.getAspectRatio()}a.fitBounds(b,true)},update:function(){var a=this,g=a._centerSpringX.getCurrent(),h=a._centerSpringY.getCurrent(),c=a._zoomSpring.getCurrent();if(a.zoomPoint)var f=a.pixelFromPoint(a.zoomPoint,true);a._zoomSpring.update();if(a.zoomPoint&&a._zoomSpring.getCurrent()!=c){var e=a.pixelFromPoint(a.zoomPoint,true),d=e.minus(f),b=a.deltaPointsFromPixels(d,true);a._centerSpringX.shiftBy(b.x);a._centerSpringY.shiftBy(b.y)}else a.zoomPoint=null;a._centerSpringX.update();a._centerSpringY.update();return a._centerSpringX.getCurrent()!=g||a._centerSpringY.getCurrent()!=h||a._zoomSpring.getCurrent()!=c},deltaPixelsFromPoints:function(a,b){return a.times(this._containerSize.x*this.getZoom(b))},deltaPointsFromPixels:function(a,b){return a.divide(this._containerSize.x*this.getZoom(b))},pixelFromPoint:function(c,b){var a=this.getBounds(b);return c.minus(a.getTopLeft()).times(this._containerSize.x/a.width)},pointFromPixel:function(c,b){var a=this.getBounds(b);return c.divide(this._containerSize.x/a.width).plus(a.getTopLeft())}};