if(window.jQuery){(function(A){A.extend(A,{MultiFile:function(B){return A("input:file.multi").MultiFile(B)}});A.extend(A.MultiFile,{options:{accept:"",max:-1,error:function(B){if(A.blockUI){A.blockUI({message:'<div class="error-box"><p><img src="/images/mascot-error.jpg" width="85" height="113" alt="" /></p><p>'+B.replace(/\n/gi,"<br/>")+'</p><p><input type="button" value="Ok" class="error-ok-button" /></p></div>',css:{border:"none",background:"none",color:"#000000",cursor:"help"},overlayCSS:{backgroundColor:"#ffffff",opacity:"0.8",cursor:"help"}});A(".error-ok-button").click(function(){A.unblockUI()})}else{alert(B)}},namePattern:"$name",STRING:{remove:"",denied:"You cannot select a $ext file.",selected:"File selected: $file",duplicate:"This file has already been selected: $file"}}});A.extend(A.MultiFile,{disableEmpty:function(B){var C=[];A("input:file").each(function(){if(A(this).val()==""){C[C.length]=this}});return A(C).each(function(){this.disabled=true}).addClass(B||"mfD")},reEnableEmpty:function(B){B=B||"mfD";return A("input:file."+B).removeClass(B).each(function(){this.disabled=false})},autoIntercept:["submit","ajaxSubmit","validate"],intercepted:{},intercept:function(B,E,C){var G,F;C=C||[];if(C.constructor.toString().indexOf("Array")<0){C=[C]}if(typeof (B)=="function"){A.MultiFile.disableEmpty();F=B.apply(E||window,C);A.MultiFile.reEnableEmpty();return F}if(B.constructor.toString().indexOf("Array")<0){B=[B]}for(var D=0;D<B.length;D++){G=B[D]+"";if(G){(function(H){A.MultiFile.intercepted[H]=A.fn[H]||function(){};A.fn[H]=function(){A.MultiFile.disableEmpty();F=A.MultiFile.intercepted[H].apply(this,arguments);A.MultiFile.reEnableEmpty();return F}})(G)}}}});A.extend(A.fn,{reset:function(){return this.each(function(){try{this.reset()}catch(B){}})},MultiFile:function(B){if(A.MultiFile.autoIntercept){A.MultiFile.intercept(A.MultiFile.autoIntercept);A.MultiFile.autoIntercept=null}return A(this).each(function(D){if(this._MultiFile){return }this._MultiFile=true;window.MultiFile=(window.MultiFile||0)+1;D=window.MultiFile;var C={e:this,E:A(this),clone:A(this).clone()};if(typeof B=="number"){B={max:B}}if(typeof B=="string"){B={accept:B}}var E=A.extend({},A.MultiFile.options,B||{},(A.meta?C.E.data():(A.metadata?C.E.metadata():null))||{});if(!(E.max>0)){E.max=C.E.attr("maxlength");if(!(E.max>0)){E.max=(String(C.e.className.match(/\b(max|limit)\-([0-9]+)\b/gi)||[""]).match(/[0-9]+/gi)||[""])[0];if(!(E.max>0)){E.max=-1}else{E.max=String(E.max).match(/[0-9]+/gi)[0]}}}E.max=new Number(E.max);E.accept=E.accept||C.E.attr("accept")||"";if(!E.accept){E.accept=(C.e.className.match(/\b(accept\-[\w\|]+)\b/gi))||"";E.accept=new String(E.accept).replace(/^(accept|ext)\-/i,"")}A.extend(C,E||{});C.STRING=A.extend({},A.MultiFile.options.STRING,C.STRING);A.extend(C,{n:0,slaves:[],files:[],instanceKey:C.e.id||"MultiFile"+String(D),generateID:function(F){return C.instanceKey+(F>0?"_F"+String(F):"")},trigger:function(I,F){var H=C[I],J=A(F).attr("value");if(H){var G=H(F,J,C);if(G!=null){return G}}return true}});if(String(C.accept).length>1){C.rxAccept=new RegExp("\\.("+(C.accept?C.accept:"")+")$","gi")}C.wrapID=C.instanceKey+"_wrap";C.E.wrap('<div id="'+C.wrapID+'"></div>');C.wrapper=A("#"+C.wrapID+"");C.e.name=C.e.name||"file"+D+"[]";C.wrapper.append('<span id="'+C.wrapID+'_labels"></span>');C.labels=A("#"+C.wrapID+"_labels");C.addSlave=function(F,G){C.n++;F.MF=C;F.i=G;if(F.i>0){F.id=F.name=null}F.id=F.id||C.generateID(F.i);F.name=String(C.namePattern.replace(/\$name/gi,C.E.attr("name")).replace(/\$id/gi,C.E.attr("id")).replace(/\$g/gi,(D>0?D:"")).replace(/\$i/gi,(G>0?G:"")));A(F).val("").attr("value","")[0].value="";if((C.max>0)&&((C.n-1)>(C.max))){F.disabled=true}C.current=C.slaves[F.i]=F;F=A(F);A(F).change(function(){A(this).blur();if(!C.trigger("onFileSelect",this,C)){return false}var J="",I=String(this.value||"");if(C.accept&&I&&!I.match(C.rxAccept)){J=C.STRING.denied.replace("$ext",String(I.match(/\.\w{1,4}$/gi)))}for(var K in C.slaves){if(C.slaves[K]&&C.slaves[K]!=this){if(C.slaves[K].value==I){J=C.STRING.duplicate.replace("$file",I.match(/[^\/\\]+$/gi))}}}var H=A(C.clone).clone();H.addClass("MultiFile");if(J!=""){C.error(J);C.n--;C.addSlave(H[0],this.i);F.parent().prepend(H);F.remove();return false}A(this).css({position:"absolute",top:"-3000px"});C.labels.before(H);C.addToList(this);C.addSlave(H[0],this.i+1);if(!C.trigger("afterFileSelect",this,C)){return false}})};C.addToList=function(I){if(!C.trigger("onFileAppend",I,C)){return false}var J=A("<div></div>"),H=String(I.value||""),G=A('<span class="file" title="'+C.STRING.selected.replace("$file",H)+'">'+H.match(/[^\/\\]+$/gi)[0]+"</span>"),F=A('<a href="#'+C.wrapID+'" title="remove file" class="remove-image">'+C.STRING.remove+"</a>");C.labels.append(J.append('<div style="margin: 2px 0px 3px 0px;">',F,"&nbsp;",G,"</div>"));F.click(function(){if(!C.trigger("onFileRemove",I,C)){return false}C.n--;C.current.disabled=false;C.slaves[I.i]=null;A(I).remove();A(this).parent().remove();A(C.current).css({position:"",top:""});A(C.current).reset().val("").attr("value","")[0].value="";if(!C.trigger("afterFileRemove",I,C)){return false}return false});if(!C.trigger("afterFileAppend",I,C)){return false}};if(!C.MF){C.addSlave(C.e,0)}C.n++})}});A(function(){A.MultiFile()})})(jQuery)};