var Uploader=new Class({Extends:Swiff.Uploader,options:{limitSize:false,multiple:false,queued:false,instantStart:false,validateFile:$lambda(true),debug:false,fileInvalid:null,fileUpload:null,fileComplete:null},initialize:function(a,b){this.status=$(a);this.files=[];if(b.callBacks){this.addEvents(b.callBacks);b.callBacks=null}this.parent(b);this.render()},render:function(){var a=new Element("span",{"class":"overall-progress"}).inject(this.status);var b=new Element("span",{"class":"progress-text"}).inject(a,"after");this.progressBar=new Fx.ProgressBar(a,{text:b})},onLoad:function(){this.log("Uploader ready!")},onBeforeOpen:function(b,a){this.log('Initialize upload for "{name}".',b);var c=this.options.fileUpload;var d=c?c.call(this,this.getFile(b),a):a;return d},onOpen:function(a,b){this.log('Starting upload "{name}".',a)},onProgress:function(a,c,b){this.progressBar.start(b.bytesLoaded,b.bytesTotal);this.log('Uploading "'+a.name+'" "'+b.bytesLoaded+'": "'+b.bytesTotal+'".')},onSelect:function(a){var c=[];if(this.options.limitSize&&(a.size>this.options.limitSize)){c.push("size")}if(!this.options.validateFile.call(this,a,c)){c.push("custom")}if(c.length){var b=this.options.fileInvalid;if(b){b.call(this,a,c)}return false}this.removeFile();this.files.push(a);return true},onAllSelect:function(b,c,a){this.log("Added "+b.length+" files, now we have ("+c.bytesTotal+" bytes).",arguments);if(this.files.length&&this.options.instantStart){this.upload.delay(10,this)}},onComplete:function(b,a){this.log('Completed upload "'+b.name+'".',arguments);this.progressBar.start(100);var c=this.options.fileComplete;if(c){c.call(this,this.finishFile(b),a)}},onAllComplete:function(a){this.log("Completed all files, "+a.bytesTotal+" bytes.",arguments);this.status.removeClass("file-uploading");this.progressBar.start(100)},onError:function(b,a,d){this.log('Upload "'+b.name+'" failed. "{1}": "{2}".',arguments);this.status.removeClass("file-uploading");this.progressBar.cancel();var c=this.options.fileError;if(c){c.call(this,this.finishFile(b),a,d)}this.removeFile()},onCancel:function(){this.log("Filebrowser cancelled.",arguments)},upload:function(b){var a=this.parent(b);if(a===true){this.log("Upload started.");this.status.addClass("file-uploading");this.progressBar.set(0);return true}else{if(a){this.log("An error occured: "+a)}else{this.log("Upload in progress or nothing to upload.")}}return false},removeFile:function(a){if(!a){this.files.empty()}else{if(!a.element){a=this.getFile(a)}this.files.erase(a)}this.parent(a)},getFile:function(b){var a=null;this.files.some(function(c){if((c.name!=b.name)||(c.size!=b.size)){return false}a=c;return true});return a},finishFile:function(a){a=this.getFile(a);a.finished=true;return a},log:function(b,a){if(this.options.debug&&window.console){console.log(b.substitute(a||{}))}}});