﻿Event.observe(window, 'load', function(e) {
    $$('table.listing').each(function(table) {
        applyAlt(table);
        table.down('tbody').observe('mouseover', function(e) {
            var el = e.element();
            var table = el.up('table');
            if (el.tagName == 'TD') el = el.up();
            if (el.tagName == 'A') el = el.up(1);
            if (table.hoverRow != el) {
                if (table.hoverRow) table.hoverRow.removeClassName('hover');
                el.addClassName('hover');
                table.hoverRow = el;
            }
        }).observe('mouseout', function(e) {
            var el = e.element();
            var table = el.up('table');
            if (table.hoverRow) {
                table.hoverRow.removeClassName('hover');
                table.hoverRow = null;
            }
        });
    });
});

function applyAlt(table) {
    table.select('tbody tr.alt').invoke('removeClassName','alt');
    table.select('tbody tr:nth-child(even)').invoke('addClassName', 'alt');
}
function listingsortcomplete(t) {
    applyAlt($(t));
}