(function(){var d=0,i=[],k={},g={},a={"<":"lt",">":"gt","&":"amp",'"':"quot","'":"#39"},j=/[<>&\"\']/g,b,c=window.setTimeout;function f(){this.returnValue=false}function h(){this.cancelBubble=true}(function(l){var m=l.split(/,/),n,p,o;for(n=0;n0){e.each(m,function(p,o){l[o]=p})}});return l},cleanName:function(l){var m,n;n=[/[\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(m=0;m0?"&":"?")+n}return m},each:function(o,p){var n,m,l;if(o){n=o.length;if(n===b){for(m in o){if(o.hasOwnProperty(m)){if(p(o[m],m)===false){return}}}}else{for(l=0;l1048576){return Math.round(l/1048576,1)+" MB"}if(l>1024){return Math.round(l/1024,1)+" KB"}return l+" b"},getPos:function(m,q){var r=0,p=0,t,s=document,n,o;m=m;q=q||s.body;function l(z){var v,w,u=0,A=0;if(z){w=z.getBoundingClientRect();v=s.compatMode==="CSS1Compat"?s.documentElement:s.body;u=w.left+v.scrollLeft;A=w.top+v.scrollTop}return{x:u,y:A}}if(m.getBoundingClientRect&&(navigator.userAgent.indexOf("MSIE")>0&&s.documentMode!==8)){n=l(m);o=l(q);return{x:n.x-o.x,y:n.y-o.y}}t=m;while(t&&t!=q&&t.nodeType){r+=t.offsetLeft||0;p+=t.offsetTop||0;t=t.offsetParent}t=m.parentNode;while(t&&t!=q&&t.nodeType){r-=t.scrollLeft||0;p-=t.scrollTop||0;t=t.parentNode}return{x:r,y:p}},getSize:function(l){return{w:l.clientWidth||l.offsetWidth,h:l.clientHeight||l.offsetHeight}},parseSize:function(l){var m;if(typeof(l)=="string"){l=/^([0-9]+)([mgk]+)$/.exec(l.toLowerCase().replace(/[^0-9mkg]/g,""));m=l[2];l=+l[1];if(m=="g"){l*=1073741824}if(m=="m"){l*=1048576}if(m=="k"){l*=1024}}return l},xmlEncode:function(l){return l?(""+l).replace(j,function(m){return a[m]?"&"+a[m]+";":m}):l},toArray:function(n){var m,l=[];for(m=0;m0?Math.ceil(r.uploaded/q.length*100):0}else{r.bytesPerSec=Math.ceil(r.loaded/((+new Date()-n||1)/1000));r.percent=r.size>0?Math.ceil(r.loaded/r.size*100):0}}e.extend(this,{state:e.STOPPED,features:{},files:q,settings:o,total:r,id:e.guid(),init:function(){var y=this,z,v,u,x=0,w;if(typeof(o.preinit)=="function"){o.preinit(y)}else{e.each(o.preinit,function(B,A){y.bind(A,B)})}o.page_url=o.page_url||document.location.pathname.replace(/\/[^\/]+$/g,"/");if(!/^(\w+:\/\/|\/)/.test(o.url)){o.url=o.page_url+o.url}o.chunk_size=e.parseSize(o.chunk_size);o.max_file_size=e.parseSize(o.max_file_size);y.bind("FilesAdded",function(A,D){var C,B,F=0,G,E=o.filters;if(E&&E.length){G=[];e.each(E,function(H){e.each(H.extensions.split(/,/),function(I){G.push("\\."+I.replace(new RegExp("["+("/^$.*+?|()[]{}\\".replace(/./g,"\\$&"))+"]","g"),"\\$&"))})});G=new RegExp(G.join("|")+"$","i")}for(C=0;Co.max_file_size){A.trigger("Error",{code:e.FILE_SIZE_ERROR,message:"File size error.",file:B});continue}q.push(B);F++}if(F){c(function(){y.trigger("QueueChanged");y.refresh()})}else{return false}});if(o.unique_names){y.bind("UploadFile",function(A,B){var D=B.name.match(/\.([^.]+)$/),C="tmp";if(D){C=D[1]}B.target_name=B.id+"."+C})}y.bind("UploadProgress",function(A,B){B.percent=B.size>0?Math.ceil(B.loaded/B.size*100):100;l()});y.bind("StateChanged",function(A){if(A.state==e.STARTED){n=(+new Date())}});y.bind("QueueChanged",l);y.bind("Error",function(A,B){if(B.file){B.file.status=e.FAILED;l();c(function(){p.call(y)})}});y.bind("FileUploaded",function(A,B){B.status=e.DONE;B.loaded=B.size;A.trigger("UploadProgress",B);c(function(){p.call(y)})});if(o.runtimes){v=[];w=o.runtimes.split(/\s?,\s?/);for(z=0;z=0;t--){if(q[t].id===u){return q[t]}}},removeFile:function(u){var t;for(t=q.length-1;t>=0;t--){if(q[t].id===u.id){return this.splice(t,1)[0]}}},splice:function(v,t){var u;u=q.splice(v===b?0:v,t===b?q.length:t);this.trigger("FilesRemoved",u);this.trigger("QueueChanged");return u},trigger:function(u){var w=m[u.toLowerCase()],v,t;if(w){t=Array.prototype.slice.call(arguments);t[0]=this;for(v=0;v=0;u--){if(w[u].func===v){w.splice(u,1)}}}}})};e.File=function(o,m,n){var l=this;l.id=o;l.name=m;l.size=n;l.loaded=0;l.percent=0;l.status=0};e.Runtime=function(){this.getFeatures=function(){};this.init=function(l,m){}};e.QueueProgress=function(){var l=this;l.size=0;l.loaded=0;l.uploaded=0;l.failed=0;l.queued=0;l.percent=0;l.bytesPerSec=0;l.reset=function(){l.size=l.loaded=l.uploaded=l.failed=l.queued=l.percent=l.bytesPerSec=0}};e.runtimes={};window.plupload=e})();(function(b){var c={};function a(j,f,m,l,d){var n,h,g,i;h=google.gears.factory.create("beta.canvas");try{h.decode(j);i=Math.min(f/h.width,m/h.height);if(i<1){h.resize(Math.round(h.width*i),Math.round(h.height*i));return h.encode(d,{quality:l/100})}}catch(k){}return j}b.runtimes.Gears=b.addRuntime("gears",{getFeatures:function(){return{dragdrop:true,jpgresize:true,pngresize:true,chunks:true,progress:true,multipart:true}},init:function(g,i){var h;if(!window.google||!google.gears){return i({success:false})}try{h=google.gears.factory.create("beta.desktop")}catch(f){return i({success:false})}function d(k){var j,e,l=[],m;for(e=0;e0;p=Math.ceil(l.size/m);if(!e){m=l.size;p=1}function j(){var v,x,s=o.settings.multipart,r=0,w={name:l.target_name||l.name},t=o.settings.url;function u(z){var y,E="----pluploadboundary"+b.guid(),B="--",D="\r\n",A,C;if(s){v.setRequestHeader("Content-Type","multipart/form-data; boundary="+E);y=google.gears.factory.create("beta.blobbuilder");b.each(b.extend(w,o.settings.multipart_params),function(G,F){y.append(B+E+D+'Content-Disposition: form-data; name="'+F+'"'+D+D);y.append(G+D)});C=b.mimeTypes[l.name.replace(/^.+\.([^.]+)/,"$1")]||"application/octet-stream";y.append(B+E+D+'Content-Disposition: form-data; name="'+o.settings.file_data_name+'"; filename="'+l.name+'"'+D+"Content-Type: "+C+D+D);y.append(z);y.append(D+B+E+B+D);A=y.getAsBlob();r=A.length-z.length;z=A}v.send(z)}if(l.status==b.DONE||l.status==b.FAILED||o.state==b.STOPPED){return}if(e){w.chunk=q;w.chunks=p}x=Math.min(m,l.size-(q*m));if(!s){t=b.buildUrl(o.settings.url,w)}v=google.gears.factory.create("beta.httprequest");v.open("POST",t);if(!s){v.setRequestHeader("Content-Disposition",'attachment; filename="'+l.name+'"');v.setRequestHeader("Content-Type","application/octet-stream")}b.each(o.settings.headers,function(z,y){v.setRequestHeader(y,z)});v.upload.onprogress=function(y){l.loaded=n+y.loaded-r;o.trigger("UploadProgress",l)};v.onreadystatechange=function(){var y;if(v.readyState==4){if(v.status==200){y={chunk:q,chunks:p,response:v.responseText,status:v.status};o.trigger("ChunkUploaded",l,y);if(y.cancelled){l.status=b.FAILED;return}n+=x;if(++q>=p){l.status=b.DONE;o.trigger("FileUploaded",l,{response:v.responseText,status:v.status})}else{j()}}else{o.trigger("Error",{code:b.HTTP_ERROR,message:"HTTP Error.",file:l,chunk:q,chunks:p,status:v.status})}}};if(q3){h.pop()}while(h.length<4){h.push(0)}i=o.split(".");while(i.length>4){i.pop()}do{q=parseInt(i[m],10);j=parseInt(h[m],10);m++}while(m8?"":0.01});k.className="plupload silverlight";if(l.settings.container){f=document.getElementById(l.settings.container);f.style.position="relative"}f.appendChild(k);for(g=0;g';function e(){return document.getElementById(l.id+"_silverlight").content.Upload}l.bind("Silverlight:Init",function(){var i,n={};l.bind("Silverlight:StartSelectFiles",function(o){i=[]});l.bind("Silverlight:SelectFile",function(o,r,p,q){var s;s=c.guid();n[s]=r;n[r]=s;i.push(new c.File(s,p,q))});l.bind("Silverlight:SelectSuccessful",function(){if(i.length){l.trigger("FilesAdded",i)}});l.bind("Silverlight:UploadChunkError",function(o,r,p,s,q){l.trigger("Error",{code:c.IO_ERROR,message:"IO Error.",details:q,file:o.getFile(n[r])})});l.bind("Silverlight:UploadFileProgress",function(o,s,p,r){var q=o.getFile(n[s]);if(q.status!=c.FAILED){q.size=r;q.loaded=p;o.trigger("UploadProgress",q)}});l.bind("Refresh",function(o){var p,q,r;p=document.getElementById(o.settings.browse_button);q=c.getPos(p,document.getElementById(o.settings.container));r=c.getSize(p);c.extend(document.getElementById(o.id+"_silverlight_container").style,{top:q.y+"px",left:q.x+"px",width:r.w+"px",height:r.h+"px"})});l.bind("Silverlight:UploadChunkSuccessful",function(o,r,p,u,t){var s,q=o.getFile(n[r]);s={chunk:p,chunks:u,response:t};o.trigger("ChunkUploaded",q,s);if(q.status!=c.FAILED){e().UploadNextChunk()}if(p==u-1){q.status=c.DONE;o.trigger("FileUploaded",q,{response:t})}});l.bind("Silverlight:UploadSuccessful",function(o,r,p){var q=o.getFile(n[r]);q.status=c.DONE;o.trigger("FileUploaded",q,{response:p})});l.bind("FilesRemoved",function(o,q){var p;for(p=0;p';function j(){return document.getElementById(g.id+"_flash")}function i(){if(m++>5000){l({success:false});return}if(!e){setTimeout(i,1)}}i();k=f=null;g.bind("Flash:Init",function(){var p={},o,n=g.settings.resize||{};e=true;j().setFileFilters(g.settings.filters,g.settings.multi_selection);g.bind("UploadFile",function(q,r){var s=q.settings;j().uploadFile(p[r.id],s.url,{name:r.target_name||r.name,mime:c.mimeTypes[r.name.replace(/^.+\.([^.]+)/,"$1")]||"application/octet-stream",chunk_size:s.chunk_size,width:n.width,height:n.height,quality:n.quality||90,multipart:s.multipart,multipart_params:s.multipart_params||{},file_data_name:s.file_data_name,format:/\.(jpg|jpeg)$/i.test(r.name)?"jpg":"png",headers:s.headers,urlstream_upload:s.urlstream_upload})});g.bind("Flash:UploadProcess",function(r,q){var s=r.getFile(p[q.id]);if(s.status!=c.FAILED){s.loaded=q.loaded;s.size=q.size;r.trigger("UploadProgress",s)}});g.bind("Flash:UploadChunkComplete",function(q,s){var t,r=q.getFile(p[s.id]);t={chunk:s.chunk,chunks:s.chunks,response:s.text};q.trigger("ChunkUploaded",r,t);if(r.status!=c.FAILED){j().uploadNextChunk()}if(s.chunk==s.chunks-1){r.status=c.DONE;q.trigger("FileUploaded",r,{response:s.text})}});g.bind("Flash:SelectFiles",function(q,t){var s,r,u=[],v;for(r=0;r0){q(++s,u)}else{j.status=a.DONE;m.trigger("FileUploaded",j,{response:w.value.body,status:v});if(v>=400){m.trigger("Error",{code:a.HTTP_ERROR,message:"HTTP Error.",file:j,status:v})}}}else{m.trigger("Error",{code:a.GENERIC_ERROR,message:"Generic Error.",file:j,details:w.error})}})}function p(s){j.size=s.size;if(k){e.FileAccess.chunk({file:s,chunkSize:k},function(v){if(v.success){var w=v.value,t=w.length;n=Array(t);for(var u=0;u0;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