//4afc10896172f193fcae43253333193e
var FancyUpload2=new Class({Extends:Swiff.Uploader,options:{limitSize:false,limitFiles:5,instantStart:false,allowDuplicates:false,validateFile:$lambda(true),debug:false,fileInvalid:null,fileCreate:null,fileUpload:null,fileComplete:null,fileRemove:null},initialize:function(A,C,B){this.status=$(A);this.list=$(C);this.files=[];if(B.callBacks){this.addEvents(B.callBacks);B.callBacks=null}this.parent(B);this.render()},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")})},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);A=this.getFile(A);A.element.addClass("file-uploading");this.currentProgress.cancel().set(0);this.currentTitle.set("html",'File Progress "{name}"'.substitute(A))},onProgress:function(A,C,B){this.overallProgress.start(B.bytesLoaded,B.bytesTotal);this.currentText.set("html","Upload with {rate}/s. Time left: ~{timeLeft}".substitute({rate:(C.rate)?this.sizeToKB(C.rate):"- B",timeLeft:Date.fancyDuration(C.timeLeft||0)}));this.currentProgress.start(C.bytesLoaded,C.bytesTotal)},onSelect:function(B,A,D){var E=[];if(this.options.limitSize&&(B.size>this.options.limitSize)){E.push("size")}if(this.options.limitFiles&&(this.countFiles()>=this.options.limitFiles)){E.push("length")}if(!this.options.allowDuplicates&&this.getFile(B)){E.push("duplicate")}if(!this.options.validateFile.call(this,B,E)){E.push("custom")}if(E.length){var C=this.options.fileInvalid;if(C){C.call(this,B,E)}return false}(this.options.fileCreate||this.fileCreate).call(this,B);this.files.push(B);return true},onAllSelect:function(B,C,A){this.log("Added "+B.length+" files, now we have ("+C.bytesTotal+" bytes).",arguments);this.updateOverall(C.bytesTotal);this.status.removeClass("status-browsing");if(this.files.length&&this.options.instantStart){this.upload.delay(10,this)}},onComplete:function(B,A){this.log('Completed upload "'+B.name+'".',arguments);this.currentText.set("html","Upload complete!");this.currentProgress.start(100);(this.options.fileComplete||this.fileComplete).call(this,this.finishFile(B),A)},onError:function(B,A,C){this.log('Upload "'+B.name+'" failed. "{1}": "{2}".',arguments);(this.options.fileError||this.fileError).call(this,this.finishFile(B),A,C)},onCancel:function(){this.log("Filebrowser cancelled.",arguments);this.status.removeClass("file-browsing")},onAllComplete:function(A){this.log("Completed all files, "+A.bytesTotal+" bytes.",arguments);this.updateOverall(A.bytesTotal);this.overallProgress.start(100);this.status.removeClass("file-uploading")},browse:function(B){var A=this.parent(B);if(A!==true){if(A){this.log("An error occured: "+A)}else{this.log("Browse in progress.")}}else{this.log("Browse started.");this.status.addClass("file-browsing")}},upload:function(B){var A=this.parent(B);if(A!==true){this.log("Upload in progress or nothing to upload.");if(A){alert(A)}}else{this.log("Upload started.");this.status.addClass("file-uploading");this.overallProgress.set(0)}},removeFile:function(B){var A=this.options.fileRemove||this.fileRemove;if(!B){this.files.each(A,this);this.files.empty();this.updateOverall(0)}else{if(!B.element){B=this.getFile(B)}this.files.erase(B);A.call(this,B);this.updateOverall(this.bytesTotal-B.size)}this.parent(B)},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},countFiles:function(){var B=0;for(var C=0,A=this.files.length;C<A;C++){if(!this.files[C].finished){B++}}return B},updateOverall:function(A){this.bytesTotal=A;this.overallTitle.set("html","Progress ("+this.sizeToKB(A)+")")},finishFile:function(A){A=this.getFile(A);A.element.removeClass("file-uploading");A.finished=true;return A},fileCreate:function(A){if($("list-holder")!=null){$("list-holder").dispose()}A.info=new Element("span",{"class":"file-info"});A.element=new Element("li",{id:"list-holder","class":"file"}).adopt(new Element("span",{id:"filename-span","class":"file-name",html:A.name})).inject(this.list)},fileComplete:function(C,A){this.options.processResponse||this;var B=$H(JSON.decode(A,true));if(B.get("result")=="success"){C.element.addClass("file-success");C.info.set("html",B.get("size"))}else{C.element.addClass("file-failed");C.info.set("html",B.get("error")||A)}},fileError:function(B,A,C){B.element.addClass("file-failed");B.info.set("html","<strong>"+A+"</strong><br />"+C)},fileRemove:function(A){A.element.fade("out").retrieve("tween").chain(Element.destroy.bind(Element,A.element))},sizeToKB:function(A){var B="B";if((A/1048576)>1){B="MB";A/=1048576}else{if((A/1024)>1){B="kB";A/=1024}}return A.round(1)+" "+B},log:function(B,A){if(this.options.debug&&window.console){console.log(B.substitute(A||{}))}},setUrl:function(A){this.parent.options.url=this.options.url=A}});Date.parseDuration=function(B){var A={},E=Date.durations;for(var C in E){var D=Math.floor(B/E[C]);if(D){A[C]=D;if(!(B-=D*E[C])){break}}}return A};Date.fancyDuration=function(C){var B=[],A=Date.parseDuration(C);for(var D in A){B.push(A[D]+Date.durationsAbbr[D])}return B.join(", ")};Date.durations={years:31556926,months:2629743.83,days:86400,hours:3600,minutes:60,seconds:1,milliseconds:0.001};Date.durationsAbbr={years:"j",months:"m",days:"d",hours:"h",minutes:"min",seconds:"sec",milliseconds:"ms"};