
	/**
	*  UTF-8 data encode / decode
	*  http://www.webtoolkit.info/
	**/
	var Utf8 = {
		// public method for url encoding
		encode : function (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
			for (var n = 0; n < string.length; n++) {
				var c = string.charCodeAt(n);
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
			}
			return utftext;
		},
		// public method for url decoding
		decode : function (utftext) {
			var string = "";
			var i = 0;
			var c = c1 = c2 = 0;
			while ( i < utftext.length ) {
				c = this.winToAsciiCharCode(utftext.charCodeAt(i));
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				}
				else if((c > 191) && (c < 224)) {
					c2 = this.winToAsciiCharCode(utftext.charCodeAt(i+1));
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				}
				else {
					c2 = this.winToAsciiCharCode(utftext.charCodeAt(i+1));
					c3 = this.winToAsciiCharCode(utftext.charCodeAt(i+2));
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				}
			}
			return string;
		},
		// convert from Windows-1252 char code to ascii char codes
		winToAsciiCharCode : function (code)
		{
			switch(code) {
				case 8364: code = 128; break;
				case 8218: code = 130; break;
				case 402: code = 131; break;
				case 8222: code = 132; break;
				case 8230: code = 133; break;
				case 8224: code = 134; break;
				case 8225: code = 135; break;
				case 710: code = 136; break;
				case 8240: code = 137; break;
				case 352: code = 138; break;
				case 8249: code = 139; break;
				case 338: code = 140; break;
				case 381: code = 142; break;
				case 8216: code = 145; break;
				case 8217: code = 146; break;
				case 8220: code = 147; break;
				case 8221: code = 148; break;
				case 8226: code = 149; break;
				case 8211: code = 150; break;
				case 8212: code = 151; break;
				case 732: code = 152; break;
				case 8482: code = 153; break;
				case 353: code = 154; break;
				case 8250: code = 155; break;
				case 339: code = 156; break;
				case 382: code = 158; break;
				case 376: code = 159; break;
			}
			return code;
		}
	}
	/**
	*  END UTF-8 data encode / decode
	**/
