var ServerList = new Class({
    initialize: function(table, selected)
    {
        this.table = $(table);

        if (this.table) var rows = this.table.getElements('tr');

        if (rows && rows.length > 1)
        {
            rows.shift();

            this.rows = rows;

            for(i = 0; i < rows.length; i++)
            {
                //console.log(rows[i]);
                rows[i].addEvent('mouseover', this.mouseover.bindWithEvent(this, i));
                rows[i].addEvent('mouseout', this.mouseout.bindWithEvent(this, i));
                rows[i].addEvent('click', this.click.bindWithEvent(this, i));
            }

            this.table.getElement('.row_' + selected).addClass('selected');
            this.table.getElement('#radio_' + selected).set('checked', 'checked');
        }
    },

    unselect: function()
    {
        for(i = 0; i < this.rows.length; i++)
        {
            this.rows[i].removeClass('selected');
            //row.removeClass('selected');
        }
    },

    mouseover: function(e, i)
    {
        //console.log('mouseover: ' + i);
        this.table.getElement('.row_' + i).addClass('hover');
    },

    mouseout: function(e, i)
    {
        //console.log('mouseout: ' + i);
        this.table.getElement('.row_' + i).removeClass('hover');
    },

    click: function(e, i)
    {
        //console.log('click: ' + i);
        this.unselect();

        this.table.getElement('.row_' + i).addClass('selected');
        this.table.getElement('#radio_' + i).set('checked', 'checked');
    }
});