/// <reference path="jquery-vsdoc.js" /> 

jQuery(function()
{
	jQuery("input[name=entityCode]").change(function()
	{
		var entity = jQuery.trim(this.value);
		if (0 === entity.length) { entity = "nbsp"; }
		jQuery("#entityCodeLookup").html("&" + entity + ";");
	});
	
	jQuery("input[name=charCode]").change(function()
	{
		var txt = jQuery.trim(this.value);
		if (0 === txt.length)
		{
			txt = "&nbsp;";
		}
		else
		{
			var n = parseInt(txt, 0);
			if (isNaN(n))
			{
				if (1 === txt.length)
				{
					txt = "<span class=\"charCode\">&amp;#x" + txt.charCodeAt(0).toString(16) + ";</span>";
				}
				else
				{
					txt = "&nbsp;";
				}
			}
			else if (9830 < n)
			{
				txt = "<span class=\"charCode\">#ERR#</span>";
			}
			else if (0 <= n)
			{
				txt = "&#" + n.toString(10) + ";";
			}
			else
			{
				txt = "&nbsp;";
			}
		}
		
		jQuery("#charCodeLookup").html(txt);
	});
	
	jQuery("select[name=fontName]").change(function()
	{
		var value = this.options[this.selectedIndex].value;
		jQuery(".char").css("font-family", value);
	});
	
	jQuery("select[name=fontSize]").change(function()
	{
		var value = this.options[this.selectedIndex].value;
		jQuery(".char, .charCode").css("font-size", value);
	});
});
