$(document).ready(function()
{
    servers = new Array();
    $('.server').each(function(i) {
        servers[i] = new hlsw_gameserver($(this).find('.server_gametype').text(), $(this).find('.server_address').text());
        servers[i].object = $(this);
        servers[i].serverInfoReceived = function(data) {
            if(data.info != undefined) {
                this.object.find('.server_hostname').text(data.info.hostname);
                this.object.find('.server_map').text(data.info.map);
                this.object.find('.server_country').attr('src', this.object.find('.server_country').attr('src').replace(/([a-z])*\.gif/i, data.location.country + '.gif'));
                clientcount = this.object.find('.server_clientcount');
                clientmax = this.object.find('.server_clientmax');
                if(data.info.playercount>=data.info.playermax) {
                    clientcount.addClass("player_full");
                    clientmax.addClass("player_full");
                } else {
                    clientcount.removeClass("player_full");
                    clientmax.removeClass("player_full");
                }
                clientcount.text(data.info.playercount);
                clientmax.text(data.info.playermax);
            } else {
                this.object.addClass('server_offline');
                this.object.removeClass('odd');
                if(this.object != this.object.parent().find('.server:last'))
                    this.object.parent().find('.server:last').after(this.object);
            }
        }

        servers[i].getServerInfo();
    });
});