(function(d){var e,c;function b(g,h){var f;if("FileReader" in window){f=new FileReader();f.readAsDataURL(g);f.onload=function(){h(f.result)}}else{return h(g.getAsDataURL())}}function a(l,n,k,f,m){var h,g,j,i;b(l,function(o){h=document.createElement("canvas");h.style.display="none";document.body.appendChild(h);g=h.getContext("2d");j=new Image();j.onload=function(){var s,p,q,r,t;i=Math.min(n/j.width,k/j.height);if(i<1){s=Math.round(j.width*i);p=Math.round(j.height*i);h.width=s;h.height=p;g.drawImage(j,0,0,s,p);t=new c();t.init(atob(o.substring(o.indexOf("base64,")+7)));r=t.APP1({width:s,height:p});o=h.toDataURL(f);o=o.substring(o.indexOf("base64,")+7);o=atob(o);if(r){t.init(o);t.setAPP1(r);o=t.getBinary()}h.parentNode.removeChild(h);m({success:true,data:o})}else{m({success:false})}};j.src=o})}d.runtimes.Html5=d.addRuntime("html5",{getFeatures:function(){var k,g,j,h,f,i=window;g=j=h=f=false;if(i.XMLHttpRequest){k=new XMLHttpRequest();j=!!k.upload;g=!!(k.sendAsBinary||k.upload)}if(g){h=!!(File&&(File.prototype.getAsDataURL||i.FileReader)&&k.sendAsBinary);f=!!(File&&File.prototype.slice)}e=navigator.userAgent.indexOf("Safari")>0;return{html5:g,dragdrop:i.mozInnerScreenX!==undefined||f||e,jpgresize:h,pngresize:h,multipart:h||!!i.FileReader||!!i.FormData,progress:j,chunking:f||h}},init:function(i,j){var f={},g;function h(n){var l,k,m=[],o;for(k=0;k";document.getElementById(i.id+"_html5").onchange=function(){h(this.files);this.value=""}});i.bind("PostInit",function(){var k=document.getElementById(i.settings.drop_element);if(k){if(e){d.addEvent(k,"dragenter",function(o){var n,l,m;n=document.getElementById(i.id+"_drop");if(!n){n=document.createElement("input");n.setAttribute("type","file");n.setAttribute("id",i.id+"_drop");n.setAttribute("multiple","multiple");n.onchange=function(){h(this.files);this.value=""}}l=d.getPos(k,document.getElementById(i.settings.container));m=d.getSize(k);d.extend(n.style,{position:"absolute",display:"block",top:l.y+"px",left:l.x+"px",width:m.w+"px",height:m.h+"px",opacity:0});k.appendChild(n)});return}d.addEvent(k,"dragover",function(l){l.preventDefault()});d.addEvent(k,"drop",function(m){var l=m.dataTransfer;if(l&&l.files){h(l.files)}m.preventDefault()})}});i.bind("Refresh",function(k){var l,m,n;l=document.getElementById(i.settings.browse_button);m=d.getPos(l,document.getElementById(k.settings.container));n=d.getSize(l);d.extend(document.getElementById(i.id+"_html5_container").style,{top:m.y+"px",left:m.x+"px",width:n.w+"px",height:n.h+"px"})});i.bind("UploadFile",function(k,m){var n=k.settings,p,l;function o(q){var t=0,s=0;function r(){var A=q,H,I,D,E,F=0,w="----pluploadboundary"+d.guid(),z,B,x,y="--",G="\r\n",C="",v,u=k.settings.url;if(m.status==d.DONE||m.status==d.FAILED||k.state==d.STOPPED){return}E={name:m.target_name||m.name};if(n.chunk_size&&g.chunking){z=n.chunk_size;D=Math.ceil(m.size/z);B=Math.min(z,m.size-(t*z));if(typeof(q)=="string"){A=q.substring(t*z,t*z+B)}else{A=q.slice(t*z,B)}E.chunk=t;E.chunks=D}else{B=m.size}H=new XMLHttpRequest();I=H.upload;if(I){I.onprogress=function(J){m.loaded=Math.min(m.size,s+J.loaded-F);k.trigger("UploadProgress",m)}}if(!k.settings.multipart||!g.multipart){u=d.buildUrl(k.settings.url,E)}else{E.name=m.target_name||m.name}H.open("post",u,true);H.onreadystatechange=function(){var J,L;if(H.readyState==4){try{J=H.status}catch(K){J=0}if(J>=400){k.trigger("Error",{code:d.HTTP_ERROR,message:"HTTP Error.",file:m,status:J})}else{if(D){L={chunk:t,chunks:D,response:H.responseText,status:J};k.trigger("ChunkUploaded",m,L);s+=B;if(L.cancelled){m.status=d.FAILED;return}m.loaded=Math.min(m.size,(t+1)*z)}else{m.loaded=m.size}k.trigger("UploadProgress",m);if(!D||++t>=D){m.status=d.DONE;k.trigger("FileUploaded",m,{response:H.responseText,status:J});p=q=f[m.id]=null}else{r()}}H=A=x=C=null}};d.each(k.settings.headers,function(K,J){H.setRequestHeader(J,K)});if(k.settings.multipart&&g.multipart){if(!H.sendAsBinary){x=new FormData();d.each(d.extend(E,k.settings.multipart_params),function(K,J){x.append(J,K)});x.append(k.settings.file_data_name,A);H.send(x);return}H.setRequestHeader("Content-Type","multipart/form-data; boundary="+w);d.each(d.extend(E,k.settings.multipart_params),function(K,J){C+=y+w+G+'Content-Disposition: form-data; name="'+J+'"'+G+G;C+=unescape(encodeURIComponent(K))+G});v=d.mimeTypes[m.name.replace(/^.+\.([^.]+)/,"$1")]||"application/octet-stream";C+=y+w+G+'Content-Disposition: form-data; name="'+k.settings.file_data_name+'"; filename="'+unescape(encodeURIComponent(m.name))+'"'+G+"Content-Type: "+v+G+G+A+G+y+w+y+G;F=C.length-A.length;A=C}else{H.setRequestHeader("Content-Type","application/octet-stream")}if(H.sendAsBinary){H.sendAsBinary(A)}else{H.send(A)}}r()}p=f[m.id];l=k.settings.resize;if(g.jpgresize){if(l&&/\.(png|jpg|jpeg)$/i.test(m.name)){a(p,l.width,l.height,/\.png$/i.test(m.name)?"image/png":"image/jpeg",function(q){if(q.success){m.size=q.data.length;o(q.data)}else{o(p.getAsBinary())}})}else{o(p.getAsBinary())}}else{o(p)}});j({success:true})}});c=function(){var h,i,x,r,s,m,q,t,C,o,z,v,j,B,f,A,y,k,g;function n(){var G=false,E;function H(J,L){var I=G?0:-8*(L-1),M=0,K;for(K=0;K>Math.abs(I+L*8))&255)}D(J,N,true)}return{II:function(I){if(I===f){return G}else{G=I}},init:function(I){E=I},SEGMENT:function(I,K,J){if(!arguments.length){return E}if(typeof K=="number"){return E.substr(parseInt(I,10),K)}D(I,K,J)},BYTE:function(I){return H(I,1)},SHORT:function(I){return H(I,2)},LONG:function(I,J){if(J===f){return H(I,4)}else{F(I,J,4)}},SLONG:function(I){var J=H(I,4);return(J>2147483647?J-4294967296:J)},STRING:function(I,J){var K="";for(J+=I;I4){G=C.LONG(G)+B}for(N=0;N4){G=C.LONG(G)+B}O[P]=C.STRING(G,I-1);continue;case 3:if(I>2){G=C.LONG(G)+B}for(N=0;N1){G=C.LONG(G)+B}for(N=0;N