/**
 * 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++) {
				if(WS.hasClass(tables[i], 'wshover')) {
					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) {
							WS.Event.addEvent(rows[j], 'mouseover', function() {
								WS.addClass(this, hoverCls);
							});
							WS.Event.addEvent(rows[j], 'mouseout', function() {
								WS.removeClass(this, hoverCls);
							});
						}
					}
				}
			}
		}
	}
}();

WS.Event.addEvent(window, 'load', function() {
	RowHover.initialize();
});

