update_after_loaded = function() { 
  jQuery(document).ready(function($){
    $('div.activeboxscore').removeClass('activeboxscore').slideToggle('fast');
  });
};
jQuery(document).ready(function($){
  $('div.boxscorelink a').click(function(event){
     event.preventDefault();
  });
  $('div.boxscorelink').click(function() { 
    var boxscore = $(this).next();
    if ( true == boxscore.hasClass('boxscoreisvisible')) {
      boxscore.slideToggle('fast').removeClass('boxscoreisvisible');
    } else {
      var boxscore_url = $(this).find('a.boxscorelinka').attr('href');
      boxscore.addClass('boxscoreisvisible');
      if (false == boxscore.hasClass('boxscoreloaded')) {
        boxscore.addClass('boxscoreloaded').addClass('activeboxscore').load(boxscore_url + ' table.boxscore', update_after_loaded);
      } else {
        boxscore.slideToggle('fast');
      }
    }
    $(this).find('span').toggle();
  });
});