/**
 * Rowclick.js - Make your rows clickable
 * 
 * @author  Webstores <info at webstores dot nl>
 *           Copyright (c) Webstores internet totaalbureau <http://www.webstores.nl/>
 */

var RowClick = function() {
	var tables,
		anchor;
	
	return {
		initialize: function() {
			tables = document.getElementsByTagName('table');
			this.initEvents();
		},
		initEvents: function() {
			for(var i = 0; i < tables.length; i++) {
				if(WS.hasClass(tables[i], 'wsclick')) {
					var rows = tables[i].rows;
					for(var j = 0; j < rows.length; j++) {
						if(rows[j].getElementsByTagName('a').length) {
							var anchor = rows[j].getElementsByTagName('a')[0];
							rows[j].title = anchor.title;
							this.bindHREF(rows[j], anchor.href);
						}
					}
				}
			}
		},
		bindHREF: function(el, hrf) {
			WS.Event.addEvent(el, 'click', function() {
				window.location.href = hrf;
			});
		}
	}
}();

WS.Event.addEvent(window, 'load', function() {
	RowClick.initialize();
});

