var DEBUG_ALERTS = false; function Table(name, prefix) { this.name=name; this.columns=new Array(); this.styleprefix = prefix; } function Table_addColumn(colname) { this.columns[this.columns.length]=colname; } Table.prototype.addColumn = Table_addColumn; function Table_setSelectedRow(selrow) { this.selectedRow=selrow; } Table.prototype.setSelectedRow = Table_setSelectedRow; function Table_setSelectedColumn(selcol) { this.selectedColumn=selcol; } Table.prototype.setSelectedColumn = Table_setSelectedColumn; function Row(row,tableobj) { this.row = row; var rowContents = new Array(); for (var i = 0;i < row.cells.length;i++) { var column=tableobj.columns[i]; rowContents[column]=row.cells[i].innerText; } this.cells = rowContents; } function getParentTableId(obj) { if (obj.tagName=="TABLE") { if (obj.id.length==0) { return (getParentTableId(obj.parentNode)); } else { return obj.id; } } else { return (getParentTableId(obj.parentNode)); } } function getTableObject(tableId) { var idx = tableId.lastIndexOf ("_heading"); if (idx > 0) { tableId = tableId.substring(0, idx); } var tableobj = eval("__TABLE__"+tableId); return tableobj; } function rowSelect(row) { var table = getParentTableId(row); var tableobj = getTableObject(table); if (tableobj) { if (tableobj.selectedRow) { tableobj.selectedRow.row.className=tableobj.styleprefix+"row"; if (DEBUG_ALERTS) alert("rowSelect: setting previously selected row's style to "+tableobj.selectedRow.row.className); } row.className=tableobj.styleprefix+"rowselected" var selRow = new Row(row,tableobj); tableobj.setSelectedRow(selRow); } } function colSelect(column) { var table = getParentTableId(column); var tableobj = getTableObject(table); if (tableobj) { if (tableobj.selectedColumn) { tableobj.selectedColumn.className=tableobj.styleprefix+"columnheading"; } column.className=tableobj.styleprefix+"columnheadingselected"; tableobj.setSelectedColumn(column); } } function bind(table,form) { var tableobj = getTableObject(table); if (tableobj) { if (tableobj.selectedRow) { for (var j = 0; j < tableobj.selectedRow.cells.length; j++) { for (var k = 0; k < form.elements.length;k++) { if ((form.elements[k].tagName == "INPUT") && (form.elements[k].name==tableobj.columns[j])) {form.elements[k].value=tableobj.selectedRow.cells[j]; }}}}}}