/*!
* Copyright (c) 2007 Bethke et al. GmbH, Berlin, Germany copyright@b-et-a.de
* All rights reserved.
* Author: Ingo Struck - seen at ingostruck dot de
*/

function Fld (tag, text, sep) {
	if ( !sep ) sep = '\t';
	this.tag = tag;
	this.sub = text.split(sep);
}

Fld.prototype = {
};

function Rec (src) {
	this._state = false;
	this._fld = new Array();
	this._body = '';

	// constructor
	if ( null == src ) {
		// TODO
	} else if( 'string' == typeof(src) ) {
		this.parse_string(src);
	} else if( src.tagName ) {
		this.parse_DOM(src);
	}
}

Rec.prototype = {

	parse_string : function (src) {
		var lst = src.split('\n');
		var m;
		var tag = '';
		var pos;
		for ( pos = 0; pos < lst.length; ++pos ) {
			var spl = lst[pos].match('^([0-9]+)\t(.+)$');
			if (!spl) break;
			this._fld.push(new Fld(spl[1], spl[2]));
		} // for lst
		for ( ; pos < lst.length; ++pos ) this._body = this._body + lst[pos] + '\n';
	}, // parse_string

	fld : function (tag) {
		for (var i = 0; i < this._fld.length; ++i) if ( tag == this._fld[i].tag ) return this._fld[i];
		return false;
	}, // fld

	body : function () { return this._body; }

}; // Rec.prototype
