function UpdateServerInfo(sort) {
    servers = new Array();
    $('.server:not(.updated)').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) {
            	hostname = this.object.find('.server_hostname');
            	map = this.object.find('.server_map');
            	country = this.object.find('.server_country');
            	if(!$.isEmptyObject(hostname))
            		hostname.text(data.info.hostname);
            	if(!$.isEmptyObject(map))
            		map.text(data.info.map);
            	if(!$.isEmptyObject(country))
            		country.attr('src', 'http://flags.hlsw.org/21x14/' + 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(sort && this.object != this.object.parent().find('.server:last'))
                    this.object.parent().find('.server:last').after(this.object);
            }
            this.object.addClass('updated');
        }
        servers[i].getServerInfo();
    });
}

$(document).ready(function()
{
	UpdateServerInfo(true);
});