/**
 * Rowhover.js - Hover for your rows!
 * 
 * @author  Webstores <info at webstores dot nl>
 *           Copyright (c) Webstores internet totaalbureau <http://www.webstores.nl/>
 */

var RowHover = function() {
	var tables,
		hoverCls;
	
	return {
		initialize: function(cls) {
			hoverCls = cls || 'hover';
			tables = document.getElementsByTagName('table');
			this.initEvents();
		},
		initEvents: function() {
			for(var i = 0; i < tables.length; i++) {
				var rows = tables[i].rows;
				for(var j = 0; j < rows.length; j++) {
					// Not for rows in THEAD or rows with TH childs
					if(rows[j].parentNode.nodeName == 'TBODY' && rows[j].getElementsByTagName('th').length == 0) {
						addEvent(rows[j], 'mouseover', function() {
							addClass(this, hoverCls);
						});
						addEvent(rows[j], 'mouseout', function() {
							removeClass(this, hoverCls);
						});
					}
				}
			}
		}
	}
}();

addEvent(window, 'load', function() {
	RowHover.initialize();
});
