!function(){var moduleFactory=function($){var module=this,jQuery=$,exports=function(){!function(){function preventDefault(){this.returnValue=!1}function stopPropagation(){this.cancelBubble=!0}var undef,uid,count=0,runtimes=[],i18n={},mimes={},xmlEncodeChars={"<":"lt",">":"gt","&":"amp",'"':"quot","'":"#39"},xmlEncodeRegExp=/[<>&\"\']/g,delay=window.setTimeout,eventhash={};!function(mime_data){var i,y,ext,items=mime_data.split(/,/);for(i=0;i<items.length;i+=2)for(ext=items[i+1].split(/ /),y=0;y<ext.length;y++)mimes[ext[y]]=items[i]
}("application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb,application/vnd.ms-powerpoint,ppt pps pot,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx,application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx,application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx,application/vnd.openxmlformats-officedocument.presentationml.template,potx,application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx,application/x-javascript,js,application/json,json,audio/mpeg,mpga mpega mp2 mp3,audio/x-wav,wav,audio/mp4,m4a,image/bmp,bmp,image/gif,gif,image/jpeg,jpeg jpg jpe,image/photoshop,psd,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/plain,asc txt text diff log,text/html,htm html xhtml,text/css,css,text/csv,csv,text/rtf,rtf,video/mpeg,mpeg mpg mpe,video/quicktime,qt mov,video/mp4,mp4,video/x-m4v,m4v,video/x-flv,flv,video/x-ms-wmv,wmv,video/avi,avi,video/webm,webm,video/vnd.rn-realvideo,rv,application/vnd.oasis.opendocument.formula-template,otf,application/octet-stream,exe");
var plupload={VERSION:"1.5.2",STOPPED:1,STARTED:2,QUEUED:1,UPLOADING:2,FAILED:4,DONE:5,GENERIC_ERROR:-100,HTTP_ERROR:-200,IO_ERROR:-300,SECURITY_ERROR:-400,INIT_ERROR:-500,FILE_SIZE_ERROR:-600,FILE_EXTENSION_ERROR:-601,IMAGE_FORMAT_ERROR:-700,IMAGE_MEMORY_ERROR:-701,IMAGE_DIMENSIONS_ERROR:-702,mimeTypes:mimes,ua:function(){var webkit,opera,safari,nav=navigator,userAgent=nav.userAgent,vendor=nav.vendor;return webkit=/WebKit/.test(userAgent),safari=webkit&&-1!==vendor.indexOf("Apple"),opera=window.opera&&window.opera.buildNumber,{windows:-1!==navigator.platform.indexOf("Win"),ie:!webkit&&!opera&&/MSIE/gi.test(userAgent)&&/Explorer/gi.test(nav.appName),webkit:webkit,gecko:!webkit&&/Gecko/.test(userAgent),safari:safari,opera:!!opera}
}(),typeOf:function(o){return{}.toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()},extend:function(target){return plupload.each(arguments,function(arg,i){i>0&&plupload.each(arg,function(value,key){target[key]=value})}),target},cleanName:function(name){var i,lookup;for(lookup=[/[\300-\306]/g,"A",/[\340-\346]/g,"a",/\307/g,"C",/\347/g,"c",/[\310-\313]/g,"E",/[\350-\353]/g,"e",/[\314-\317]/g,"I",/[\354-\357]/g,"i",/\321/g,"N",/\361/g,"n",/[\322-\330]/g,"O",/[\362-\370]/g,"o",/[\331-\334]/g,"U",/[\371-\374]/g,"u"],i=0;i<lookup.length;i+=2)name=name.replace(lookup[i],lookup[i+1]);
return name=name.replace(/\s+/g,"_"),name=name.replace(/[^a-z0-9_\-\.]+/gi,"")},addRuntime:function(name,runtime){return runtime.name=name,runtimes[name]=runtime,runtimes.push(runtime),runtime},guid:function(){var i,guid=(new Date).getTime().toString(32);for(i=0;5>i;i++)guid+=Math.floor(65535*Math.random()).toString(32);return(plupload.guidPrefix||"p")+guid+(count++).toString(32)},buildUrl:function(url,items){var query="";return plupload.each(items,function(value,name){query+=(query?"&":"")+encodeURIComponent(name)+"="+encodeURIComponent(value)
}),query&&(url+=(url.indexOf("?")>0?"&":"?")+query),url},each:function(obj,callback){var length,key,i;if(obj)if(length=obj.length,length===undef){for(key in obj)if(obj.hasOwnProperty(key)&&callback(obj[key],key)===!1)return}else for(i=0;length>i;i++)if(callback(obj[i],i)===!1)return},formatSize:function(size){return size===undef||/\D/.test(size)?plupload.translate("N/A"):size>1073741824?Math.round(size/1073741824,1)+" GB":size>1048576?Math.round(size/1048576,1)+" MB":size>1024?Math.round(size/1024,1)+" KB":size+" b"
},getPos:function(node,root){function getIEPos(node){var bodyElm,rect,x=0,y=0;return node&&(rect=node.getBoundingClientRect(),bodyElm="CSS1Compat"===doc.compatMode?doc.documentElement:doc.body,x=rect.left+bodyElm.scrollLeft,y=rect.top+bodyElm.scrollTop),{x:x,y:y}}var parent,nodeRect,rootRect,x=0,y=0,doc=document;if(node=node,root=root||doc.body,node&&node.getBoundingClientRect&&navigator.userAgent.indexOf("MSIE")>0&&doc.documentMode<8)return nodeRect=getIEPos(node),rootRect=getIEPos(root),{x:nodeRect.x-rootRect.x,y:nodeRect.y-rootRect.y};
for(parent=node;parent&&parent!=root&&parent.nodeType;)x+=parent.offsetLeft||0,y+=parent.offsetTop||0,parent=parent.offsetParent;for(parent=node.parentNode;parent&&parent!=root&&parent.nodeType;)x-=parent.scrollLeft||0,y-=parent.scrollTop||0,parent=parent.parentNode;return{x:x,y:y}},getSize:function(node){return{w:node.offsetWidth||node.clientWidth,h:node.offsetHeight||node.clientHeight}},parseSize:function(size){var mul;return"string"==typeof size&&(size=/^([0-9]+)([mgk]?)$/.exec(size.toLowerCase().replace(/[^0-9mkg]/g,"")),mul=size[2],size=+size[1],"g"==mul&&(size*=1073741824),"m"==mul&&(size*=1048576),"k"==mul&&(size*=1024)),size
},xmlEncode:function(str){return str?(""+str).replace(xmlEncodeRegExp,function(chr){return xmlEncodeChars[chr]?"&"+xmlEncodeChars[chr]+";":chr}):str},toArray:function(obj){var i,arr=[];for(i=0;i<obj.length;i++)arr[i]=obj[i];return arr},inArray:function(needle,array){if(array){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(array,needle);for(var i=0,length=array.length;length>i;i++)if(array[i]===needle)return i}return-1},addI18n:function(pack){return plupload.extend(i18n,pack)},translate:function(str){return i18n[str]||str
},isEmptyObj:function(obj){if(obj===undef)return!0;for(var prop in obj)return!1;return!0},hasClass:function(obj,name){var regExp;return""==obj.className?!1:(regExp=new RegExp("(^|\\s+)"+name+"(\\s+|$)"),regExp.test(obj.className))},addClass:function(obj,name){plupload.hasClass(obj,name)||(obj.className=""==obj.className?name:obj.className.replace(/\s+$/,"")+" "+name)},removeClass:function(obj,name){var regExp=new RegExp("(^|\\s+)"+name+"(\\s+|$)");obj.className=obj.className.replace(regExp,function($0,$1,$2){return" "===$1&&" "===$2?" ":""
})},getStyle:function(obj,name){return obj.currentStyle?obj.currentStyle[name]:window.getComputedStyle?window.getComputedStyle(obj,null)[name]:void 0},addEvent:function(obj,name,callback){var func,events,key;key=arguments[3],name=name.toLowerCase(),uid===undef&&(uid="Plupload_"+plupload.guid()),obj.addEventListener?(func=callback,obj.addEventListener(name,func,!1)):obj.attachEvent&&(func=function(){var evt=window.event;evt.target||(evt.target=evt.srcElement),evt.preventDefault=preventDefault,evt.stopPropagation=stopPropagation,callback(evt)
},obj.attachEvent("on"+name,func)),obj[uid]===undef&&(obj[uid]=plupload.guid()),eventhash.hasOwnProperty(obj[uid])||(eventhash[obj[uid]]={}),events=eventhash[obj[uid]],events.hasOwnProperty(name)||(events[name]=[]),events[name].push({func:func,orig:callback,key:key})},removeEvent:function(obj,name){var type,callback,key;if("function"==typeof arguments[2]?callback=arguments[2]:key=arguments[2],name=name.toLowerCase(),obj[uid]&&eventhash[obj[uid]]&&eventhash[obj[uid]][name]){type=eventhash[obj[uid]][name];for(var i=type.length-1;i>=0&&(type[i].key!==key&&type[i].orig!==callback||(obj.removeEventListener?obj.removeEventListener(name,type[i].func,!1):obj.detachEvent&&obj.detachEvent("on"+name,type[i].func),type[i].orig=null,type[i].func=null,type.splice(i,1),callback===undef));i--);if(type.length||delete eventhash[obj[uid]][name],plupload.isEmptyObj(eventhash[obj[uid]])){delete eventhash[obj[uid]];
try{delete obj[uid]}catch(e){obj[uid]=undef}}}},removeAllEvents:function(obj){var key=arguments[1];obj[uid]!==undef&&obj[uid]&&plupload.each(eventhash[obj[uid]],function(events,name){plupload.removeEvent(obj,name,key)})}};plupload.Uploader=function(settings){function uploadNext(){var file,i,count=0;if(this.state==plupload.STARTED){for(i=0;i<files.length;i++)file||files[i].status!=plupload.QUEUED?count++:(file=files[i],file.status=plupload.UPLOADING,this.trigger("BeforeUpload",file)&&this.trigger("UploadFile",file));
count==files.length&&(this.stop(),this.trigger("UploadComplete",files))}}function calc(){var i,file;for(total.reset(),i=0;i<files.length;i++)file=files[i],file.size!==undef?(total.size+=file.size,total.loaded+=file.loaded):total.size=undef,file.status==plupload.DONE?total.uploaded++:file.status==plupload.FAILED?total.failed++:total.queued++;total.size===undef?total.percent=files.length>0?Math.ceil(100*(total.uploaded/files.length)):0:(total.bytesPerSec=Math.ceil(total.loaded/((+new Date-startTime||1)/1e3)),total.percent=total.size>0?Math.ceil(100*(total.loaded/total.size)):0)
}var total,startTime,events={},files=[],disabled=!1;total=new plupload.QueueProgress,settings=plupload.extend({chunk_size:0,multipart:!0,multi_selection:!0,file_data_name:"file",filters:[]},settings),plupload.extend(this,{state:plupload.STOPPED,runtime:"",features:{},files:files,settings:settings,total:total,id:plupload.guid(),init:function(){function callNextInit(){var features,requiredFeatures,i,runtime=runtimeList[runTimeIndex++];if(runtime){if(features=runtime.getFeatures(),requiredFeatures=self.settings.required_features)for(requiredFeatures=requiredFeatures.split(","),i=0;i<requiredFeatures.length;i++)if(!features[requiredFeatures[i]])return callNextInit(),void 0;
runtime.init(self,function(res){res&&res.success?(self.features=features,self.runtime=runtime.name,self.trigger("Init",{runtime:runtime.name}),self.trigger("PostInit"),self.refresh()):callNextInit()})}else self.trigger("Error",{code:plupload.INIT_ERROR,message:plupload.translate("Init error.")})}var i,runtimeList,items,self=this,runTimeIndex=0;if("function"==typeof settings.preinit?settings.preinit(self):plupload.each(settings.preinit,function(func,name){self.bind(name,func)}),settings.page_url=settings.page_url||document.location.pathname.replace(/\/[^\/]+$/g,"/"),/^(\w+:\/\/|\/)/.test(settings.url)||(settings.url=settings.page_url+settings.url),settings.chunk_size=plupload.parseSize(settings.chunk_size),settings.max_file_size=plupload.parseSize(settings.max_file_size),self.bind("FilesAdded",function(up,selected_files){var i,file,extensionsRegExp,count=0,filters=settings.filters;
for(filters&&filters.length&&(extensionsRegExp=[],plupload.each(filters,function(filter){plupload.each(filter.extensions.split(/,/),function(ext){/^\s*\*\s*$/.test(ext)?extensionsRegExp.push("\\.*"):extensionsRegExp.push("\\."+ext.replace(new RegExp("["+"/^$.*+?|()[]{}\\".replace(/./g,"\\$&")+"]","g"),"\\$&"))})}),extensionsRegExp=new RegExp(extensionsRegExp.join("|")+"$","i")),i=0;i<selected_files.length;i++)file=selected_files[i],file.loaded=0,file.percent=0,file.status=plupload.QUEUED,!extensionsRegExp||extensionsRegExp.test(file.name)?file.size!==undef&&file.size>settings.max_file_size?up.trigger("Error",{code:plupload.FILE_SIZE_ERROR,message:plupload.translate("File size error."),file:file}):(files.push(file),count++):up.trigger("Error",{code:plupload.FILE_EXTENSION_ERROR,message:plupload.translate("File extension error."),file:file});
return count?(delay(function(){self.trigger("QueueChanged"),self.refresh()},1),void 0):!1}),settings.unique_names&&self.bind("UploadFile",function(up,file){var matches=file.name.match(/\.([^.]+)$/),ext="tmp";matches&&(ext=matches[1]),file.target_name=file.id+"."+ext}),self.bind("UploadProgress",function(up,file){file.percent=file.size>0?Math.ceil(100*(file.loaded/file.size)):100,calc()}),self.bind("StateChanged",function(up){if(up.state==plupload.STARTED)startTime=+new Date;else if(up.state==plupload.STOPPED)for(i=up.files.length-1;i>=0;i--)up.files[i].status==plupload.UPLOADING&&(up.files[i].status=plupload.QUEUED,calc())
}),self.bind("QueueChanged",calc),self.bind("Error",function(up,err){err.file&&(err.file.status=plupload.FAILED,calc(),up.state==plupload.STARTED&&delay(function(){uploadNext.call(self)},1))}),self.bind("FileUploaded",function(up,file){file.status=plupload.DONE,file.loaded=file.size,up.trigger("UploadProgress",file),delay(function(){uploadNext.call(self)},1)}),settings.runtimes)for(runtimeList=[],items=settings.runtimes.split(/\s?,\s?/),i=0;i<items.length;i++)runtimes[items[i]]&&runtimeList.push(runtimes[items[i]]);
else runtimeList=runtimes;callNextInit(),"function"==typeof settings.init?settings.init(self):plupload.each(settings.init,function(func,name){self.bind(name,func)})},refresh:function(){this.trigger("Refresh")},start:function(){files.length&&this.state!=plupload.STARTED&&(this.state=plupload.STARTED,this.trigger("StateChanged"),uploadNext.call(this))},stop:function(){this.state!=plupload.STOPPED&&(this.state=plupload.STOPPED,this.trigger("CancelUpload"),this.trigger("StateChanged"))},disableBrowse:function(){disabled=arguments[0]!==undef?arguments[0]:!0,this.trigger("DisableBrowse",disabled)
},getFile:function(id){var i;for(i=files.length-1;i>=0;i--)if(files[i].id===id)return files[i]},removeFile:function(file){var i;for(i=files.length-1;i>=0;i--)if(files[i].id===file.id)return this.splice(i,1)[0]},splice:function(start,length){var removed;return removed=files.splice(start===undef?0:start,length===undef?files.length:length),this.trigger("FilesRemoved",removed),this.trigger("QueueChanged"),removed},trigger:function(name){var i,args,list=events[name.toLowerCase()];if(list)for(args=Array.prototype.slice.call(arguments),args[0]=this,i=0;i<list.length;i++)if(list[i].func.apply(list[i].scope,args)===!1)return!1;
return!0},hasEventListener:function(name){return!!events[name.toLowerCase()]},bind:function(name,func,scope){var list;name=name.toLowerCase(),list=events[name]||[],list.push({func:func,scope:scope||this}),events[name]=list},unbind:function(name){name=name.toLowerCase();var i,list=events[name],func=arguments[1];if(list){if(func!==undef){for(i=list.length-1;i>=0;i--)if(list[i].func===func){list.splice(i,1);break}}else list=[];list.length||delete events[name]}},unbindAll:function(){var self=this;plupload.each(events,function(list,name){self.unbind(name)
})},destroy:function(){this.stop(),this.trigger("Destroy"),this.unbindAll()}})},plupload.File=function(id,name,size){var self=this;self.id=id,self.name=name,self.size=size,self.loaded=0,self.percent=0,self.status=0},plupload.Runtime=function(){this.getFeatures=function(){},this.init=function(){}},plupload.QueueProgress=function(){var self=this;self.size=0,self.loaded=0,self.uploaded=0,self.failed=0,self.queued=0,self.percent=0,self.bytesPerSec=0,self.reset=function(){self.size=self.loaded=self.uploaded=self.failed=self.queued=self.percent=self.bytesPerSec=0
}},plupload.runtimes={},$.plupload=plupload}(),function(window,document,plupload){function getById(id){return document.getElementById(id)}plupload.runtimes.Html4=plupload.addRuntime("html4",{getFeatures:function(){return{multipart:!0,triggerDialog:plupload.ua.gecko&&window.FormData||plupload.ua.webkit}},init:function(uploader,callback){uploader.bind("Init",function(up){function createForm(){var form,input,bgcolor,browseButton;currentFileId=plupload.guid(),fileIds.push(currentFileId),form=document.createElement("form"),form.setAttribute("id","form_"+currentFileId),form.setAttribute("method","post"),form.setAttribute("enctype","multipart/form-data"),form.setAttribute("encoding","multipart/form-data"),form.setAttribute("target",up.id+"_iframe"),form.style.position="absolute",input=document.createElement("input"),input.setAttribute("id","input_"+currentFileId),input.setAttribute("type","file"),input.setAttribute("accept",mimes),input.setAttribute("size",1),browseButton=getById(up.settings.browse_button),up.features.triggerDialog&&browseButton&&plupload.addEvent(getById(up.settings.browse_button),"click",function(e){input.disabled||input.click(),e.preventDefault()
},up.id),plupload.extend(input.style,{width:"100%",height:"100%",opacity:0,fontSize:"99px",cursor:"pointer"}),plupload.extend(form.style,{overflow:"hidden"}),bgcolor=up.settings.shim_bgcolor,bgcolor&&(form.style.background=bgcolor),IE&&plupload.extend(input.style,{filter:"alpha(opacity=0)"}),plupload.addEvent(input,"change",function(e){var name,element=e.target,files=[];element.value&&(getById("form_"+currentFileId).style.top="-1048575px",name=element.value.replace(/\\/g,"/"),name=name.substring(name.length,name.lastIndexOf("/")+1),files.push(new plupload.File(currentFileId,name)),up.features.triggerDialog?plupload.removeEvent(browseButton,"click",up.id):plupload.removeAllEvents(form,up.id),plupload.removeEvent(input,"change",up.id),createForm(),files.length&&uploader.trigger("FilesAdded",files))
},up.id),form.appendChild(input),container.appendChild(form),up.refresh()}function createIframe(){var temp=document.createElement("div");temp.innerHTML='<iframe id="'+up.id+'_iframe" name="'+up.id+'_iframe" src="'+url+':&quot;&quot;" style="display:none"></iframe>',iframe=temp.firstChild,container.appendChild(iframe),plupload.addEvent(iframe,"load",function(e){var el,result,n=e.target;if(currentFile){try{el=n.contentWindow.document||n.contentDocument||window.frames[n.id].document}catch(ex){return up.trigger("Error",{code:plupload.SECURITY_ERROR,message:plupload.translate("Security error."),file:currentFile}),void 0
}result=el.body.innerHTML,result&&(currentFile.status=plupload.DONE,currentFile.loaded=1025,currentFile.percent=100,up.trigger("UploadProgress",currentFile),up.trigger("FileUploaded",currentFile,{response:result}))}},up.id)}var iframe,currentFile,currentFileId,i,ext,type,y,container=document.body,url="javascript",fileIds=[],IE=/MSIE/.test(navigator.userAgent),mimes=[],filters=up.settings.filters;no_type_restriction:for(i=0;i<filters.length;i++)for(ext=filters[i].extensions.split(/,/),y=0;y<ext.length;y++){if("*"===ext[y]){mimes=[];
break no_type_restriction}type=plupload.mimeTypes[ext[y]],type&&-1===plupload.inArray(type,mimes)&&mimes.push(type)}mimes=mimes.join(","),up.settings.container&&(container=getById(up.settings.container),"static"===plupload.getStyle(container,"position")&&(container.style.position="relative")),up.bind("UploadFile",function(up,file){var form,input;file.status!=plupload.DONE&&file.status!=plupload.FAILED&&up.state!=plupload.STOPPED&&(form=getById("form_"+file.id),input=getById("input_"+file.id),input.setAttribute("name",up.settings.file_data_name),form.setAttribute("action",up.settings.url),plupload.each(plupload.extend({name:file.target_name||file.name},up.settings.multipart_params),function(value,name){var hidden=document.createElement("input");
plupload.extend(hidden,{type:"hidden",name:name,value:value}),form.insertBefore(hidden,form.firstChild)}),currentFile=file,getById("form_"+currentFileId).style.top="-1048575px",form.submit())}),up.bind("FileUploaded",function(up){up.refresh()}),up.bind("StateChanged",function(up){up.state==plupload.STARTED?createIframe():up.state==plupload.STOPPED&&window.setTimeout(function(){plupload.removeEvent(iframe,"load",up.id),iframe.parentNode&&iframe.parentNode.removeChild(iframe)},0),plupload.each(up.files,function(file){if(file.status===plupload.DONE||file.status===plupload.FAILED){var form=getById("form_"+file.id);
form&&form.parentNode.removeChild(form)}})}),up.bind("Refresh",function(up){var browseButton,topElement,hoverClass,activeClass,browsePos,browseSize,inputContainer,inputFile,zIndex;browseButton=getById(up.settings.browse_button),browseButton&&(browsePos=plupload.getPos(browseButton,getById(up.settings.container)),browseSize=plupload.getSize(browseButton),inputContainer=getById("form_"+currentFileId),inputFile=getById("input_"+currentFileId),plupload.extend(inputContainer.style,{top:browsePos.y+"px",left:browsePos.x+"px",width:browseSize.w+"px",height:browseSize.h+"px"}),up.features.triggerDialog&&("static"===plupload.getStyle(browseButton,"position")&&plupload.extend(browseButton.style,{position:"relative"}),zIndex=parseInt(browseButton.style.zIndex,10),isNaN(zIndex)&&(zIndex=0),plupload.extend(browseButton.style,{zIndex:zIndex}),plupload.extend(inputContainer.style,{zIndex:zIndex-1})),hoverClass=up.settings.browse_button_hover,activeClass=up.settings.browse_button_active,topElement=up.features.triggerDialog?browseButton:inputContainer,hoverClass&&(plupload.addEvent(topElement,"mouseover",function(){plupload.addClass(browseButton,hoverClass)
},up.id),plupload.addEvent(topElement,"mouseout",function(){plupload.removeClass(browseButton,hoverClass)},up.id)),activeClass&&(plupload.addEvent(topElement,"mousedown",function(){plupload.addClass(browseButton,activeClass)},up.id),plupload.addEvent(document.body,"mouseup",function(){plupload.removeClass(browseButton,activeClass)},up.id)))}),uploader.bind("FilesRemoved",function(up,files){var i,n;for(i=0;i<files.length;i++)n=getById("form_"+files[i].id),n&&n.parentNode.removeChild(n)}),uploader.bind("DisableBrowse",function(up,disabled){var input=document.getElementById("input_"+currentFileId);
input&&(input.disabled=disabled)}),uploader.bind("Destroy",function(up){var name,element,form,elements={inputContainer:"form_"+currentFileId,inputFile:"input_"+currentFileId,browseButton:up.settings.browse_button};for(name in elements)element=getById(elements[name]),element&&plupload.removeAllEvents(element,up.id);plupload.removeAllEvents(document.body,up.id),plupload.each(fileIds,function(id){form=getById("form_"+id),form&&container.removeChild(form)})}),createForm()}),callback({success:!0})}})}(window,document,$.plupload),function(window,document,plupload,undef){function readFileAsDataURL(file,callback){var reader;
return"FileReader"in window?(reader=new FileReader,reader.readAsDataURL(file),reader.onload=function(){callback(reader.result)},void 0):callback(file.getAsDataURL())}function readFileAsBinary(file,callback){var reader;return"FileReader"in window?(reader=new FileReader,reader.readAsBinaryString(file),reader.onload=function(){callback(reader.result)},void 0):callback(file.getAsBinary())}function scaleImage(file,resize,mime,callback){var canvas,context,img,scale,up=this;readFileAsDataURL(html5files[file.id],function(data){canvas=document.createElement("canvas"),canvas.style.display="none",document.body.appendChild(canvas),context=canvas.getContext("2d"),img=new Image,img.onerror=img.onabort=function(){callback({success:!1})
},img.onload=function(){var width,height,jpegHeaders,exifParser;if(resize.width||(resize.width=img.width),resize.height||(resize.height=img.height),scale=Math.min(resize.width/img.width,resize.height/img.height),1>scale||1===scale&&"image/jpeg"===mime){if(width=Math.round(img.width*scale),height=Math.round(img.height*scale),canvas.width=width,canvas.height=height,context.drawImage(img,0,0,width,height),"image/jpeg"===mime){if(jpegHeaders=new JPEG_Headers(atob(data.substring(data.indexOf("base64,")+7))),jpegHeaders.headers&&jpegHeaders.headers.length&&(exifParser=new ExifParser,exifParser.init(jpegHeaders.get("exif")[0])&&(exifParser.setExif("PixelXDimension",width),exifParser.setExif("PixelYDimension",height),jpegHeaders.set("exif",exifParser.getBinary()),up.hasEventListener("ExifData")&&up.trigger("ExifData",file,exifParser.EXIF()),up.hasEventListener("GpsData")&&up.trigger("GpsData",file,exifParser.GPS()))),resize.quality)try{data=canvas.toDataURL(mime,resize.quality/100)
}catch(e){data=canvas.toDataURL(mime)}}else data=canvas.toDataURL(mime);data=data.substring(data.indexOf("base64,")+7),data=atob(data),jpegHeaders&&jpegHeaders.headers&&jpegHeaders.headers.length&&(data=jpegHeaders.restore(data),jpegHeaders.purge()),canvas.parentNode.removeChild(canvas),callback({success:!0,data:data})}else callback({success:!1})},img.src=data})}function BinaryReader(){function read(idx,size){var i,mv=II?0:-8*(size-1),sum=0;for(i=0;size>i;i++)sum|=bin.charCodeAt(idx+i)<<Math.abs(mv+8*i);return sum
}function putstr(segment,idx,length){var length=3===arguments.length?length:bin.length-idx-1;bin=bin.substr(0,idx)+segment+bin.substr(length+idx)}function write(idx,num,size){var i,str="",mv=II?0:-8*(size-1);for(i=0;size>i;i++)str+=String.fromCharCode(255&num>>Math.abs(mv+8*i));putstr(str,idx,size)}var bin,II=!1;return{II:function(order){return order===undef?II:(II=order,void 0)},init:function(binData){II=!1,bin=binData},SEGMENT:function(idx,length,segment){switch(arguments.length){case 1:return bin.substr(idx,bin.length-idx-1);
case 2:return bin.substr(idx,length);case 3:putstr(segment,idx,length);break;default:return bin}},BYTE:function(idx){return read(idx,1)},SHORT:function(idx){return read(idx,2)},LONG:function(idx,num){return num===undef?read(idx,4):(write(idx,num,4),void 0)},SLONG:function(idx){var num=read(idx,4);return num>2147483647?num-4294967296:num},STRING:function(idx,size){var str="";for(size+=idx;size>idx;idx++)str+=String.fromCharCode(read(idx,1));return str}}}function JPEG_Headers(data){var read,idx,limit,markers={65505:{app:"EXIF",name:"APP1",signature:"Exif\0"},65506:{app:"ICC",name:"APP2",signature:"ICC_PROFILE\0"},65517:{app:"IPTC",name:"APP13",signature:"Photoshop 3.0\0"}},headers=[],marker=undef,length=0;
if(read=new BinaryReader,read.init(data),65496===read.SHORT(0)){for(idx=2,limit=Math.min(1048576,data.length);limit>=idx;)if(marker=read.SHORT(idx),marker>=65488&&65495>=marker)idx+=2;else{if(65498===marker||65497===marker)break;length=read.SHORT(idx+2)+2,markers[marker]&&read.STRING(idx+4,markers[marker].signature.length)===markers[marker].signature&&headers.push({hex:marker,app:markers[marker].app.toUpperCase(),name:markers[marker].name.toUpperCase(),start:idx,length:length,segment:read.SEGMENT(idx,length)}),idx+=length
}return read.init(null),{headers:headers,restore:function(data){read.init(data);var jpegHeaders=new JPEG_Headers(data);if(!jpegHeaders.headers)return!1;for(var i=jpegHeaders.headers.length;i>0;i--){var hdr=jpegHeaders.headers[i-1];read.SEGMENT(hdr.start,hdr.length,"")}jpegHeaders.purge(),idx=65504==read.SHORT(2)?4+read.SHORT(4):2;for(var i=0,max=headers.length;max>i;i++)read.SEGMENT(idx,0,headers[i].segment),idx+=headers[i].length;return read.SEGMENT()},get:function(app){for(var array=[],i=0,max=headers.length;max>i;i++)headers[i].app===app.toUpperCase()&&array.push(headers[i].segment);
return array},set:function(app,segment){var array=[];"string"==typeof segment?array.push(segment):array=segment;for(var i=ii=0,max=headers.length;max>i&&(headers[i].app===app.toUpperCase()&&(headers[i].segment=array[ii],headers[i].length=array[ii].length,ii++),!(ii>=array.length));i++);},purge:function(){headers=[],read.init(null)}}}}function ExifParser(){function extractTags(IFD_offset,tags2extract){var i,ii,tag,type,count,tagOffset,offset,value,length=data.SHORT(IFD_offset),values=[],hash={};for(i=0;length>i;i++)if(offset=tagOffset=IFD_offset+12*i+2,tag=tags2extract[data.SHORT(offset)],tag!==undef){switch(type=data.SHORT(offset+=2),count=data.LONG(offset+=2),offset+=4,values=[],type){case 1:case 7:for(count>4&&(offset=data.LONG(offset)+offsets.tiffHeader),ii=0;count>ii;ii++)values[ii]=data.BYTE(offset+ii);
break;case 2:count>4&&(offset=data.LONG(offset)+offsets.tiffHeader),hash[tag]=data.STRING(offset,count-1);continue;case 3:for(count>2&&(offset=data.LONG(offset)+offsets.tiffHeader),ii=0;count>ii;ii++)values[ii]=data.SHORT(offset+2*ii);break;case 4:for(count>1&&(offset=data.LONG(offset)+offsets.tiffHeader),ii=0;count>ii;ii++)values[ii]=data.LONG(offset+4*ii);break;case 5:for(offset=data.LONG(offset)+offsets.tiffHeader,ii=0;count>ii;ii++)values[ii]=data.LONG(offset+4*ii)/data.LONG(offset+4*ii+4);break;case 9:for(offset=data.LONG(offset)+offsets.tiffHeader,ii=0;count>ii;ii++)values[ii]=data.SLONG(offset+4*ii);
break;case 10:for(offset=data.LONG(offset)+offsets.tiffHeader,ii=0;count>ii;ii++)values[ii]=data.SLONG(offset+4*ii)/data.SLONG(offset+4*ii+4);break;default:continue}value=1==count?values[0]:values,hash[tag]=tagDescs.hasOwnProperty(tag)&&"object"!=typeof value?tagDescs[tag][value]:value}return hash}function getIFDOffsets(){var Tiff=undef,idx=offsets.tiffHeader;return data.II(18761==data.SHORT(idx)),42!==data.SHORT(idx+=2)?!1:(offsets.IFD0=offsets.tiffHeader+data.LONG(idx+=2),Tiff=extractTags(offsets.IFD0,tags.tiff),offsets.exifIFD="ExifIFDPointer"in Tiff?offsets.tiffHeader+Tiff.ExifIFDPointer:undef,offsets.gpsIFD="GPSInfoIFDPointer"in Tiff?offsets.tiffHeader+Tiff.GPSInfoIFDPointer:undef,!0)
}function setTag(ifd,tag,value){var offset,length,tagOffset,valueOffset=0;if("string"==typeof tag){var tmpTags=tags[ifd.toLowerCase()];for(hex in tmpTags)if(tmpTags[hex]===tag){tag=hex;break}}for(offset=offsets[ifd.toLowerCase()+"IFD"],length=data.SHORT(offset),i=0;length>i;i++)if(tagOffset=offset+12*i+2,data.SHORT(tagOffset)==tag){valueOffset=tagOffset+8;break}return valueOffset?(data.LONG(valueOffset,value),!0):!1}var data,tags,tagDescs,offsets={};return data=new BinaryReader,tags={tiff:{274:"Orientation",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"}},tagDescs={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire.",1:"Flash fired.",5:"Strobe return light not detected.",7:"Strobe return light detected.",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},{init:function(segment){return offsets={tiffHeader:10},segment!==undef&&segment.length?(data.init(segment),65505===data.SHORT(0)&&"EXIF\0"===data.STRING(4,5).toUpperCase()?getIFDOffsets():!1):!1
},EXIF:function(){var Exif;if(Exif=extractTags(offsets.exifIFD,tags.exif),Exif.ExifVersion&&"array"===plupload.typeOf(Exif.ExifVersion)){for(var i=0,exifVersion="";i<Exif.ExifVersion.length;i++)exifVersion+=String.fromCharCode(Exif.ExifVersion[i]);Exif.ExifVersion=exifVersion}return Exif},GPS:function(){var GPS;return GPS=extractTags(offsets.gpsIFD,tags.gps),GPS.GPSVersionID&&(GPS.GPSVersionID=GPS.GPSVersionID.join(".")),GPS},setExif:function(tag,value){return"PixelXDimension"!==tag&&"PixelYDimension"!==tag?!1:setTag("exif",tag,value)
},getBinary:function(){return data.SEGMENT()}}}var fakeSafariDragDrop,html5files={};plupload.runtimes.Html5=void 0===window.File?void 0:plupload.addRuntime("html5",{getFeatures:function(){var xhr,hasXhrSupport,hasProgress,canSendBinary,dataAccessSupport,sliceSupport;return hasXhrSupport=hasProgress=dataAccessSupport=sliceSupport=!1,window.XMLHttpRequest&&(xhr=new XMLHttpRequest,hasProgress=!!xhr.upload,hasXhrSupport=!(!xhr.sendAsBinary&&!xhr.upload)),hasXhrSupport&&(canSendBinary=!!(xhr.sendAsBinary||window.Uint8Array&&window.ArrayBuffer),dataAccessSupport=!(!File||!File.prototype.getAsDataURL&&!window.FileReader||!canSendBinary),sliceSupport=!(!File||!(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice))),fakeSafariDragDrop=plupload.ua.safari&&plupload.ua.windows,{html5:hasXhrSupport,dragdrop:function(){var div=document.createElement("div");
return"draggable"in div||"ondragstart"in div&&"ondrop"in div}(),jpgresize:dataAccessSupport,pngresize:dataAccessSupport,multipart:dataAccessSupport||!!window.FileReader||!!window.FormData,canSendBinary:canSendBinary,cantSendBlobInFormData:!(!(plupload.ua.gecko&&window.FormData&&window.FileReader)||FileReader.prototype.readAsArrayBuffer),progress:hasProgress,chunks:sliceSupport,multi_selection:!(plupload.ua.safari&&plupload.ua.windows),triggerDialog:plupload.ua.gecko&&window.FormData||plupload.ua.webkit}},init:function(uploader,callback){function addSelectedFiles(native_files){var file,i,id,files=[],fileNames={};
for(i=0;i<native_files.length;i++)file=native_files[i],fileNames[file.name]||(fileNames[file.name]=!0,id=plupload.guid(),html5files[id]=file,files.push(new plupload.File(id,file.fileName||file.name,file.fileSize||file.size)));files.length&&uploader.trigger("FilesAdded",files)}var features,xhr;return features=this.getFeatures(),features.html5?(uploader.bind("Init",function(up){var inputContainer,browseButton,i,y,ext,type,inputFile,mimes=[],filters=up.settings.filters,container=document.body;inputContainer=document.createElement("div"),inputContainer.id=up.id+"_html5_container",plupload.extend(inputContainer.style,{position:"absolute",background:uploader.settings.shim_bgcolor||"transparent",width:"100px",height:"100px",overflow:"hidden",zIndex:99999,opacity:uploader.settings.shim_bgcolor?"":0}),inputContainer.className="plupload html5",uploader.settings.container&&(container=document.getElementById(uploader.settings.container),"static"===plupload.getStyle(container,"position")&&(container.style.position="relative")),container.appendChild(inputContainer);
no_type_restriction:for(i=0;i<filters.length;i++)for(ext=filters[i].extensions.split(/,/),y=0;y<ext.length;y++){if("*"===ext[y]){mimes=[];break no_type_restriction}type=plupload.mimeTypes[ext[y]],type&&-1===plupload.inArray(type,mimes)&&mimes.push(type)}if(inputContainer.innerHTML='<input id="'+uploader.id+'_html5" '+' style="font-size:999px"'+' type="file" accept="'+mimes.join(",")+'" '+(uploader.settings.multi_selection&&uploader.features.multi_selection?'multiple="multiple"':"")+" />",inputContainer.scrollTop=100,inputFile=document.getElementById(uploader.id+"_html5"),up.features.triggerDialog?plupload.extend(inputFile.style,{position:"absolute",width:"100%",height:"100%"}):plupload.extend(inputFile.style,{cssFloat:"right",styleFloat:"right"}),inputFile.onchange=function(){addSelectedFiles(this.files),this.value=""
},browseButton=document.getElementById(up.settings.browse_button)){var hoverClass=up.settings.browse_button_hover,activeClass=up.settings.browse_button_active,topElement=up.features.triggerDialog?browseButton:inputContainer;hoverClass&&(plupload.addEvent(topElement,"mouseover",function(){plupload.addClass(browseButton,hoverClass)},up.id),plupload.addEvent(topElement,"mouseout",function(){plupload.removeClass(browseButton,hoverClass)},up.id)),activeClass&&(plupload.addEvent(topElement,"mousedown",function(){plupload.addClass(browseButton,activeClass)
},up.id),plupload.addEvent(document.body,"mouseup",function(){plupload.removeClass(browseButton,activeClass)},up.id)),up.features.triggerDialog&&plupload.addEvent(browseButton,"click",function(e){var input=document.getElementById(up.id+"_html5");input&&!input.disabled&&input.click(),e.preventDefault()},up.id)}}),uploader.bind("PostInit",function(){var dropElm=document.getElementById(uploader.settings.drop_element);if(dropElm){if(fakeSafariDragDrop)return plupload.addEvent(dropElm,"dragenter",function(){var dropInputElm,dropPos,dropSize;
dropInputElm=document.getElementById(uploader.id+"_drop"),dropInputElm||(dropInputElm=document.createElement("input"),dropInputElm.setAttribute("type","file"),dropInputElm.setAttribute("id",uploader.id+"_drop"),dropInputElm.setAttribute("multiple","multiple"),plupload.addEvent(dropInputElm,"change",function(){addSelectedFiles(this.files),plupload.removeEvent(dropInputElm,"change",uploader.id),dropInputElm.parentNode.removeChild(dropInputElm)},uploader.id),dropElm.appendChild(dropInputElm)),dropPos=plupload.getPos(dropElm,document.getElementById(uploader.settings.container)),dropSize=plupload.getSize(dropElm),"static"===plupload.getStyle(dropElm,"position")&&plupload.extend(dropElm.style,{position:"relative"}),plupload.extend(dropInputElm.style,{position:"absolute",display:"block",top:0,left:0,width:dropSize.w+"px",height:dropSize.h+"px",opacity:0})
},uploader.id),void 0;plupload.addEvent(dropElm,"dragover",function(e){e.preventDefault()},uploader.id),plupload.addEvent(dropElm,"drop",function(e){var dataTransfer=e.dataTransfer;dataTransfer&&dataTransfer.files&&addSelectedFiles(dataTransfer.files),e.preventDefault()},uploader.id)}}),uploader.bind("Refresh",function(up){var browseButton,browsePos,browseSize,inputContainer,zIndex;browseButton=document.getElementById(uploader.settings.browse_button),browseButton&&(browsePos=plupload.getPos(browseButton,document.getElementById(up.settings.container)),browseSize=plupload.getSize(browseButton),inputContainer=document.getElementById(uploader.id+"_html5_container"),plupload.extend(inputContainer.style,{top:browsePos.y+"px",left:browsePos.x+"px",width:browseSize.w+"px",height:browseSize.h+"px"}),uploader.features.triggerDialog&&("static"===plupload.getStyle(browseButton,"position")&&plupload.extend(browseButton.style,{position:"relative"}),zIndex=parseInt(plupload.getStyle(browseButton,"z-index"),10),isNaN(zIndex)&&(zIndex=0),plupload.extend(browseButton.style,{zIndex:zIndex}),plupload.extend(inputContainer.style,{zIndex:zIndex-1})))
}),uploader.bind("DisableBrowse",function(up,disabled){var input=document.getElementById(up.id+"_html5");input&&(input.disabled=disabled)}),uploader.bind("CancelUpload",function(){xhr&&xhr.abort&&xhr.abort()}),uploader.bind("UploadFile",function(up,file){function w3cBlobSlice(blob,start,end){var blobSlice;if(!File.prototype.slice)return(blobSlice=File.prototype.webkitSlice||File.prototype.mozSlice)?blobSlice.call(blob,start,end):null;try{return blob.slice(),blob.slice(start,end)}catch(e){return blob.slice(start,end-start)
}}function sendBinaryBlob(blob){function uploadNextChunk(){function prepareAndSend(bin){var formData,multipartDeltaSize=0,boundary="----pluploadboundary"+plupload.guid(),dashdash="--",crlf="\r\n",multipartBlob="";if(xhr=new XMLHttpRequest,xhr.upload&&(xhr.upload.onprogress=function(e){file.loaded=Math.min(file.size,loaded+e.loaded-multipartDeltaSize),up.trigger("UploadProgress",file)}),xhr.onreadystatechange=function(){var httpStatus,chunkArgs;if(4==xhr.readyState&&up.state!==plupload.STOPPED){try{httpStatus=xhr.status
}catch(ex){httpStatus=0}if(httpStatus>=400)up.trigger("Error",{code:plupload.HTTP_ERROR,message:plupload.translate("HTTP Error."),file:file,status:httpStatus});else{if(chunks){if(chunkArgs={chunk:chunk,chunks:chunks,response:xhr.responseText,status:httpStatus},up.trigger("ChunkUploaded",file,chunkArgs),loaded+=curChunkSize,chunkArgs.cancelled)return file.status=plupload.FAILED,void 0;file.loaded=Math.min(file.size,(chunk+1)*chunkSize)}else file.loaded=file.size;up.trigger("UploadProgress",file),bin=chunkBlob=formData=multipartBlob=null,!chunks||++chunk>=chunks?(file.status=plupload.DONE,up.trigger("FileUploaded",file,{response:xhr.responseText,status:httpStatus})):uploadNextChunk()
}}},up.settings.multipart&&features.multipart){if(args.name=file.target_name||file.name,xhr.open("post",url,!0),plupload.each(up.settings.headers,function(value,name){xhr.setRequestHeader(name,value)}),"string"!=typeof bin&&window.FormData)return formData=new FormData,plupload.each(plupload.extend(args,up.settings.multipart_params),function(value,name){formData.append(name,value)}),formData.append(up.settings.file_data_name,bin),xhr.send(formData),void 0;if("string"==typeof bin){if(xhr.setRequestHeader("Content-Type","multipart/form-data; boundary="+boundary),plupload.each(plupload.extend(args,up.settings.multipart_params),function(value,name){multipartBlob+=dashdash+boundary+crlf+'Content-Disposition: form-data; name="'+name+'"'+crlf+crlf,multipartBlob+=unescape(encodeURIComponent(value))+crlf
}),mimeType=plupload.mimeTypes[file.name.replace(/^.+\.([^.]+)/,"$1").toLowerCase()]||"application/octet-stream",multipartBlob+=dashdash+boundary+crlf+'Content-Disposition: form-data; name="'+up.settings.file_data_name+'"; filename="'+unescape(encodeURIComponent(file.name))+'"'+crlf+"Content-Type: "+mimeType+crlf+crlf+bin+crlf+dashdash+boundary+dashdash+crlf,multipartDeltaSize=multipartBlob.length-bin.length,bin=multipartBlob,xhr.sendAsBinary)xhr.sendAsBinary(bin);else if(features.canSendBinary){for(var ui8a=new Uint8Array(bin.length),i=0;i<bin.length;i++)ui8a[i]=255&bin.charCodeAt(i);
xhr.send(ui8a.buffer)}return}}url=plupload.buildUrl(up.settings.url,plupload.extend(args,up.settings.multipart_params)),xhr.open("post",url,!0),xhr.setRequestHeader("Content-Type","application/octet-stream"),plupload.each(up.settings.headers,function(value,name){xhr.setRequestHeader(name,value)}),xhr.send(bin)}var chunkBlob,chunks,args,chunkSize,curChunkSize,mimeType,url=up.settings.url;file.status!=plupload.DONE&&file.status!=plupload.FAILED&&up.state!=plupload.STOPPED&&(args={name:file.target_name||file.name},settings.chunk_size&&file.size>settings.chunk_size&&(features.chunks||"string"==typeof blob)?(chunkSize=settings.chunk_size,chunks=Math.ceil(file.size/chunkSize),curChunkSize=Math.min(chunkSize,file.size-chunk*chunkSize),chunkBlob="string"==typeof blob?blob.substring(chunk*chunkSize,chunk*chunkSize+curChunkSize):w3cBlobSlice(blob,chunk*chunkSize,chunk*chunkSize+curChunkSize),args.chunk=chunk,args.chunks=chunks):(curChunkSize=file.size,chunkBlob=blob),up.settings.multipart&&features.multipart&&"string"!=typeof chunkBlob&&fr&&features.cantSendBlobInFormData&&features.chunks&&up.settings.chunk_size?(fr.onload=function(){prepareAndSend(fr.result)
},fr.readAsBinaryString(chunkBlob)):prepareAndSend(chunkBlob))}var chunk=0,loaded=0,fr="FileReader"in window?new FileReader:null;uploadNextChunk()}var nativeFile,settings=up.settings;nativeFile=html5files[file.id],features.jpgresize&&up.settings.resize&&/\.(png|jpg|jpeg)$/i.test(file.name)?scaleImage.call(up,file,up.settings.resize,/\.png$/i.test(file.name)?"image/png":"image/jpeg",function(res){res.success?(file.size=res.data.length,sendBinaryBlob(res.data)):features.chunks?sendBinaryBlob(nativeFile):readFileAsBinary(nativeFile,sendBinaryBlob)
}):!features.chunks&&features.jpgresize?readFileAsBinary(nativeFile,sendBinaryBlob):sendBinaryBlob(nativeFile)}),uploader.bind("Destroy",function(up){var name,element,container=document.body,elements={inputContainer:up.id+"_html5_container",inputFile:up.id+"_html5",browseButton:up.settings.browse_button,dropElm:up.settings.drop_element};for(name in elements)element=document.getElementById(elements[name]),element&&plupload.removeAllEvents(element,up.id);plupload.removeAllEvents(document.body,up.id),up.settings.container&&(container=document.getElementById(up.settings.container)),container.removeChild(document.getElementById(elements.inputContainer))
}),callback({success:!0}),void 0):(callback({success:!1}),void 0)}})}(window,document,$.plupload),$.Controller("plupload",{defaultOptions:{"{uploader}":".uploader","{uploadButton}":".uploadButton","{uploadDropsite}":".uploadDropsite",settings:{runtimes:"html5, html4",url:$.indexUrl,max_file_count:20,unique_names:!0}}},function(self){return{init:function(){var settings=self.options.settings,uploadContainerId=$.uid("uploadContainer-");self.element.attr("id",uploadContainerId),settings.container=uploadContainerId;
var uploadButtonId=$.uid("uploadButton-");self.uploadButton().attr("id",uploadButtonId),settings.browse_button=uploadButtonId;var uploadDropsiteId=$.uid("uploadDropsite-");self.uploadDropsite().length>0&&(self.uploadDropsite().attr("id",uploadDropsiteId),settings.drop_element=uploadDropsiteId),self.uploader=$(self.uploader()[0]||self.element),self.plupload=new $.plupload.Uploader(settings),self.plupload.bind("PostInit",function(){self.eventHandler("PostInit",$.makeArray(arguments))}),self.plupload.init();var events=["BeforeUpload","ChunkUploaded","Destroy","Error","FilesAdded","FilesRemoved","FileUploaded","Init","QueueChanged","Refresh","StateChanged","UploadComplete","UploadFile","UploadProgress"];
$.each(events,function(i,eventName){self.plupload.bind(eventName,function(){self.eventHandler(eventName,$.makeArray(arguments))})})},eventHandler:function(eventName,args){var elementEventHandlerArgs,eventHandler=self["plupload::"+eventName];!function(){var eventHandlers=(self.uploader.data("events")||{})[eventName];return eventHandlers?eventHandlers[0].handler:void 0}(),$.isFunction(eventHandler)&&(elementEventHandlerArgs=eventHandler.apply(self,args)),elementEventHandlerArgs!==!1&&self.uploader.trigger(eventName,elementEventHandlerArgs||args)
},"plupload::FileUploaded":function(up,file,data,handler){var response,error;try{response=eval("("+data.response+")")}catch(e){error={code:-100,message:"Invalid response from server.",data:data},self.uploader.trigger("FileError",[up,file,error])}return error?!1:[up,file,response]},"plupload::Error":function(up,error){try{console.log("plupload Error: ",up,error)}catch(e){}}}})};exports(),module.resolveWith(exports)};dispatch("plupload").containing(moduleFactory).to("Foundry/2.1 Modules")}();