Type.registerNamespace("Sys.Extended.UI.Seadragon");Sys.Extended.UI.Seadragon.Job=function(c,b){var a=this;a._image=null;a._timeout=null;a._src=c;a._callback=b;a.TIMEOUT=5e3};Sys.Extended.UI.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}};Sys.Extended.UI.Seadragon.Job.registerClass("Sys.Extended.UI.Seadragon.Job",null,Sys.IDisposable);Sys.Extended.UI.Seadragon.ImageLoader=function(a){this._downloading=0;this.imageLoaderLimit=a};Sys.Extended.UI.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 Sys.Extended.UI.Seadragon.Job(e,c);a._downloading++;d.start();return true}};Sys.Extended.UI.Seadragon.ImageLoader.registerClass("Sys.Extended.UI.Seadragon.ImageLoader",null,Sys.IDisposable);