function addEvent(elm, evType, fn, useCapture) {
  // cross-browser event handling for IE5+, NS6 and Mozilla
  // By Scott Andrew
  if (elm.addEventListener) {
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent) {
    var r = elm.attachEvent('on' + evType, fn);
    EventCache.add(elm, evType, fn);
    return r;
  } else {
    elm['on' + evType] = fn;
  }
}

addEvent(window, 'unload', EventCache.flush, false);

function table() {
    var content = document.getElementById('middle_column');
    if(content){
        var tables = content.getElementsByTagName('table');
        if(tables.length > 0){
            for(i=0; i < tables.length; i++){
                if(tables[i].className=='renderedtable'){
                    //alert('Klasa dla tabeli ' + i + ': ' + tables[i].className);
                    var rows = tables[i].getElementsByTagName('tr');
                    var rowCount = rows.length;
                    //alert('Tabela ' + i + ',rowCount: ' + rowCount);
                    
                    if (rows[0]) {
                        cellCount = rows[0].cells.length;
                        if (cellCount > 0) {
                            rows[0].cells[0].className += " left_top"; 
                            rows[0].cells[cellCount - 1].className += " right_top";

                            // testowe kolory
                            //rows[0].cells[0].style.color = 'green';
                            //rows[0].cells[cellCount - 1].style.color = 'blue';
                        }
                    }
                    
                    if (rows[rowCount - 1]) {
                        cellCount = rows[rowCount - 1].cells.length;
                        if (cellCount > 0) {
                            rows[rowCount - 1].cells[0].className += " left_bottom"; 
                            rows[rowCount - 1].cells[cellCount - 1].className += " right_bottom";

                            // testowe kolory
                            //rows[rowCount - 1].cells[0].style.color = 'red';
                            //rows[rowCount - 1].cells[cellCount - 1].style.color = 'gray';
                        }
                    }
                }
            }
        }
    }
}

addEvent(window, 'load', table, false);

