//global background color variable //set this to change the hover background color var BACKGROUND_COLOR = '#ffffcc'; function trhover() { //sets up all rows in all tables to have the hover effect. var tables = document.getElementsByTagName("table"), thisTable, thisRow, rowcount=0, tablecount=0; while (thisTable = tables[tablecount++]) { while (thisRow = thisTable.rows[rowcount++]) { thisRow.onmouseover = turnOn; thisRow.onmouseout = turnOff; } } } function turnOn() { //this function sets the row's background color on mouseover this.style.backgroundColor = BACKGROUND_COLOR; } function turnOff() { //this function sets the row's background color back to normal this.style.backgroundColor = ''; } //set up the event handlers for the tables when the page loads function tableInit() { trhover(); } window.onload = tableInit;