;(function(window,o,undef){var delay=window.setTimeout,fileFilters={};function normalizeCaps(settings){var features=settings.required_features,caps={};function resolve(feature,value,strict){var map={chunks:'slice_blob',jpgresize:'send_binary_string',pngresize:'send_binary_string',progress:'report_upload_progress',multi_selection:'select_multiple',dragdrop:'drag_and_drop',drop_element:'drag_and_drop',headers:'send_custom_headers',urlstream_upload:'send_binary_string',canSendBinary:'send_binary',triggerDialog:'summon_file_dialog'};if(map[feature]){caps[map[feature]]=value;}else if(!strict){caps[feature]=value;}}
if(typeof(features)==='string'){plupload.each(features.split(/\s*,\s*/),function(feature){resolve(feature,true);});}else if(typeof(features)==='object'){plupload.each(features,function(value,feature){resolve(feature,value);});}else if(features===true){if(settings.chunk_size>0){caps.slice_blob=true;}
if(settings.resize.enabled||!settings.multipart){caps.send_binary_string=true;}
plupload.each(settings,function(value,feature){resolve(feature,!!value,true);});}
settings.runtimes='html5,html4';return caps;}
var plupload={VERSION:'2.1.9',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,FILE_DUPLICATE_ERROR:-602,IMAGE_FORMAT_ERROR:-700,MEMORY_ERROR:-701,IMAGE_DIMENSIONS_ERROR:-702,mimeTypes:o.mimes,ua:o.ua,typeOf:o.typeOf,extend:o.extend,guid:o.guid,getAll:function get(ids){var els=[],el;if(plupload.typeOf(ids)!=='array'){ids=[ids];}
var i=ids.length;while(i--){el=plupload.get(ids[i]);if(el){els.push(el);}}
return els.length?els:null;},get:o.get,each:o.each,getPos:o.getPos,getSize:o.getSize,xmlEncode:function(str){var xmlEncodeChars={'<':'lt','>':'gt','&':'amp','"':'quot','\'':'#39'},xmlEncodeRegExp=/[<>&\"\']/g;return str?(''+str).replace(xmlEncodeRegExp,function(chr){return xmlEncodeChars[chr]?'&'+xmlEncodeChars[chr]+';':chr;}):str;},toArray:o.toArray,inArray:o.inArray,addI18n:o.addI18n,translate:o.translate,isEmptyObj:o.isEmptyObj,hasClass:o.hasClass,addClass:o.addClass,removeClass:o.removeClass,getStyle:o.getStyle,addEvent:o.addEvent,removeEvent:o.removeEvent,removeAllEvents:o.removeAllEvents,cleanName:function(name){var i,lookup;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'];for(i=0;i<lookup.length;i+=2){name=name.replace(lookup[i],lookup[i+1]);}
name=name.replace(/\s+/g,'_');name=name.replace(/[^a-z0-9_\-\.]+/gi,'');return name;},buildUrl:function(url,items){var query='';plupload.each(items,function(value,name){query+=(query?'&':'')+encodeURIComponent(name)+'='+encodeURIComponent(value);});if(query){url+=(url.indexOf('?')>0?'&':'?')+query;}
return url;},formatSize:function(size){if(size===undef||/\D/.test(size)){return plupload.translate('N/A');}
function round(num,precision){return Math.round(num*Math.pow(10,precision))/ Math.pow(10,precision);}
var boundary=Math.pow(1024,4);if(size>boundary){return round(size / boundary,1)+" "+plupload.translate('tb');}
if(size>(boundary/=1024)){return round(size / boundary,1)+" "+plupload.translate('gb');}
if(size>(boundary/=1024)){return round(size / boundary,1)+" "+plupload.translate('mb');}
if(size>1024){return Math.round(size / 1024)+" "+plupload.translate('kb');}
return size+" "+plupload.translate('b');},parseSize:o.parseSizeStr,predictRuntime:function(config,runtimes){var up,runtime;up=new plupload.Uploader(config);runtime=o.Runtime.thatCan(up.getOption().required_features,runtimes||config.runtimes);up.destroy();return runtime;},addFileFilter:function(name,cb){fileFilters[name]=cb;}};plupload.addFileFilter('mime_types',function(filters,file,cb){if(filters.length&&!filters.regexp.test(file.name)){this.trigger('Error',{code:plupload.FILE_EXTENSION_ERROR,message:plupload.translate('File extension error.'),file:file});cb(false);}else{cb(true);}});plupload.addFileFilter('max_file_size',function(maxSize,file,cb){var undef;maxSize=plupload.parseSize(maxSize);if(file.size!==undef&&maxSize&&file.size>maxSize){this.trigger('Error',{code:plupload.FILE_SIZE_ERROR,message:plupload.translate('File size error.'),file:file});cb(false);}else{cb(true);}});plupload.addFileFilter('prevent_duplicates',function(value,file,cb){if(value){var ii=this.files.length;while(ii--){if(file.name===this.files[ii].name&&file.size===this.files[ii].size){this.trigger('Error',{code:plupload.FILE_DUPLICATE_ERROR,message:plupload.translate('Duplicate file error.'),file:file});cb(false);return;}}}
cb(true);});plupload.Uploader=function(options){var uid=plupload.guid(),settings,files=[],preferred_caps={},fileInputs=[],fileDrops=[],startTime,total,disabled=false,xhr;function uploadNext(){var file,count=0,i;if(this.state==plupload.STARTED){for(i=0;i<files.length;i++){if(!file&&files[i].status==plupload.QUEUED){file=files[i];if(this.trigger("BeforeUpload",file)){file.status=plupload.UPLOADING;this.trigger("UploadFile",file);}}else{count++;}}
if(count==files.length){if(this.state!==plupload.STOPPED){this.state=plupload.STOPPED;this.trigger("StateChanged");}
this.trigger("UploadComplete",files);}}}
function calcFile(file){file.percent=file.size>0?Math.ceil(file.loaded / file.size*100):100;calc();}
function calc(){var i,file;total.reset();for(i=0;i<files.length;i++){file=files[i];if(file.size!==undef){total.size+=file.origSize;total.loaded+=file.loaded*file.origSize / file.size;}else{total.size=undef;}
if(file.status==plupload.DONE){total.uploaded++;}else if(file.status==plupload.FAILED){total.failed++;}else{total.queued++;}}
if(total.size===undef){total.percent=files.length>0?Math.ceil(total.uploaded / files.length*100):0;}else{total.bytesPerSec=Math.ceil(total.loaded /((+new Date()-startTime||1)/ 1000.0));total.percent=total.size>0?Math.ceil(total.loaded / total.size*100):0;}}
function getRUID(){var ctrl=fileInputs[0]||fileDrops[0];if(ctrl){return ctrl.getRuntime().uid;}
return false;}
function runtimeCan(file,cap){if(file.ruid){var info=o.Runtime.getInfo(file.ruid);if(info){return info.can(cap);}}
return false;}
function bindEventListeners(){this.bind('FilesAdded FilesRemoved',function(up){up.trigger('QueueChanged');up.refresh();});this.bind('CancelUpload',onCancelUpload);this.bind('BeforeUpload',onBeforeUpload);this.bind('UploadFile',onUploadFile);this.bind('UploadProgress',onUploadProgress);this.bind('StateChanged',onStateChanged);this.bind('QueueChanged',calc);this.bind('Error',onError);this.bind('FileUploaded',onFileUploaded);this.bind('Destroy',onDestroy);}
function initControls(settings,cb){var self=this,inited=0,queue=[];var options={runtime_order:settings.runtimes,required_caps:settings.required_features,preferred_caps:preferred_caps};plupload.each(settings.runtimes.split(/\s*,\s*/),function(runtime){if(settings[runtime]){options[runtime]=settings[runtime];}});if(settings.browse_button){plupload.each(settings.browse_button,function(el){queue.push(function(cb){var fileInput=new o.FileInput(plupload.extend({},options,{accept:settings.filters.mime_types,name:settings.file_data_name,multiple:settings.multi_selection,container:settings.container,browse_button:el}));fileInput.onready=function(){var info=o.Runtime.getInfo(this.ruid);o.extend(self.features,{chunks:info.can('slice_blob'),multipart:info.can('send_multipart'),multi_selection:info.can('select_multiple')});inited++;fileInputs.push(this);cb();};fileInput.onchange=function(){self.addFile(this.files);};fileInput.bind('mouseenter mouseleave mousedown mouseup',function(e){if(!disabled){if(settings.browse_button_hover){if('mouseenter'===e.type){o.addClass(el,settings.browse_button_hover);}else if('mouseleave'===e.type){o.removeClass(el,settings.browse_button_hover);}}
if(settings.browse_button_active){if('mousedown'===e.type){o.addClass(el,settings.browse_button_active);}else if('mouseup'===e.type){o.removeClass(el,settings.browse_button_active);}}}});fileInput.bind('mousedown',function(){self.trigger('Browse');});fileInput.bind('error runtimeerror',function(){fileInput=null;cb();});fileInput.init();});});}
if(settings.drop_element){plupload.each(settings.drop_element,function(el){queue.push(function(cb){var fileDrop=new o.FileDrop(plupload.extend({},options,{drop_zone:el}));fileDrop.onready=function(){var info=o.Runtime.getInfo(this.ruid);o.extend(self.features,{chunks:info.can('slice_blob'),multipart:info.can('send_multipart'),dragdrop:info.can('drag_and_drop')});inited++;fileDrops.push(this);cb();};fileDrop.ondrop=function(){self.addFile(this.files);};fileDrop.bind('error runtimeerror',function(){fileDrop=null;cb();});fileDrop.init();});});}
o.inSeries(queue,function(){if(typeof(cb)==='function'){cb(inited);}});}
function resizeImage(blob,params,cb){var img=new o.Image();try{img.onload=function(){if(params.width>this.width&&params.height>this.height&&params.quality===undef&&params.preserve_headers&&!params.crop){this.destroy();return cb(blob);}
img.downsize(params.width,params.height,params.crop,params.preserve_headers);};img.onresize=function(){cb(this.getAsBlob(blob.type,params.quality));this.destroy();};img.onerror=function(){cb(blob);};img.load(blob);}catch(ex){cb(blob);}}
function setOption(option,value,init){var self=this,reinitRequired=false;function _setOption(option,value,init){var oldValue=settings[option];switch(option){case'max_file_size':if(option==='max_file_size'){settings.max_file_size=settings.filters.max_file_size=value;}
break;case'chunk_size':if(value=plupload.parseSize(value)){settings[option]=value;settings.send_file_name=true;}
break;case'multipart':settings[option]=value;if(!value){settings.send_file_name=true;}
break;case'unique_names':settings[option]=value;if(value){settings.send_file_name=true;}
break;case'filters':if(plupload.typeOf(value)==='array'){value={mime_types:value};}
if(init){plupload.extend(settings.filters,value);}else{settings.filters=value;}
if(value.mime_types){settings.filters.mime_types.regexp=(function(filters){var extensionsRegExp=[];plupload.each(filters,function(filter){plupload.each(filter.extensions.split(/,/),function(ext){if(/^\s*\*\s*$/.test(ext)){extensionsRegExp.push('\\.*');}else{extensionsRegExp.push('\\.'+ext.replace(new RegExp('['+('/^$.*+?|()[]{}\\'.replace(/./g,'\\$&'))+']','g'),'\\$&'));}});});return new RegExp('('+extensionsRegExp.join('|')+')$','i');}(settings.filters.mime_types));}
break;case'resize':if(init){plupload.extend(settings.resize,value,{enabled:true});}else{settings.resize=value;}
break;case'prevent_duplicates':settings.prevent_duplicates=settings.filters.prevent_duplicates=!!value;break;case'container':case'browse_button':case'drop_element':value='container'===option?plupload.get(value):plupload.getAll(value);case'runtimes':case'multi_selection':settings[option]=value;if(!init){reinitRequired=true;}
break;default:settings[option]=value;}
if(!init){self.trigger('OptionChanged',option,value,oldValue);}}
if(typeof(option)==='object'){plupload.each(option,function(value,option){_setOption(option,value,init);});}else{_setOption(option,value,init);}
if(init){settings.required_features=normalizeCaps(plupload.extend({},settings));preferred_caps=normalizeCaps(plupload.extend({},settings,{required_features:true}));}else if(reinitRequired){self.trigger('Destroy');initControls.call(self,settings,function(inited){if(inited){self.runtime=o.Runtime.getInfo(getRUID()).type;self.trigger('Init',{runtime:self.runtime});self.trigger('PostInit');}else{self.trigger('Error',{code:plupload.INIT_ERROR,message:plupload.translate('Init error.')});}});}}
function onBeforeUpload(up,file){if(up.settings.unique_names){var matches=file.name.match(/\.([^.]+)$/),ext="part";if(matches){ext=matches[1];}
file.target_name=file.id+'.'+ext;}}
function onUploadFile(up,file){var url=up.settings.url,chunkSize=up.settings.chunk_size,retries=up.settings.max_retries,features=up.features,offset=0,blob;if(file.loaded){offset=file.loaded=chunkSize?chunkSize*Math.floor(file.loaded / chunkSize):0;}
function handleError(){if(retries-->0){delay(uploadNextChunk,1000);}else{file.loaded=offset;up.trigger('Error',{code:plupload.HTTP_ERROR,message:plupload.translate('HTTP Error.'),file:file,response:xhr.responseText,status:xhr.status,responseHeaders:xhr.getAllResponseHeaders()});}}
function uploadNextChunk(){var chunkBlob,formData,args={},curChunkSize;if(file.status!==plupload.UPLOADING||up.state===plupload.STOPPED){return;}
if(up.settings.send_file_name){args.name=file.target_name||file.name;}
if(chunkSize&&features.chunks&&blob.size>chunkSize){curChunkSize=Math.min(chunkSize,blob.size-offset);chunkBlob=blob.slice(offset,offset+curChunkSize);}else{curChunkSize=blob.size;chunkBlob=blob;}
if(chunkSize&&features.chunks){if(up.settings.send_chunk_number){args.chunk=Math.ceil(offset / chunkSize);args.chunks=Math.ceil(blob.size / chunkSize);}else{args.offset=offset;args.total=blob.size;}}
xhr=new o.XMLHttpRequest();if(xhr.upload){xhr.upload.onprogress=function(e){file.loaded=Math.min(file.size,offset+e.loaded);up.trigger('UploadProgress',file);};}
xhr.onload=function(){if(xhr.status>=400){handleError();return;}
retries=up.settings.max_retries;if(curChunkSize<blob.size){chunkBlob.destroy();offset+=curChunkSize;file.loaded=Math.min(offset,blob.size);up.trigger('ChunkUploaded',file,{offset:file.loaded,total:blob.size,response:xhr.responseText,status:xhr.status,responseHeaders:xhr.getAllResponseHeaders()});if(o.Env.browser==='Android Browser'){up.trigger('UploadProgress',file);}}else{file.loaded=file.size;}
chunkBlob=formData=null;if(!offset||offset>=blob.size){if(file.size!=file.origSize){blob.destroy();blob=null;}
up.trigger('UploadProgress',file);file.status=plupload.DONE;up.trigger('FileUploaded',file,{response:xhr.responseText,status:xhr.status,responseHeaders:xhr.getAllResponseHeaders()});}else{delay(uploadNextChunk,1);}};xhr.onerror=function(){handleError();};xhr.onloadend=function(){this.destroy();xhr=null;};if(up.settings.multipart&&features.multipart){xhr.open("post",url,true);plupload.each(up.settings.headers,function(value,name){xhr.setRequestHeader(name,value);});formData=new o.FormData();plupload.each(plupload.extend(args,up.settings.multipart_params),function(value,name){formData.append(name,value);});formData.append(up.settings.file_data_name,chunkBlob);xhr.send(formData,{runtime_order:up.settings.runtimes,required_caps:up.settings.required_features,preferred_caps:preferred_caps});}else{url=plupload.buildUrl(up.settings.url,plupload.extend(args,up.settings.multipart_params));xhr.open("post",url,true);xhr.setRequestHeader('Content-Type','application/octet-stream');plupload.each(up.settings.headers,function(value,name){xhr.setRequestHeader(name,value);});xhr.send(chunkBlob,{runtime_order:up.settings.runtimes,required_caps:up.settings.required_features,preferred_caps:preferred_caps});}}
blob=file.getSource();if(up.settings.resize.enabled&&runtimeCan(blob,'send_binary_string')&&!!~o.inArray(blob.type,['image/jpeg','image/png'])){resizeImage.call(this,blob,up.settings.resize,function(resizedBlob){blob=resizedBlob;file.size=resizedBlob.size;uploadNextChunk();});}else{uploadNextChunk();}}
function onUploadProgress(up,file){calcFile(file);}
function onStateChanged(up){if(up.state==plupload.STARTED){startTime=(+new Date());}else if(up.state==plupload.STOPPED){for(var i=up.files.length-1;i>=0;i--){if(up.files[i].status==plupload.UPLOADING){up.files[i].status=plupload.QUEUED;calc();}}}}
function onCancelUpload(){if(xhr){xhr.abort();}}
function onFileUploaded(up){calc();delay(function(){uploadNext.call(up);},1);}
function onError(up,err){if(err.code===plupload.INIT_ERROR){up.destroy();}
else if(err.code===plupload.HTTP_ERROR){err.file.status=plupload.FAILED;calcFile(err.file);if(up.state==plupload.STARTED){up.trigger('CancelUpload');delay(function(){uploadNext.call(up);},1);}}}
function onDestroy(up){up.stop();plupload.each(files,function(file){file.destroy();});files=[];if(fileInputs.length){plupload.each(fileInputs,function(fileInput){fileInput.destroy();});fileInputs=[];}
if(fileDrops.length){plupload.each(fileDrops,function(fileDrop){fileDrop.destroy();});fileDrops=[];}
preferred_caps={};disabled=false;startTime=xhr=null;total.reset();}
settings={runtimes:o.Runtime.order,max_retries:0,chunk_size:0,multipart:true,multi_selection:true,file_data_name:'file',filters:{mime_types:[],prevent_duplicates:false,max_file_size:0},resize:{enabled:false,preserve_headers:true,crop:false},send_file_name:true,send_chunk_number:true};setOption.call(this,options,null,true);total=new plupload.QueueProgress();plupload.extend(this,{id:uid,uid:uid,state:plupload.STOPPED,features:{},runtime:null,files:files,settings:settings,total:total,init:function(){var self=this,opt,preinitOpt,err;preinitOpt=self.getOption('preinit');if(typeof(preinitOpt)=="function"){preinitOpt(self);}else{plupload.each(preinitOpt,function(func,name){self.bind(name,func);});}
bindEventListeners.call(self);plupload.each(['container','browse_button','drop_element'],function(el){if(self.getOption(el)===null){err={code:plupload.INIT_ERROR,message:plupload.translate("'%' specified, but cannot be found.")}
return false;}});if(err){return self.trigger('Error',err);}
if(!settings.browse_button&&!settings.drop_element){return self.trigger('Error',{code:plupload.INIT_ERROR,message:plupload.translate("You must specify either 'browse_button' or 'drop_element'.")});}
initControls.call(self,settings,function(inited){var initOpt=self.getOption('init');if(typeof(initOpt)=="function"){initOpt(self);}else{plupload.each(initOpt,function(func,name){self.bind(name,func);});}
if(inited){self.runtime=o.Runtime.getInfo(getRUID()).type;self.trigger('Init',{runtime:self.runtime});self.trigger('PostInit');}else{self.trigger('Error',{code:plupload.INIT_ERROR,message:plupload.translate('Init error.')});}});},setOption:function(option,value){setOption.call(this,option,value,!this.runtime);},getOption:function(option){if(!option){return settings;}
return settings[option];},refresh:function(){if(fileInputs.length){plupload.each(fileInputs,function(fileInput){fileInput.trigger('Refresh');});}
this.trigger('Refresh');},start:function(){if(this.state!=plupload.STARTED){this.state=plupload.STARTED;this.trigger('StateChanged');uploadNext.call(this);}},stop:function(){if(this.state!=plupload.STOPPED){this.state=plupload.STOPPED;this.trigger('StateChanged');this.trigger('CancelUpload');}},disableBrowse:function(){disabled=arguments[0]!==undef?arguments[0]:true;if(fileInputs.length){plupload.each(fileInputs,function(fileInput){fileInput.disable(disabled);});}
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];}}},addFile:function(file,fileName){var self=this,queue=[],filesAdded=[],ruid;function filterFile(file,cb){var queue=[];o.each(self.settings.filters,function(rule,name){if(fileFilters[name]){queue.push(function(cb){fileFilters[name].call(self,rule,file,function(res){cb(!res);});});}});o.inSeries(queue,cb);}
function resolveFile(file){var type=o.typeOf(file);if(file instanceof o.File){if(!file.ruid&&!file.isDetached()){if(!ruid){return false;}
file.ruid=ruid;file.connectRuntime(ruid);}
resolveFile(new plupload.File(file));}
else if(file instanceof o.Blob){resolveFile(file.getSource());file.destroy();}
else if(file instanceof plupload.File){if(fileName){file.name=fileName;}
queue.push(function(cb){filterFile(file,function(err){if(!err){files.push(file);filesAdded.push(file);self.trigger("FileFiltered",file);}
delay(cb,1);});});}
else if(o.inArray(type,['file','blob'])!==-1){resolveFile(new o.File(null,file));}
else if(type==='node'&&o.typeOf(file.files)==='filelist'){o.each(file.files,resolveFile);}
else if(type==='array'){fileName=null;o.each(file,resolveFile);}}
ruid=getRUID();resolveFile(file);if(queue.length){o.inSeries(queue,function(){if(filesAdded.length){self.trigger("FilesAdded",filesAdded);}});}},removeFile:function(file){var id=typeof(file)==='string'?file:file.id;for(var i=files.length-1;i>=0;i--){if(files[i].id===id){return this.splice(i,1)[0];}}},splice:function(start,length){var removed=files.splice(start===undef?0:start,length===undef?files.length:length);var restartRequired=false;if(this.state==plupload.STARTED){plupload.each(removed,function(file){if(file.status===plupload.UPLOADING){restartRequired=true;return false;}});if(restartRequired){this.stop();}}
this.trigger("FilesRemoved",removed);plupload.each(removed,function(file){file.destroy();});if(restartRequired){this.start();}
return removed;},dispatchEvent:function(type){var list,args,result;type=type.toLowerCase();list=this.hasEventListener(type);if(list){list.sort(function(a,b){return b.priority-a.priority;});args=[].slice.call(arguments);args.shift();args.unshift(this);for(var i=0;i<list.length;i++){if(list[i].fn.apply(list[i].scope,args)===false){return false;}}}
return true;},bind:function(name,fn,scope,priority){plupload.Uploader.prototype.bind.call(this,name,fn,priority,scope);},destroy:function(){this.trigger('Destroy');settings=total=null;this.unbindAll();}});};plupload.Uploader.prototype=o.EventTarget.instance;plupload.File=(function(){var filepool={};function PluploadFile(file){plupload.extend(this,{id:plupload.guid(),name:file.name||file.fileName,type:file.type||'',size:file.size||file.fileSize,origSize:file.size||file.fileSize,loaded:0,percent:0,status:plupload.QUEUED,lastModifiedDate:file.lastModifiedDate||(new Date()).toLocaleString(),getNative:function(){var file=this.getSource().getSource();return o.inArray(o.typeOf(file),['blob','file'])!==-1?file:null;},getSource:function(){if(!filepool[this.id]){return null;}
return filepool[this.id];},destroy:function(){var src=this.getSource();if(src){src.destroy();delete filepool[this.id];}}});filepool[this.id]=file;}
return PluploadFile;}());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;};};window.plupload=plupload;}(window,mOxie));