/**
 * 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++) {
				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) {
			addEvent(el, 'click', function() {
				window.location.href = hrf;
			});
		}
	}
}();

addEvent(window, 'load', function() {
	RowClick.initialize();
});
