Files
SIG/Scripts/AjaxControlToolkit/Release/Seadragon.js
2024-11-05 10:47:20 -07:00

3 lines
73 KiB
JavaScript

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