(function(f){function j(b){c.drop(b);e=b.dataTransfer.files;if(null===e||void 0===e)return c.error(g[0]),!1;k=e.length;n();b.preventDefault();return!1}function o(b,d,e){var a="";f.each(c.data,function(b,c){"function"===typeof c&&(c=c());a+="--";a+=e;a+="\r\n";a+='Content-Disposition: form-data; name="'+b+'"';a+="\r\n";a+="\r\n";a+=c;a+="\r\n"});a+="--";a+=e;a+="\r\n";a+='Content-Disposition: form-data; name="'+c.paramname+'"';a+='; filename="'+b+'"';a+="\r\n";a+="Content-Type: application/octet-stream"; a+="\r\n";a+="\r\n";a+=d;a+="\r\n";a+="--";a+=e;a+="--";return a+="\r\n"}function p(b){if(b.lengthComputable){var d=Math.round(100*b.loaded/b.total);if(this.currentProgress!=d){this.currentProgress=d;c.progressUpdated(this.index,this.file,this.currentProgress);var d=(new Date).getTime(),e=d-this.currentStart;e>=c.refresh&&(c.speedUpdated(this.index,this.file,(b.loaded-this.startData)/e),this.startData=b.loaded,this.currentStart=d)}}}function n(){function b(a){if(void 0==a.target.index){var b=a.target, h;a:{for(h=0;h<k;h++)if(e[h].size==a.total)break a;h=void 0}b.index=h}var f=new XMLHttpRequest,b=f.upload,g=e[a.target.index],j=a.target.index,l=(new Date).getTime();h="------multipartformboundary"+(new Date).getTime();newName=c.rename(g.name);a="string"===typeof newName?o(newName,a.target.result,h):o(g.name,a.target.result,h);b.index=j;b.file=g;b.downloadStartTime=l;b.currentStart=l;b.currentProgress=0;b.startData=0;b.addEventListener("progress",p,!1);f.open("POST",c.url,!0);f.setRequestHeader("content-type", "multipart/form-data; boundary="+h);f.sendAsBinary(a);c.uploadStarted(j,g,k);f.onload=function(){if(f.responseText){var a=(new Date).getTime()-l,a=c.uploadFinished(j,g,jQuery.parseJSON(f.responseText),a);d++;d==k-i&&c.afterAll();!1===a&&(m=!0)}}}m=!1;if(!e)return c.error(g[0]),!1;var d=0,i=0;if(k>c.maxfiles)return c.error(g[1]),!1;for(var a=0;a<k;a++){if(m)return!1;try{if(!1!=c.beforeEach(e[a])){if(a===k)break;var f=new FileReader,j=1048576*c.maxfilesize;f.index=a;e[a].size>j?(c.error(g[2],e[a],a), i++):(f.onloadend=b,f.readAsBinaryString(e[a]))}else i++}catch(n){return c.error(g[0]),!1}}}function q(b){clearTimeout(i);b.preventDefault();c.dragEnter(b)}function r(b){clearTimeout(i);b.preventDefault();c.docOver(b);c.dragOver(b)}function s(b){clearTimeout(i);c.dragLeave(b);b.stopPropagation()}function t(b){b.preventDefault();c.docLeave(b);return!1}function u(b){clearTimeout(i);b.preventDefault();c.docEnter(b);return!1}function v(b){clearTimeout(i);b.preventDefault();c.docOver(b);return!1}function w(b){i= setTimeout(function(){c.docLeave(b)},200)}function d(){}jQuery.event.props.push("dataTransfer");var c={},x={url:"",refresh:1E3,paramname:"userfile",maxfiles:25,maxfilesize:1,data:{},drop:d,dragEnter:d,dragOver:d,dragLeave:d,docEnter:d,docOver:d,docLeave:d,beforeEach:d,afterAll:d,rename:d,error:function(b){alert(b)},uploadStarted:d,uploadFinished:d,progressUpdated:d,speedUpdated:d},g=["BrowserNotSupported","TooManyFiles","FileTooLarge"],i,m=!1,k=0,e;f.fn.filedrop=function(b){c=f.extend({},x,b);this.bind("drop", j).bind("dragenter",q).bind("dragover",r).bind("dragleave",s);f(document).bind("drop",t).bind("dragenter",u).bind("dragover",v).bind("dragleave",w)};try{XMLHttpRequest.prototype.sendAsBinary||(XMLHttpRequest.prototype.sendAsBinary=function(b){b=Array.prototype.map.call(b,function(b){return b.charCodeAt(0)&255});b=new Uint8Array(b);this.send(b.buffer)})}catch(y){}})(jQuery);