(function(){functionlog(){if(typeofconsole!="undefined"&&typeofconsole.log=="function"){Array.prototype.unshift.call(arguments,"[Ajax Upload]");console.log(Array.prototype.join.call(arguments," "))}}functionaddEvent(el,type,fn){if(el.addEventListener){el.addEventListener(type,fn,false)}elseif(el.attachEvent){el.attachEvent("on"+type,function(){fn.call(el)})}else{thrownewError("not supported or DOM not loaded")}}functionaddResizeEvent(fn){vartimeout;addEvent(window,"resize",function(){if(timeout){clearTimeout(timeout)}timeout=setTimeout(fn,100)})}if(document.documentElement.getBoundingClientRect){vargetOffset=function(el){varbox=el.getBoundingClientRect();vardoc=el.ownerDocument;varbody=doc.body;vardocElem=doc.documentElement;varclientTop=docElem.clientTop||body.clientTop||0;varclientLeft=docElem.clientLeft||body.clientLeft||0;varzoom=1;if(body.getBoundingClientRect){varbound=body.getBoundingClientRect();zoom=(bound.right-bound.left)/body.clientWidth}if(zoom>1){clientTop=0;clientLeft=0}vartop=box.top/zoom+(window.pageYOffset||docElem&&docElem.scrollTop/zoom||body.scrollTop/zoom)-clientTop,left=box.left/zoom+(window.pageXOffset||docElem&&docElem.scrollLeft/zoom||body.scrollLeft/zoom)-clientLeft;return{top:top,left:left}}}else{vargetOffset=function(el){vartop=0,left=0;do{top+=el.offsetTop||0;left+=el.offsetLeft||0;el=el.offsetParent}while(el);return{left:left,top:top}}}functiongetBox(el){varleft,right,top,bottom;varoffset=getOffset(el);left=offset.left;top=offset.top;right=left+el.offsetWidth;bottom=top+el.offsetHeight;return{left:left,right:right,top:top,bottom:bottom}}functionaddStyles(el,styles){for(varnameinstyles){if(styles.hasOwnProperty(name)){el.style[name]=styles[name]}}}functioncopyLayout(from,to){varbox=getBox(from);addStyles(to,{position:"absolute",left:box.left+"px",top:box.top+"px",width:from.offsetWidth+"px",height:from.offsetHeight+"px"});to.title=from.title}vartoElement=function(){vardiv=document.createElement("div");returnfunction(html){div.innerHTML=html;varel=div.firstChild;returndiv.removeChild(el)}}();vargetUID=function(){varid=0;returnfunction(){return"ValumsAjaxUpload"+id++}}();functionfileFromPath(file){returnfile.replace(/.*(\/|\\)/,"")}functiongetExt(file){return-1!==file.indexOf(".")?file.replace(/.*[.]/,""):""}functionhasClass(el,name){varre=newRegExp("\\b"+name+"\\b");returnre.test(el.className)}functionaddClass(el,name){if(!hasClass(el,name)){el.className+=" "+name}}functionremoveClass(el,name){varre=newRegExp("\\b"+name+"\\b");el.className=el.className.replace(re,"")}functionremoveNode(el){el.parentNode.removeChild(el)}window.AjaxUpload=function(button,options){this._settings={action:"upload.php",name:"userfile",data:{},autoSubmit:true,responseType:false,hoverClass:"hover",focusClass:"focus",disabledClass:"disabled",onChange:function(file,extension){},onSubmit:function(file,extension){},onComplete:function(file,response){}};for(variinoptions){if(options.hasOwnProperty(i)){this._settings[i]=options[i]}}if(button.jquery){button=button[0]}elseif(typeofbutton=="string"){if(/^#.*/.test(button)){button=button.slice(1)}button=document.getElementById(button)}if(!button||button.nodeType!==1){thrownewError("Please make sure that you're passing a valid element")}if(button.nodeName.toUpperCase()=="A"){addEvent(button,"click",function(e){if(e&&e.preventDefault){e.preventDefault()}elseif(window.event){window.event.returnValue=false}})}this._button=button;this._input=null;this._disabled=false;this.enable();this._rerouteClicks()};AjaxUpload.prototype={setData:function(data){this._settings.data=data},disable:function(){addClass(this._button,this._settings.disabledClass);this._disabled=true;varnodeName=this._button.nodeName.toUpperCase();if(nodeName=="INPUT"||nodeName=="BUTTON"){this._button.setAttribute("disabled","disabled")}if(this._input){this._input.parentNode.style.visibility="hidden"}},enable:function(){removeClass(this._button,this._settings.disabledClass);this._button.removeAttribute("disabled");this._disabled=false},_createInput:function(){v