(function(){function append(name,method){if(!String.prototype[name])String.prototype[name]=method}append("decodeBase64",function(){if((this.length%4)==0){if(typeof(atob)!="undefined")return atob(this);else{var nBits,sDecoded=new Array(this.length/4),base64='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';for(var i=0;i>16,(nBits&0xff00)>>8,nBits&0xff)}sDecoded[sDecoded.length-1]=sDecoded[sDecoded.length-1].substring(0,3-((this.charCodeAt(i-2)==61)?2:(this.charCodeAt(i-1)==61?1:0)));return sDecoded.join("")}}else throw new Error("String length must be divisible by 4.")});append("encodeBase64",function(){if(typeof(btoa)!="undefined")return btoa(this);else{var base64=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'],sbin,pad=0,s=""+this;if((s.length%3)==1){s+=String.fromCharCode(0);s+=String.fromCharCode(0);pad=2}else if((s.length%3)==2){s+=String.fromCharCode(0);pad=1}var rslt=new Array(s.length/3),ri=0; for(var i=0;i>18)&0x3f]+base64[(sbin>>12)&0x3f]+base64[(sbin>>6)&0x3f]+base64[sbin&0x3f]);ri++}if(pad>0)rslt[rslt.length-1]=rslt[rslt.length-1].substr(0,4-pad)+((pad==2)?"==":(pad==1)?"=":"");return rslt.join("")}});append("decodeUTF8",function(){var str=this;str=str.replace(/[\u00c0-\u00df][\u0080-\u00bf]/g,function(c){var cc=(c.charCodeAt(0)&0x1f)<<6|c.charCodeAt(1)&0x3f;return String.fromCharCode(cc)});str=str.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g,function(c){var cc=(c.charCodeAt(0)&0x0f)<<12|(c.charCodeAt(1)&0x3f<<6)|c.charCodeAt(2)&0x3f;return String.fromCharCode(cc)});return str});append("encodeUTF8",function(){var str=this;str=str.replace(/[\u0080-\u07ff]/g,function(c){var cc=c.charCodeAt(0);return String.fromCharCode(0xc0|cc>>6,0x80|cc&0x3f)});str=str.replace(/[\u0800-\uffff]/g,function(c){var cc=c.charCodeAt(0);return String.fromCharCode(0xe0|cc>>12,0x80|cc>>6&0x3F,0x80|cc&0x3f)});return str})})();