
// version 0.10
String.prototype.typo = function(options)
{
	var text = this.toString();
	var entities = {"&quot;": "&#34;", "&amp;": "&#38;", "&apos;": "'", "&lt;": "&#60;", "&gt;": "&#62;", "&OElig;": "&#338;", "&oelig;": "&#339;",
"&Scaron;": "&#352;", "&scaron;": "&#353;", "&Yuml;": "&#376;", "&circ;": "&#710;", "&tilde;": "&#732;", "&ensp;": "&#8194;", "&emsp;": "&#8195;",
"&thinsp;": "&#8201;", "&zwnj;": "&#8204;", "&zwj;": "&#8205;", "&lrm;": "&#8206;", "&rlm;": "&#8207;", "&ndash;": "&#8211;", "&mdash;": "&#8212;",
"&lsquo;": "&#8216;", "&rsquo;": "&#8217;", "&sbquo;": "&#8218;", "&ldquo;": "&#8220;", "&rdquo;": "&#8221;", "&bdquo;": "&#8222;", "&dagger;": "&#8224;",
"&Dagger;": "&#8225;", "&permil;": "&#8240;", "&lsaquo;": "&#8249;", "&rsaquo;": "&#8250;", "&euro;": "&#8364;", "&fnof;": "&#402;", "&Alpha;": "&#913;",
"&Beta;": "&#914;", "&Gamma;": "&#915;", "&Delta;": "&#916;", "&Epsilon;": "&#917;", "&Zeta;": "&#918;", "&Eta;": "&#919;", "&Theta;": "&#920;", "&Iota;":
"&#921;", "&Kappa;": "&#922;", "&Lambda;": "&#923;", "&Mu;": "&#924;", "&Nu;": "&#925;", "&Xi;": "&#926;", "&Omicron;": "&#927;", "&Pi;": "&#928;",
"&Rho;": "&#929;", "&Sigma;": "&#931;", "&Tau;": "&#932;", "&Upsilon;": "&#933;", "&Phi;": "&#934;", "&Chi;": "&#935;", "&Psi;": "&#936;", "&Omega;":
"&#937;", "&alpha;": "&#945;", "&beta;": "&#946;", "&gamma;": "&#947;", "&delta;": "&#948;", "&epsilon;": "&#949;", "&zeta;": "&#950;", "&eta;": "&#951;",
"&theta;": "&#952;", "&iota;": "&#953;", "&kappa;": "&#954;", "&lambda;": "&#955;", "&mu;": "&#956;", "&nu;": "&#957;", "&xi;": "&#958;", "&omicron;":
"&#959;", "&pi;": "&#960;", "&rho;": "&#961;", "&sigmaf;": "&#962;", "&sigma;": "&#963;", "&tau;": "&#964;", "&upsilon;": "&#965;", "&phi;": "&#966;",
"&chi;": "&#967;", "&psi;": "&#968;", "&omega;": "&#969;", "&thetasym;": "&#977;", "&upsih;": "&#978;", "&piv;": "&#982;", "&bull;": "&#8226;", "&hellip;":
"&#8230;", "&prime;": "&#8242;", "&Prime;": "&#8243;", "&oline;": "&#8254;", "&frasl;": "&#8260;", "&weierp;": "&#8472;", "&image;": "&#8465;", "&real;":
"&#8476;", "&trade;": "&#8482;", "&alefsym;": "&#8501;", "&larr;": "&#8592;", "&uarr;": "&#8593;", "&rarr;": "&#8594;", "&darr;": "&#8595;", "&harr;":
"&#8596;", "&crarr;": "&#8629;", "&lArr;": "&#8656;", "&uArr;": "&#8657;", "&rArr;": "&#8658;", "&dArr;": "&#8659;", "&hArr;": "&#8660;", "&forall;":
"&#8704;", "&part;": "&#8706;", "&exist;": "&#8707;", "&empty;": "&#8709;", "&nabla;": "&#8711;", "&isin;": "&#8712;", "&notin;": "&#8713;", "&ni;":
"&#8715;", "&prod;": "&#8719;", "&sum;": "&#8721;", "&minus;": "&#8722;", "&lowast;": "&#8727;", "&radic;": "&#8730;", "&prop;": "&#8733;", "&infin;":
"&#8734;", "&ang;": "&#8736;", "&and;": "&#8743;", "&or;": "&#8744;", "&cap;": "&#8745;", "&cup;": "&#8746;", "&int;": "&#8747;", "&there4;": "&#8756;",
"&sim;": "&#8764;", "&cong;": "&#8773;", "&asymp;": "&#8776;", "&ne;": "&#8800;", "&equiv;": "&#8801;", "&le;": "&#8804;", "&ge;": "&#8805;", "&sub;":
"&#8834;", "&sup;": "&#8835;", "&nsub;": "&#8836;", "&sube;": "&#8838;", "&supe;": "&#8839;", "&oplus;": "&#8853;", "&otimes;": "&#8855;", "&perp;":
"&#8869;", "&sdot;": "&#8901;", "&lceil;": "&#8968;", "&rceil;": "&#8969;", "&lfloor;": "&#8970;", "&rfloor;": "&#8971;", "&lang;": "&#9001;", "&rang;":
"&#9002;", "&loz;": "&#9674;", "&spades;": "&#9824;", "&clubs;": "&#9827;", "&hearts;": "&#9829;", "&diams;": "&#9830;", "&nbsp;": "&#160;", "&iexcl;":
"&#161;", "&cent;": "&#162;", "&pound;": "&#163;", "&curren;": "&#164;", "&yen;": "&#165;", "&brvbar;": "&#166;", "&sect;": "&#167;", "&uml;": "&#168;",
"&copy;": "&#169;", "&ordf;": "&#170;", "&laquo;": "&#171;", "&not;": "&#172;", "&shy;": "&#173;", "&reg;": "&#174;", "&macr;": "&#175;", "&deg;":
"&#176;", "&plusmn;": "&#177;", "&sup2;": "&#178;", "&sup3;": "&#179;", "&acute;": "&#180;", "&micro;": "&#181;", "&para;": "&#182;", "&middot;": "&#183;",
"&cedil;": "&#184;", "&sup1;": "&#185;", "&ordm;": "&#186;", "&raquo;": "&#187;", "&frac14;": "&#188;", "&frac12;": "&#189;", "&frac34;": "&#190;",
"&iquest;": "&#191;", "&Agrave;": "&#192;", "&Aacute;": "&#193;", "&Acirc;": "&#194;", "&Atilde;": "&#195;", "&Auml;": "&#196;", "&Aring;": "&#197;",
"&AElig;": "&#198;", "&Ccedil;": "&#199;", "&Egrave;": "&#200;", "&Eacute;": "&#201;", "&Ecirc;": "&#202;", "&Euml;": "&#203;", "&Igrave;": "&#204;",
"&Iacute;": "&#205;", "&Icirc;": "&#206;", "&Iuml;": "&#207;", "&ETH;": "&#208;", "&Ntilde;": "&#209;", "&Ograve;": "&#210;", "&Oacute;": "&#211;",
"&Ocirc;": "&#212;", "&Otilde;": "&#213;", "&Ouml;": "&#214;", "&times;": "&#215;", "&Oslash;": "&#216;", "&Ugrave;": "&#217;", "&Uacute;": "&#218;",
"&Ucirc;": "&#219;", "&Uuml;": "&#220;", "&Yacute;": "&#221;", "&THORN;": "&#222;", "&szlig;": "&#223;", "&agrave;": "&#224;", "&aacute;": "&#225;",
"&acirc;": "&#226;", "&atilde;": "&#227;", "&auml;": "&#228;", "&aring;": "&#229;", "&aelig;": "&#230;", "&ccedil;": "&#231;", "&egrave;": "&#232;",
"&eacute;": "&#233;", "&ecirc;": "&#234;", "&euml;": "&#235;", "&igrave;": "&#236;", "&iacute;": "&#237;", "&icirc;": "&#238;", "&iuml;": "&#239;",
"&eth;": "&#240;", "&ntilde;": "&#241;", "&ograve;": "&#242;", "&oacute;": "&#243;", "&ocirc;": "&#244;", "&otilde;": "&#245;", "&ouml;": "&#246;",
"&divide;": "&#247;", "&oslash;": "&#248;", "&ugrave;": "&#249;", "&uacute;": "&#250;", "&ucirc;": "&#251;", "&uuml;": "&#252;", "&yacute;": "&#253;",
"&thorn;": "&#254;", "&yuml;": "&#255;"};
	var lang = "en";
	if (!options) {
		options = {
            // ignoreTags: false,
			paragraphs: false,
			abbr: false,
			nobr: false,
			names: false,
			spaces: false
            // ligatures: false
		};
	}

	//convert real chars to entities
	var esc = escape(text);
	esc = "'" + esc.replace(/\%([A-F][\w]|u[\w]{4})/gi, "' + conv('$1') + '") + "'";
	esc = eval(esc);
	function conv(w)
	{
		var wd = "0x" + w.replace(/[%u]/g, "");
		wd = +wd;
		/*if (wd >= 1040 && wd < 1106) {
			lang = "ru";
			return "%" + w; //fix for russian letters :)
		}
		else*/
		return "&#" + wd + ";";
	}
	text = unescape(esc);

	text = text.replace(/\<{3}/g, "&#8920;");
	text = text.replace(/\>{3}/g, "&#8921;");
	// hide email addresses
	text = text.replace(/(\s|^)[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})(\s|$)/gi, function(w){return w.replace(/\./g,"%2E");});
	// hide URL addresses
	text = text.replace(/(\s|^|@|:)((http|https|ftp)\:\/\/)?([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(\/[^\/][a-zA-Z0-9\.\,\?\'\\\/\+&%\$#\=~_\-@]*)*(\s|$)/gi, function(w){return w.replace(/\./g,"%2E");});
	if (options.ignoreTags) {
		text = text.replace(/\<\/?(\w+)(\s*\w*\s*=\s*(\"[^\"]*\"|\'[^\']\'|[^\>]*))*|\/?>/gi, function(w){return escape(w).replace(/\./g,"%2E");});
	}
	// Sup
	var sup = ["&#8304;", "&#185;", "&#178;", "&#179;", "&#8308;", "&#8309;", "&#8310;", "&#8311;", "&#8312;", "&#8313;"];
	var newtext = "'" + text.replace(/'/g, "\\'").replace(/(?=[^\d\s])(\d)\b/g, "' + sup[$1] + '") + "'";
	text = eval(newtext);
	//replace all existing entities to number ones
	for (ch in entities) {
	    text = text.replace(new RegExp("\\" + ch, "g"), entities[ch]);
	}

	text = text.replace(/([\.\,\:])([^\.\,\:\;\)\]\s0-9\'\"])([^\.])/gi, "$1 $2$3");
	text = text.replace(/\&([^#])/gi, "&#38;$1");
	if (!options.spaces) {
		text = text.replace(/\&#38;\s+\b/gi, "&#38;&#160;");
	}

	//arrows
	text = text.replace(/([\s\'\"\(\)\,\.]+|^)-(\%3E|>)(?=[\s\'\"\(\)\,\.]+|$)/gi, "$1&#8594;");
	text = text.replace(/([\s\'\"\(\)\,\.]+|^)<-(?=[\s\'\"\(\)\,\.]+|$)/gi, "$1&#8592;");
	text = text.replace(/([\s\'\"\(\)\,\.]+|^)<-(\%3E|>)(?=[\s\'\"\(\)\,\.]+|$)/gi, "$1&#8596;");
	text = text.replace(/([\s\'\"\(\)\,\.]+|^)=(\%3E|>)(?=[\s\'\"\(\)\,\.]+|$)/gi, "$1&#8658;");
	text = text.replace(/([\s\'\"\(\)\,\.]+|^)<=(?=[\s\'\"\(\)\,\.]+|$)/gi, "$1&#8656;");
	text = text.replace(/([\s\'\"\(\)\,\.]+|^)<=(\%3E|>)(?=[\s\'\"\(\)\,\.]+|$)/gi, "$1&#8660;");

	text = text.replace(/\</gi, "&#8249;");
	text = text.replace(/\>/gi, "&#8250;");

	text = text.replace(/(\s|^)\-(\d)/gi, "$1&#8722;$2");
	text = text.replace(/(\b[^%]\d+)C\b/g, "$1&#8451;");
	text = text.replace(/(\b[^%]\d+)F\b/g, "$1&#8457;");
	text = text.replace(/(\b\d+)c\b/g, "$1&#162;");
	text = text.replace(/\bNo(?=\.\s*\d|\b\s*\d|\d)/g, "&#8470; ");
	
	if (options.abbr) {
		text = text.replace(/\b(XML)\b/g, '<abbr title="Extensible Markup Language">$1</abbr>');
		text = text.replace(/\b(XHTML)\b/g, '<abbr title="Extensible HyperText Markup Language">$1</abbr>');
		text = text.replace(/\b(DOM)\b/g, '<acronym title="Document Object Model">$1</acronym>');
		text = text.replace(/\b(W3C)\b/g, '<abbr title="World Wide Web Consortium">$1</abbr>');
		text = text.replace(/\b(HTML)\b/g, '<abbr title="HyperText Markup Language">$1</abbr>');
		text = text.replace(/\b(CSS)\b/g, '<abbr title="Cascading Style Sheets">$1</abbr>');
		text = text.replace(/\b(XSL)\b/g, '<abbr title="Extensible Stylesheet Language">$1</abbr>');
		text = text.replace(/\b(XSLT)\b/g, '<abbr title="Extensible Stylesheet Language Transformations">$1</abbr>');
		text = text.replace(/\b(WML)\b/g, '<abbr title="Wireless Markup Language">$1</abbr>');
		text = text.replace(/\b(WAP)\b/g, '<abbr title="Wireless Application Protocol">$1</abbr>');
		text = text.replace(/\b(UML)\b/g, '<abbr title="Unified Modeling Language">$1</abbr>');
		text = text.replace(/\b(URL)\b/g, '<abbr title="Uniform Resource Locator">$1</abbr>');
		text = text.replace(/\b(URI)\b/g, '<abbr title="Uniform Resource Identifier">$1</abbr>');
		text = text.replace(/\b(SMS)\b/g, '<abbr title="Short Message Service">$1</abbr>');
		text = text.replace(/\b(MMS)\b/g, '<abbr title="Multimedia Message Service">$1</abbr>');
		text = text.replace(/\b(VHS)\b/g, '<abbr title="Video Home System">$1</abbr>');
		text = text.replace(/\b(EU)\b/g, '<abbr title="European Union">$1</abbr>');
		text = text.replace(/\b(USSR)\b/g, '<abbr title="Union of Soviet Socialist Republics">$1</abbr>');
		text = text.replace(/\b(USA)\b/g, '<abbr title="United States of America">$1</abbr>');
		text = text.replace(/\b(NSW)\b/g, '<abbr title="New South Wales">$1</abbr>');
		text = text.replace(/\b(MTV)\b/g, '<abbr title="Music Television">$1</abbr>');
		text = text.replace(/\b(GPRS)\b/g, '<abbr title="General Packet Radio Service">$1</abbr>');
		text = text.replace(/\b(CDMA)\b/g, '<abbr title="Code Division Multiple Access">$1</abbr>');
		text = text.replace(/\b(DB)\b/g, '<abbr title="DataBase">$1</abbr>');
		text = text.replace(/\b(UA)\b/g, '<abbr title="User Agent">$1</abbr>');
		text = text.replace(/\b(UI)\b/g, '<abbr title="User Interface">$1</abbr>');
		text = text.replace(/\b(JS)\b/g, '<abbr title="JavaScript">$1</abbr>');
		text = text.replace(/\b(IA)\b/g, '<abbr title="Information Architecture">$1</abbr>');
		text = text.replace(/\b(SIM)\b/g, '<acronym title="Subscriber Identity Module">$1</acronym>');
		text = text.replace(/\b(CSD)\b/g, '<abbr title="Circuit Switched Data">$1</abbr>');
		text = text.replace(/\b(PC)\b/g, '<abbr title="Personal Computer">$1</abbr>');
		text = text.replace(/\b(K[Bb])\b/g, '<abbr title="Kilobyte">$1</abbr>');
		text = text.replace(/\b(M[Bb])\b/g, '<abbr title="Megabyte">$1</abbr>');
		text = text.replace(/\b(3G)\b/g, '<abbr title="3rd Generation">$1</abbr>');
		text = text.replace(/\b(RSS)\b/g, '<abbr title="Really Simple Syndication">$1</abbr>');
		text = text.replace(/\b([A-Z][\dA-Z]+)\b(?=[^<])/g, '<abbr>$1</abbr>');
	}

	text = text.replace(/(\d{2,})\-(\d{2,})(?=\s|$)/gi, "$1" + ((lang == "en")?"&#8211;":"&#8212;") + "$2");

	if (options.nobr) {
		if (options.nobr == "nobr") {
			text = text.replace(/(\b\w{1,6})((\-(\w*\b))+)/gi, "<nobr>$1$2</nobr>");
		} else {
			text = text.replace(/(\b\w{1,6})((\-(\w*\b))+)/gi, "<span class=\"nobr\">$1$2</span>");
		}
	}

	if (!options.spaces) {
		text = text.replace(/\s+(\w{1,4}[\.\!\?]*)\s*\n/gi, "&#160;$1\n");
	}
	if (options.paragraphs) {
		if (options.paragraphs.match(/(div|p|li)/gi)) {
			text = text.replace(/(^|\n)(.*?)(?=\n|$)/gi, "<" + options.paragraphs + ">$2</" + options.paragraphs + ">%0A");
		} else {
			if (options.paragraphs == "br") {
				text = text.replace(/(^|\n)(.*?)(?=\n|$)/gi, "$2<br />%0A");
			} else {
				text = text.replace(/(^|\n)(.*?)(?=\n|$)/gi, "$2%0A");
			}
		}
	}

	//hide new tags
	text = text.replace(/\<\/?(\w+)(\s*\w*\s*=\s*(\"[^\"]*\"|\'[^\']\'|[^\>]*))*|\/?>/gi, function(w){return escape(w).replace(/\./g,"%2E");});

	// apos
	text = text.replace(/(\w)\'(\w)/gi, "$1&#8217;$2");
	// single quotes
	text = text.replace(/(?!\w)\'(?=\b|[\"\'\(\[\%])/gi, "&#8216;");
	text = text.replace(/(?=\b|[\"\'\(\)\.\,\[\]\:\;\%])\'(?=[^\w]|$)/gi, "&#8217;");

	//double quotes
	text = text.replace(/(?=[\b\.\,\)\]\;\:])\"{2}(?=[^\w]|$)/gi, (lang == "en")?"&#8221;":"&#187;");
	text = text.replace(/(?!\w)\"(?=[\w\&\"\'\(\[\%])/gi, (lang == "en")?"&#8220;":"&#171;");
	text = text.replace(/(?=[\w\"\'\(\)\.\,\[\]\:\;\%])\"(?=[^\w]|$)/gi, (lang == "en")?"&#8221;":"&#187;");

	text = text.replace(/\s+/gi, " ");

	if (!options.spaces) {
		text = text.replace(/(^|\%3E)\-+\s+/gi, "$1" + ((lang == "en")?"&#8212;":"&#8212;"));
		text = text.replace(/\s+\-+\s+/gi, ((lang == "en")?"&#8212;":"&#160;&#8212; "));
		if (lang == "ru") {
			text = text.replace(/(?=\s|^)(.{1,3})\s/gi, "$1&#160;");
		} else {
/*			text = text.replace(/(\b(a|in|of|an|on|or|is|at|to|by|the|via))\s/gi, "$1&#160;");*/
			text = text.replace(/(\b(a|an|is|the))\s/gi, "$1&#160;");
		}
		text = text.replace(/\s+(are)\b/gi, "&#160;$1");
	} else {
		text = text.replace(/(\s+|^|\%3E)\-+\s+/gi, "$1" + ((lang == "en")?"&#8211;":"&#8212;") + " ");
	}
	text = text.replace(/(\d{1,2}) (January|February|March|April|May|June|July|August|September|October|November|December)/gi, "$1&#160;$2");
	text = text.replace(/\.{3}/gi, "&#8230;");
	text = text.replace(/\.{2}/gi, "&#8229;");
	text = text.replace(/\(c\)/gi, "&#169;");
	text = text.replace(/\(r\)/gi, "&#174;");
	text = text.replace(/\(\?\)/gi, "&#9072;");
	text = text.replace(/\(tm\)/gi, "&#8482;");
	text = text.replace(/TM(\s|$)/g, "&#8482;$1");
	text = text.replace(/\(x\)/gi, "&#8855;");
	text = text.replace(/\(\+\)/gi, "&#8853;");
	text = text.replace(/\+\/\-/gi, "&#177;");
	text = text.replace(/([\s,;:\)\]]|^)1\/4/gi, "&#188;");
	text = text.replace(/([\s,;:\)\]]|^)1\/2/gi, "&#189;");
	text = text.replace(/([\s,;:\)\]]|^)3\/4/gi, "&#190;");
	text = text.replace(/([\s,;:\)\]]|^)1\/3/gi, "&#8531;");
	text = text.replace(/([\s,;:\)\]]|^)2\/3/gi, "&#8532;");
	text = text.replace(/([\s,;:\)\]]|^)1\/5/gi, "&#8533;");
	text = text.replace(/([\s,;:\)\]]|^)2\/5/gi, "&#8534;");
	text = text.replace(/([\s,;:\)\]]|^)3\/5/gi, "&#8535;");
	text = text.replace(/([\s,;:\)\]]|^)4\/5/gi, "&#8536;");
	text = text.replace(/([\s,;:\)\]]|^)1\/6/gi, "&#8537;");
	text = text.replace(/([\s,;:\)\]]|^)5\/6/gi, "&#8538;");
	text = text.replace(/([\s,;:\)\]]|^)1\/8/gi, "&#8539;");
	text = text.replace(/([\s,;:\)\]]|^)3\/8/gi, "&#8540;");
	text = text.replace(/([\s,;:\)\]]|^)5\/8/gi, "&#8541;");
	text = text.replace(/([\s,;:\)\]]|^)7\/8/gi, "&#8542;");
	text = text.replace(/([\s,;:\)\]]|^)a\/c/g, "&#8448;");
	text = text.replace(/([\s,;:\)\]]|^)a\/s/g, "&#8449;");
	text = text.replace(/([\s,;:\)\]]|^)c\/o/g, "&#8453;");
	text = text.replace(/([\s,;:\)\]]|^)c\/u/g, "&#8454;");
	text = text.replace(/([\s,;:\)\]]|^)\(1\)/g, "&#9312;");
	text = text.replace(/([\s,;:\)\]]|^)\(2\)/g, "&#9313;");
	text = text.replace(/([\s,;:\)\]]|^)\(3\)/g, "&#9314;");
	text = text.replace(/([\s,;:\)\]]|^)\(4\)/g, "&#9315;");
	text = text.replace(/([\s,;:\)\]]|^)\(5\)/g, "&#9316;");
	text = text.replace(/([\s,;:\)\]]|^)\(6\)/g, "&#9317;");
	text = text.replace(/([\s,;:\)\]]|^)\(7\)/g, "&#9318;");
	text = text.replace(/([\s,;:\)\]]|^)\(8\)/g, "&#9319;");
	text = text.replace(/([\s,;:\)\]]|^)\(9\)/g, "&#9320;");
	text = text.replace(/([\s,;:\)\]]|^)\(10\)/g, "&#9321;");
	text = text.replace(/([\s,;:\)\]]|^)\(11\)/g, "&#9322;");
	text = text.replace(/([\s,;:\)\]]|^)\(12\)/g, "&#9323;");
	text = text.replace(/([\s,;:\)\]]|^)\(13\)/g, "&#9324;");
	text = text.replace(/([\s,;:\)\]]|^)\(14\)/g, "&#9325;");
	text = text.replace(/([\s,;:\)\]]|^)\(15\)/g, "&#9326;");
	text = text.replace(/([\s,;:\)\]]|^)\(16\)/g, "&#9327;");
	text = text.replace(/([\s,;:\)\]]|^)\(17\)/g, "&#9328;");
	text = text.replace(/([\s,;:\)\]]|^)\(18\)/g, "&#9329;");
	text = text.replace(/([\s,;:\)\]]|^)\(19\)/g, "&#9330;");
	text = text.replace(/([\s,;:\)\]]|^)\(20\)/g, "&#9331;");
	//ligatures
	// if (!options.ligatures) {
	// 	text = text.replace(/fi/g, "&#64257;");
	// 	text = text.replace(/fl/g, "&#64258;");
	// 	text = text.replace(/IJ/g, "&#306;");
	// 	text = text.replace(/ij/g, "&#307;");
	// }
	text = text.replace(/\*{3}/gi, "&#8258;");
	text = text.replace(/\*{2}/gi, "&#8273;");
	text = text.replace(/\!\!/gi, "&#8252;");
	text = text.replace(/\%o{2}(\s|$)/g, "&#8241;$1");
	text = text.replace(/\%o(\s|$)/g, "&#8240;$1");
	text = text.replace(/(&#160;|\s|^)+[\:\;]\-?[\)D](\s|$)+/g, "$1&#9786;$2");
	text = text.replace(/(&#160;|\s|^)+[\:\;]\-?\((\s|$)+/g, "$1&#9785;$2");
	text = text.replace(/(\d)x(\d)/gi, "$1&#160;&#215;&#160;$2");
	//special symbols
	text = text.replace(/\{star\}/gi, "&#9733;");
	text = text.replace(/\{command\}/gi, "&#8984;");
	text = text.replace(/\{alt\}/gi, "&#8997;");
	text = text.replace(/\{del(ete)?\}/gi, "&#8998;");
	text = text.replace(/\{backspace\}/gi, "&#9003;");
	text = text.replace(/\{c(on)?tro?l\}/gi, "&#8963;");
	text = text.replace(/\{wait\}/gi, "&#8987;");
	text = text.replace(/\{check\}/gi, "&#10003;");
	text = text.replace(/\{apple\}/gi, "&#63743;");
	text = text.replace(/\{shift\}/gi, "&#8679;");
	text = text.replace(/\{tab\}/gi, "&#8677;");
	text = text.replace(/\{back-?tab\}/gi, "&#8676;");
	text = text.replace(/\{left\}/gi, "&#8672;");
	text = text.replace(/\{up\}/gi, "&#8673;");
	text = text.replace(/\{right\}/gi, "&#8674;");
	text = text.replace(/\{down\}/gi, "&#8675;");
	text = text.replace(/\{esc\}/gi, "&#9099;");
	text = text.replace(/\{home\}/gi, "&#8598;");
	text = text.replace(/\{end\}/gi, "&#8600;");
	text = text.replace(/\{Pa?ge?\s?Up\}/gi, "&#8670;");
	text = text.replace(/\{Pa?ge?\s?Down\}/gi, "&#8671;");
	text = text.replace(/\{return\}/gi, "&#8617;");
	text = text.replace(/\{eject\}/gi, "&#9167;");
	text = text.replace(/\{phone\}/gi, "&#9742;");
	text = text.replace(/\{mail\}/gi, "&#9993;");
	text = text.replace(/\{cross\}/gi, "&#10007;");
	text = text.replace(/\{trash\}/gi, "&#9842;");
	text = text.replace(/\{russian\}/gi, "&#9773;");
	text = text.replace(/\{peace\}/gi, "&#9774;");
	text = text.replace(/\{mail\}/gi, "&#9993;");
	text = text.replace(/\{I\}/g, "&#8544;");
	text = text.replace(/\{III\}/g, "&#8546;");
	text = text.replace(/\{II\}/g, "&#8545;");
	text = text.replace(/\{IV\}/g, "&#8547;");
	text = text.replace(/\{V\}/g, "&#8548;");
	text = text.replace(/\{VI\}/g, "&#8549;");
	text = text.replace(/\{VII\}/g, "&#8550;");
	text = text.replace(/\{VIII\}/g, "&#8551;");
	text = text.replace(/\{IX\}/g, "&#8552;");
	text = text.replace(/\{X\}/g, "&#8553;");
	text = text.replace(/\{XI\}/g, "&#8554;");
	text = text.replace(/\{XII\}/g, "&#8555;");
	text = text.replace(/\{inf\}/g, "&#8734;");
	text = text.replace(/\{dagger\}/g, "&#8224;");
	text = text.replace(/\{para\}/g, "&#182;");
	text = text.replace(/\{section\}/g, "&#167;");
	text = text.replace(/\[o\]/g, "&#248;");
	text = text.replace(/\[O\]/g, "&#216;");
	text = text.replace(/\[a\]/g, "&#229;");
	text = text.replace(/\[A\]/g, "&#197;");
	text = text.replace(/\[ae\]/g, "&#230;");
	text = text.replace(/\[AE\]/g, "&#198;");

	if (options.names) {
    	for (ch in entities) {
    	    text = text.replace(new RegExp(entities[ch], "g"), ch);
    	}
		text = text.replace(/\&#38;/gi, "&amp;");
		text = text.replace(/\&#60;/gi, "&lt;");
		text = text.replace(/\&#62;/gi, "&gt;");
		text = text.replace(/\&#160;/gi, "&nbsp;");
	}

	return unescape(text);
};
