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||{}))}}});