(function(B){if(!B.fn.c1){B.fn.c1=function(D,C){if(this.c1[D]){return this.c1[D].call(this,C)}return this}}function A(C){if(C==0){return""}if(C<1024){return C+" bytes"}C=Math.floor(C/1024);return(C>700)?((C/1024).toFixed(1)+"MB"):(C+"KB")}B.fn.c1.upload=function(D){var E=this;D=B.extend({},B.fn.c1.upload.defaults,D);if(D.key==""){E.each(function(){var I=B(this).attr("class").match(/c1-upload-([a-z0-9]+)/i);if(I){D.key=I[1];return false}})}var C=E.parents("form");function G(I,J){if(!D.accept){return true}var K=false;var L=I.substr(I.lastIndexOf(".")+1);B.each(D.accept,function(M,O){for(var N=O.e.length-1;N>=0;N--){if(O.e[N]==L){K=true;return false}}});if(J){B.each(D.accept,function(M,O){for(var N=O.m.length-1;N>=0;N--){if(O.m[N]==J){K=true;return false}}})}return K}if(E.attr("multiple")){E.change(function(){var O=[];if(this.files){for(var L=0;L0){I=I.substr(I.lastIndexOf("/")+1)}O.push({name:I,size:0,valid:G(I)})}if(D._list==null){D._list=B(this).parent().append('
').find(".ui-links")}var N=0;D._list.html("");for(var L=0;L');var J=A(O[L].size);M.find(".border").text(O[L].name+(J?(" ("+J+")"):""));D._list.append(M);N+=O[L].size}if(D.max>0&&N>D.max){D._list.html('
  • Total size is too large ('+A(N)+").
    Maximum is "+A(D.max)+". Please choose smaller or fewer files.
  • ")}})}else{E.change(function(){var T=false;var R=false;var I=true;if(this.files){for(var K=0;K=0;U--){N+=this.files[U].size}}});T=L.length>1;if(D.max>0&&N>D.max){R=true}}else{var J=B(this).val();if(J){J=J.replace(/\\/g,"/");if(J.lastIndexOf("/")>0){J=J.substr(J.lastIndexOf("/")+1)}I=G(J)}}var P=B(this).parent();var O=P.find("label.error");var S="";if(!I){var M=[];B.each(D.accept,function(U,V){M.push(V.n+" (*."+V.e.join(", *.")+")")});M=M.sort();S="The file format is not allowed.";if(M.length>0){S+=" Acceptable formats are: ";for(var K=0,Q=M.length-1;K<=Q;K++){S+=(K>0&&K==Q?" and ":(K>0?", ":""))+M[K]}S+="."}S+=" Please choose another file."}else{if(R){S="The file is too large. Please reduce the file size and try again."}}if(S){if(O.length==0){B(this).after('');O=P.find("label.error")}O.text(S).show()}else{O.text("").hide()}});if(D.key){jQuery.each(E.parents("form"),function(){if(B('input[name="UPLOAD_IDENTIFIER"]',this).length>0){return }B(this).prepend('');B('input[name="UPLOAD_IDENTIFIER"]',this).val(D.key);if(D.target){B(this).attr("target",D.target)}B(this).submit(function(){var I=B('input[name="UPLOAD_IDENTIFIER"]',this).val();if(I){H(I,1)}})});if(D.target){var F=B('iframe[name="'+D.target+'"]');if(F.length==0){B("body").append('')}}function H(J,I){B.post("/api/json/system/upload/status",[{name:"key",value:J}],function(L){var K=L.total==0?"0":Math.round(L.current/L.total*100,0);if(L.total>0){if(D.change){D.change.call(E,K)}else{B(D.text).each(function(){B(this).text(D.format.replace("{$percentage}",K))})}if(L.current