function tableList(types, options) {
	this.initialize(types, options);
}
tableList.prototype = {
	_options : {
		tableId : null,
		tableClass : 'list',
		hoverClass : 'hover',
		oddRowClass : 'odd',
		evenRowClass : 'even',
		selectRowClass : 'selected'
	},
	types : [],
	initialize : function(types, options) {
		if(!this._isDecentBrowser()) return;
		this.options = this._clone(this._options);
		if(options) {
			for (attrname in options) {
				this.options[attrname] = options[attrname];
			}
		}
		this.types = types;
		this.set();
	},
	set : function(types) {
		if(types) {
			this.types = types;
		}
		if(this.options.tableId) {
			var tables = [document.getElementById(this.options.tableId)];
			this.options.tableClass = tables[0].className;
		} else {
			var tables=document.getElementsByTagName('table');
		}
		for (var i = 0; i < tables.length; i++) {
			var table = tables[i];
			if(!table.className.match(new RegExp('(\\s|^)'+this.options.tableClass+'(\\s|$)'))) {
				continue;
			}
			var tbodies = table.getElementsByTagName('tbody');
			for (var j = 0; j < tbodies.length; j++) {
				var trs = tbodies[j].getElementsByTagName('tr');
				for(var k = 0; k < trs.length; k++) {
					for(index in this.types) {
						this[this.types[index]](trs[k], k);
					}
				}
			}
		}
	},
	stripe : function(row, index) {
		row.className += (index % 2) ? ' ' + this.options.oddRowClass : ' ' + this.options.evenRowClass;
	},
	hover : function(row) {
		row.onmouseover = function(event, row) {
			row.className += ' ' + this.options.hoverClass;
		}.bindEventListener(this, row);
		row.onmouseout = function(event, row) {
			row.className = row.className.replace(this.options.hoverClass, '');
		}.bindEventListener(this, row);
	},
	select : function(row) {
		row.onclick = function(event, row) {
			row.className = (row.className.match(new RegExp('(\\s|^)'+this.options.selectRowClass+'(\\s|$)'))) ? row.className.replace(this.options.selectRowClass, '') : row.className + ' ' + this.options.selectRowClass;
		}.bindEventListener(this, row);
	},
	_isDecentBrowser : function() {
		return (document.getElementById && document.createTextNode);
	},
	_clone : function(obj) {
		if (typeof (obj) != 'object') return obj;
		if(obj == null) return obj;
		var newO = new Object();
		for (var i in obj) newO[i] = this._clone(obj[i]);
		return newO;
	}
}
Function.prototype.bind = function (object) {
    var method = this;
    var oldArguments = toArray(arguments).slice(1);
    return function () {
        var newArguments = toArray(arguments);
        return method.apply(object, oldArguments.concat(newArguments));
    };
}
Function.prototype.bindEventListener = function (object) {
    var method = this;
    var oldArguments = toArray(arguments).slice(1);
    return function (event) {
        return method.apply(object, [event || window.event].concat(oldArguments));
    };
}
function toArray(pseudoArray) {
    var result = [];
    for (var i = 0; i < pseudoArray.length; i++)
        result.push(pseudoArray[i]);
    return result;
}

