var BT = BT || {}; (function() { BT.Base64 = new Class( { Implements : [ Options, Events ], options : {}, initialize : function(a) { this.setOptions(a) }, keyString : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", UTF8Encode : function(b) { b = b.replace(/\x0d\x0a/g, "\x0a"); var a = ""; for ( var e = 0; e < b.length; e++) { var d = b.charCodeAt(e); if (d < 128) { a += String.fromCharCode(d) } else { if ((d > 127) && (d < 2048)) { a += String.fromCharCode((d >> 6) | 192); a += String.fromCharCode((d & 63) | 128) } else { a += String.fromCharCode((d >> 12) | 224); a += String.fromCharCode(((d >> 6) & 63) | 128); a += String.fromCharCode((d & 63) | 128) } } } return a }, UTF8Decode : function(a) { var b = ""; var d = 0; var e = c1 = c2 = 0; while (d < a.length) { e = a.charCodeAt(d); if (e < 128) { b += String.fromCharCode(e); d++ } else { if ((e > 191) && (e < 224)) { c2 = a.charCodeAt(d + 1); b += String.fromCharCode(((e & 31) << 6) | (c2 & 63)); d += 2 } else { c2 = a.charCodeAt(d + 1); c3 = a.charCodeAt(d + 2); b += String.fromCharCode(((e & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); d += 3 } } } return b }, base64Encode : function(c) { var a = ""; var k, h, f, j, g, e, d; var b = 0; c = this.UTF8Encode(c); while (b < c.length) { k = c.charCodeAt(b++); h = c.charCodeAt(b++); f = c.charCodeAt(b++); j = k >> 2; g = ((k & 3) << 4) | (h >> 4); e = ((h & 15) << 2) | (f >> 6); d = f & 63; if (isNaN(h)) { e = d = 64 } else { if (isNaN(f)) { d = 64 } } a = a + this.keyString.charAt(j) + this.keyString.charAt(g) + this.keyString.charAt(e) + this.keyString.charAt(d) } return a }, base64Decode : function(c) { var a = ""; var k, h, f; var j, g, e, d; var b = 0; c = c.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (b < c.length) { j = this.keyString.indexOf(c.charAt(b++)); g = this.keyString.indexOf(c.charAt(b++)); e = this.keyString.indexOf(c.charAt(b++)); d = this.keyString.indexOf(c.charAt(b++)); k = (j << 2) | (g >> 4); h = ((g & 15) << 4) | (e >> 2); f = ((e & 3) << 6) | d; a = a + String.fromCharCode(k); if (e != 64) { a = a + String.fromCharCode(h) } if (d != 64) { a = a + String.fromCharCode(f) } } a = this.UTF8Decode(a); return a } }) })();