var FancyUpload2=new Class({Extends:Swiff.Uploader,options:{queued:1,limitSize:0,limitFiles:0,validateFile:$lambda(true)},initialize:function(A,C,B){this.status=$(A);this.list=$(C);if(!B.fileClass){B.fileClass=FancyUpload2.File}if(B.limitSize){B.fileSizeMax=B.limitSize}if(B.limitFiles){B.fileListMax=B.limitFiles}this.parent(B);this.addEvents({load:this.render,select:this.onSelect,cancel:this.onCancel,start:this.onStart,queue:this.onQueue,complete:this.onComplete})},render:function(){this.overallTitle=this.status.getElement(".overall-title");this.currentTitle=this.status.getElement(".current-title");this.currentText=this.status.getElement(".current-text");var A=this.status.getElement(".overall-progress");this.overallProgress=new Fx.ProgressBar(A,{text:new Element("span",{"class":"progress-text"}).inject(A,"after")});A=this.status.getElement(".current-progress");this.currentProgress=new Fx.ProgressBar(A,{text:new Element("span",{"class":"progress-text"}).inject(A,"after")});A.addEvent("click",function(){this.currentProgress.start($random(0,100))}.bind(this));this.updateOverall()},onSelect:function(){this.status.removeClass("status-browsing")},onCancel:function(){this.status.removeClass("file-browsing")},onStart:function(){this.status.addClass("file-uploading");this.overallProgress.set(0)},onQueue:function(){this.updateOverall()},onComplete:function(){this.status.removeClass("file-uploading");if(this.size){this.overallProgress.start(100);setTimeout("window.location='index.php?page=uploaded'",1250)}else{this.overallProgress.set(0);this.currentProgress.set(0)}},updateOverall:function(){this.overallTitle.set("html",MooTools.lang.get("FancyUpload","progressOverall").substitute({total:Swiff.Uploader.formatUnit(this.size,"b")}));if(!this.size){this.currentTitle.set("html",MooTools.lang.get("FancyUpload","currentTitle"));this.currentText.set("html","")}},upload:function(){this.start()},removeFile:function(){return this.remove()}});FancyUpload2.File=new Class({Extends:Swiff.Uploader.File,render:function(){if(this.invalid){if(this.validationError){var A=MooTools.lang.get("FancyUpload","validationErrors")[this.validationError]||this.validationError;this.validationErrorMessage=A.substitute(this)}this.remove();return }this.addEvents({start:this.onStart,progress:this.onProgress,complete:this.onComplete,error:this.onError,remove:this.onRemove});this.info=new Element("span",{"class":"file-info"});this.element=new Element("li",{"class":"file"}).adopt(new Element("span",{"class":"file-size",html:Swiff.Uploader.formatUnit(this.size,"b")}),new Element("a",{"class":"file-remove",href:"#",html:MooTools.lang.get("FancyUpload","remove"),title:MooTools.lang.get("FancyUpload","removeTitle"),events:{click:function(){this.remove();return false}.bind(this)}}),new Element("span",{"class":"file-name",html:MooTools.lang.get("FancyUpload","fileName").substitute(this)}),this.info).inject(this.base.list)},validate:function(){return(this.parent()&&this.base.options.validateFile(this))},onStart:function(){this.element.addClass("file-uploading");this.base.currentProgress.cancel().set(0);this.base.currentTitle.set("html",MooTools.lang.get("FancyUpload","currentFile").substitute(this))},onProgress:function(){this.base.overallProgress.start(this.base.percentLoaded);this.base.currentText.set("html",MooTools.lang.get("FancyUpload","currentProgress").substitute({rate:(this.progress.rate)?Swiff.Uploader.formatUnit(this.progress.rate,"bps"):"- B",bytesLoaded:Swiff.Uploader.formatUnit(this.progress.bytesLoaded,"b"),timeRemaining:(this.progress.timeRemaining)?Swiff.Uploader.formatUnit(this.progress.timeRemaining,"s"):"-"}));this.base.currentProgress.start(this.progress.percentLoaded)},onComplete:function(){this.element.removeClass("file-uploading");this.base.currentText.set("html","Upload completed");this.base.currentProgress.start(100);if(this.response.error){this.fireEvent("error");return }var A=this.response.text||"";this.base.fireEvent("onFileSuccess",[this,A])},onError:function(){this.element.addClass("file-failed");var A=MooTools.lang.get("FancyUpload","fileError").substitute(this);var B=MooTools.lang.get("FancyUpload","errors")[this.response.error]||(this.response.error+" #"+this.response.code);B=B.substitute(this).substitute(this.response);this.info.set("html","<strong>"+A+":</strong> "+B)},onRemove:function(){this.element.fade("out").retrieve("tween").chain(Element.destroy.bind(Element,this.element))}});(function(){var A={progressOverall:"Overall Progress ({total})",currentTitle:"File Progress",currentFile:'Uploading "{name}"',currentProgress:"Upload: {bytesLoaded} with {rate}, {timeRemaining} remaining.",fileName:"{name}",remove:"Remove",removeTitle:"Click to remove this entry.",fileError:"File was not uploaded",validationErrors:{duplicate:"File <em>{name}</em> is already added, duplicates are not allowed.",sizeLimitMin:"File <em>{name}</em> is too small, please check the minimal file size.",sizeLimitMax:"File <em>{name}</em> is too big, please check the maximal file size.",fileListMax:"File <em>{name}</em> could not be added, amount of files exceeded limit.",fileListSizeMax:"File <em>{name}</em> is too big, overall filesize exceeded limit."},errors:{httpError:"Server returned HTTP-Status #{code}",securityError:"Security error occured ({text})",ioError:"Error caused a send or load operation to fail ({text})"}};if(MooTools.lang){MooTools.lang.set("en-US","FancyUpload",A)}else{MooTools.lang={get:function(C,B){return A[B]}}}})();


