jQuery(document).ready(function ($) {
	add_server_mouseovers();
   
   function add_server_mouseovers() {
      $('.server').each(function() {
         $(this).next('div.s_details').hide();
         
         $(this).mouseover(function() {
            div = $(this).next('div.s_details');
            $(div).show();
            $(div).html('Loading...');	
         
            var t = new Date().getTime();
            $.ajax({
               url: path + '/?feed=server&d=' + t + '&s=' + $(this).html(),
               type: 'GET',
               dataType: 'xml',
               timeout: 1000,
               
               success: function(xml){
                  if ($(xml).find('error').text() == 1) {
                     $(div).html('<b>' + $(xml).find('name').text() + '</b>');
                  } else {
                     pass = $(xml).find('password').text() == 1 ? 'Yes' : 'No';
                     $(div).html('<b>' + $(xml).find('name').text() + '</b><br />Players: ' + $(xml).find('players').text() + '/' + $(xml).find('players').attr('max') + ', Map: ' + $(xml).find('map').text() + ', Password: ' + pass);
                  }
               }
            });
         
         });
         
         $(this).mouseout(function() {
            $(this).next('div.s_details').hide();
         });
      });
   }
});


