function FontDef(){}
FontDef.prototype.toString = function(){return "[object FontDef]";}
FontDef.prototype.setDirectory = function(directory) {this.directory = directory;}
FontDef.prototype.setCropLeft = function(charArr) {this.cropLeft = charArr;}
FontDef.prototype.setAddLeft = function(charArr) {this.addLeft = charArr;}
FontDef.prototype.setCropRight = function(charArr) {this.cropRight = charArr;}
FontDef.prototype.setAddRight = function(charArr) {this.addRight = charArr;}
FontDef.prototype.setCropBoth = function(charArr) {this.cropBoth = charArr;}
FontDef.prototype.setAddBoth = function(charArr) {this.addBoth = charArr;}
FontDef.prototype.setFixed = function(charArr) {this.fixed = charArr;}
FontDef.prototype.writeText = function(str)
{
	var imgcnt = 0;
	var pc = ""
	var tbl = "ft"+(Math.round(Math.random()*8999)+1000);
	var headerhtml = "";		
	//headerhtml += "<div id=\"" + tbl + "\" style=\"visibility:hidden\"><table cellpadding='0' cellspacing='0' border='1' width='1'>";
	headerhtml += "<div id=\"" + tbl + "\" style=\"visibility:hidden\"><div>";
	for (var i=0;i<str.length;i++)
	{
		var c = str.charAt(i);
		var orgC = c;
		var sw = 2;
		if (pc!="")
		{
			for (var ii=0;ii<2;ii++)
			{
				var cc = ii==0?pc:c;
				if (this.cropBoth.indexOf(cc)!=-1) sw--;
				if (this.cropLeft.indexOf(cc)!=-1) sw=(ii==1?sw-1:sw);
				if (this.cropRight.indexOf(cc)!=-1) sw=(ii==0?sw-1:sw);
				if (this.fixed.indexOf(cc)!=-1) sw-=2;
				if (this.addBoth.indexOf(cc)!=-1) sw++;
			}
		}
		pc = c
		if (c>="a"&&c<="z") c = "_"+c.toUpperCase();
		else if (c==" ") c = "SPACE";
		else if (c=="/") c = "SLASH";
		else if (c=="&") c = "AMP";
		else if (c==",") c = "COMMA";
		else if (c==".") c = "PERIOD";
		else if (c=="'") c = "APOS";
		else if (c=="?") c = "QUEST";
		else if (c=="(") c = "LPARAN";
		else if (c==")") c = "RPARAN";
		else if (c==":") c = "COLON";
		else if (c=="!") c = "EXCLAM";

		if (c=="=")
		{
		
			headerhtml += "</div><div style='margin-left: -3px'>";
			//headerhtml += "</table><table cellpadding='0' cellspacing='0 border='2' width='1'>";
		}
		else
		{
			if (i>0&&sw>0)
			{
				//headerhtml += "<td><img src=\""+ this.directory + "/SPACE.gif\" alt=\"\" width=\""+ sw +"\" height=\"38\" border=0 onload=\"\"></td>";
				headerhtml += "<img src=\""+ this.directory + "/SPACE.gif\" alt=\"\" width=\""+ sw +"\" height=\"38\" border=0 onload=\"\">";
			}
			imgcnt++;
			headerhtml += "<img src=\"" + this.directory + "/" + c + ".gif\" alt=\"\" border=0 "+
				"onload=\""+
					"if (!document.all){"+
						"this.width=this.width;"+
						"this.height=this.height;"+
					"}"+
					"window['"+tbl+"_Func']('"+tbl+"')\""+
				">";
		}
	}
	//headerhtml += "</table></div>";
	headerhtml += "</div></div>";
	window[tbl+'_Total'] = imgcnt;
	window[tbl+'_Count'] = 0;
	window[tbl+'_Func'] = function(tbl)
	{
		window[tbl+'_Count']++;
		if (window[tbl+'_Total'] == window[tbl+'_Count'])
		{
			if (document.all)
			{
				document.all[tbl].style.visibility = 'visible';
			}
			else if (document.getElementById)
			{
				document.getElementById(tbl).style.visibility = 'visible';
			}
		}
	}
	document.write(headerhtml);
}


var HeadLine = new FontDef();
HeadLine.setDirectory("images/headline-font");
HeadLine.setCropLeft("dfgCJR");
HeadLine.setCropRight("klrKLFS");
HeadLine.setCropBoth(" -/stvwxyzAMPTVWXYZ");
HeadLine.setAddLeft("HI");
HeadLine.setAddRight("");
HeadLine.setAddBoth("NU");
HeadLine.setFixed("0123456789");
