function message_box() {
  this.showBox   = function(color, msg) { $('#message_box_span').css('color', color).text(msg); };
  this.showError = function(msg) { this.showBox('red', msg); };
  this.showInfo  = function(msg) { this.showBox('green', msg); };
}

function title_bar() {
  this.change = function(msg) { document.title = msg; };
}

function update_adsense()
{
  if (IS_ADMIN != true) {
    $('#google_adsense_wrapper').hide();
    return;
  }

  if ($(window).width() >= 1280) {
    $('#google_adsense_wrapper').show();
  } else {
    $('#google_adsense_wrapper').hide();
  }
}

function startup()
{
  // game on turn timer
  if ($('#game_on_turn_timer').length > 0)
    $('#game_on_turn_timer').everyTime('60s', check_game_on_turn, true);

  // screen width
  update_adsense();

  window.onresize = function() { update_adsense(); }
}

function tablesorter_stripped_text_init()
{
  $.tablesorter.addParser({
    id:     "stripped_text",
    is:     function(s) { return false; },
    format: function(s) { return s.toLowerCase().replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ""); },
    type:   "text"
  });
}

function check_game_on_turn()
{
  $.get('/games/has_game_on_turn', function(data) { if (data == 'true') { tb = new title_bar; tb.change(S_ON_TURN_IN_GAME); } });
}
