function TextData (string) {
	this.aligns = {'left' : 0, 'right' : 1, 'center' : 2, 'justify' : 3 };
	this.effects = {'shadow': 0, 'glow':1, 'bevel':2, 'stroke':3 };

	this.caption = '';
	
	try{
		if (string != null)
			this.readImageParam(string);
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData]</B> ' + e + '</FONT>' ); return false; } 
}


TextData.prototype.readTextParam = function(string){
	try{
		string = string.replace(/\[t\]/,"");
		var textData = string.split(",");
		
		if ( textData[0] ){ this.setBackgroundColor(textData[0]); }
		if ( textData[1] ){ this.setFontSize(textData[1]); }
		if ( textData[2] ){ this.setFontFace(textData[2]); }
		if ( textData[3] ){ this.setFontColor(textData[3]); }
		if ( textData[4] ){ this.setFontUnderline(textData[4]); }
		if ( textData[5] ){ this.setFontAlign(textData[5]); }
		if ( textData[6] ){ this.setCaption(replace(decodeURIComponent(textData[6]), '+', ' ')); }	// commas are used as separators in the serialized form
		if ( textData[7] ){ this.setFontEffectType(textData[7]); }
		if ( textData[8] ){ this.setFontEffectColor(textData[8]); }
		if ( textData[9] ){ this.setFontEffectStrokeWeight(textData[9]); }

		//dbg.add("<FONT color='green'><B>Reading Image string</B>: "+string,"<I>this.path</I>: "+this.path,"<I>this.scannum</I>: "+this.scannum,( this.zoomCommand? ("<I>this.zoomCommand</I>: "+this.zoomCommand.zoomFactor+","+this.zoomCommand.cropX+","+this.zoomCommand.cropY+"<BR>" ) : "" )+"</FONT>" );
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.readImageParam]</B> ' + e + '</FONT>' ); return false; } 
}


TextData.prototype.toString = function(){
	try{
		var string = "[t]";
		string += this.getBackgroundColor();
		string += "," + this.getFontSize();
		string += "," + this.getFontFace();
		string += "," + this.getFontColor();
		string += "," + this.getFontUnderline();
		string += "," + this.getFontAlign();
		string += "," + encodeURIComponent(this.getCaption());	// commas are used as separators in the serialized form
		string += "," + (this.getFontEffectType() == null ? '' : this.getFontEffectType());
		string += "," + (this.getFontEffectColor() == null ? '' : this.getFontEffectColor());
		string += "," + (this.getFontEffectStrokeWeight() == null ? '' : this.getFontEffectStrokeWeight());

		return string;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.toString]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getCaption = function(){
	try{
		return this.caption;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getCaption]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setCaption = function(caption){
	try{
		this.caption = caption;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setCaption]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getFontSize = function(){
	try{
		return this.fontSize;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontSize]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontSize = function(fontSize){
	try{
		this.fontSize = fontSize;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontSize]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getFontFace = function(){
	try{
		return this.fontFace;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontFace]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontFace = function(fontFace){
	try{
		this.fontFace = fontFace;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontFace]</B> ' + e + '</FONT>' ); return false; } 
}


TextData.prototype.getFontColor = function(){
	try{
		return this.fontColor;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontColor]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontColor = function(fontColor){
	try{
		this.fontColor = fontColor;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontColor]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getBackgroundColor = function(){
	try{
		return this.backgroundColor;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getBackgroundColor]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setBackgroundColor = function(backgroundColor){
	try{
		this.backgroundColor = backgroundColor;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setBackgroundColor]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getFontUnderline = function(){
	try{
		return this.fontUnderline;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontUnderline]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontUnderline = function(fontUnderline){
	try{
		this.fontUnderline = fontUnderline;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontUnderline]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getFontAlign = function(){
	try{
		for (var prop in this.aligns) {
			if (this.aligns[prop] == this.align) return prop;
		}
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontAlign]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontAlign = function(align){
	try{
		this.align = this.aligns[align];
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontAlign]</B> ' + e + '</FONT>' ); return false; } 
}


TextData.prototype.getFontEffectType = function(){
	try{
		for (var prop in this.effects) {
			if (this.effects[prop] == this.effect) return prop;
		}
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontEffectType]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontEffectType = function(effect){
	try{
		this.effect = this.effects[effect];
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontEffectType]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getFontEffectColor = function(){
	try{
		return this.fontEffectColor;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontEffectColor]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontEffectColor = function(fontEffectColor){
	try{
		this.fontEffectColor = fontEffectColor;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontEffectColor]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.getFontEffectStrokeWeight = function(){
	try{
		return this.fontEffectStrokeWeight;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.getFontEffectStrokeWeight]</B> ' + e + '</FONT>' ); return false; } 
}

TextData.prototype.setFontEffectStrokeWeight = function(fontEffectStrokeWeight){
	try{
		this.fontEffectStrokeWeight = fontEffectStrokeWeight;
	}
	catch(e){ dbg.add ( '<FONT COLOR="red"><B>[TextData.setFontEffectStrokeWeight]</B> ' + e + '</FONT>' ); return false; } 
}
