function initTUAnalyzeResult()
{
  if (typeof(wAnalyzeResult) == "undefined") {
    try
    {
      wAnalyzeResult = new ActiveXObject("TUAnalyzeInfo.TUAnalyzeResult");
    }
    catch (e)
    {
    }
  }
}

function initAnimations()
{
  $('*').keydown(
    function (e)
    {
      switch (e.keyCode)
      {
        case 13:
          $(this).click();
          break;
      }
    }
  );

  $('a').mouseenter(
      function ()
      {
        $(this).addClass('hover');
      }
  ).mouseleave(
    function ()
    {
      $(this).removeClass('hover');
    }
  );
}

function headlineStatus(status, type)
{
  if (type == 'highspeed')
  {
    return translate('<localized>Turbo-Modus</localized>');
  }
  else if (type == 'maintenance')
  {
    switch (status)
    {
      case 'good':
        return translate('<localized>Automatisch</localized>');
        break;
      case 'warning':
        if (wAnalyzeResult.OCMTaskWorking == 2)
        {
          return translate('<localized>Manuell</localized>');
        }
        else
        {
          return translate('<localized>Achtung</localized>');
        }
        break;
      case 'critical':
        return translate('<localized>Warnung</localized>');
        break;
    }
  }
  else
  {
    switch (status)
    {
      case 'good':
        return translate('<localized>Optimiert</localized>');
        break;
      case 'warning':
        return translate('<localized>Achtung</localized>');
        break;
      case 'critical':
        return translate('<localized>Warnung</localized>');
        break;
      case 'loading':
        return '&nbsp;';
    }
  }
}

function updateStatus(status, type)
{
  $('#content').removeClass('good warning critical unknown loading highspeed').addClass(status);
  $('#content .headline').html(headlineStatus(status, type));
}

function loadContent(type)
{
  $('#content').removeClass('maintenance speed status highspeed').addClass(type);
  var tuEval = 'var status = ' + type + 'Status();' +
               'updateStatus(status, type);' +
               '$(\'#content .text\').html(' + type + 'TextStatus(status));' +
               '$(\'#content .link\').html(' + type + 'LinkStatus(status));';
  eval(tuEval);
  if (status)
  {
    initAnimations();
    return true;
  }
  else
  {
    return false;
  }
}