var lastResultStatus;
function statusStatus()
{
  if (wAnalyzeResult)
  {
    lastResultStatus = parseInt(wAnalyzeResult.LoadState());
    switch (lastResultStatus)
    {
      case 0:
        if (wAnalyzeResult.CriticalCount)
        {
          return 'critical';
        }
        else if (wAnalyzeResult.WarningCount)
        {
          return 'warning';
        }
        else
        {
          return 'good';
        }
        break;
      case 30:
        return 'critical';
        break;
      default:
        return 'critical';
        break;
    }
  }
  else
  {
    return 'critical';
  }
}

function statusTextStatus(status)
{
  var returnText = '';
  switch (status)
  {
    case 'good':
      returnText = translate('<localized>Es wurden keine Probleme gefunden.</localized>');
      // no break, add ignore count in default
    case 'warning':
      if (wAnalyzeResult.WarningCount)
      {
        if (wAnalyzeResult.WarningCount == 1)
        {
          returnText += translate('<localized>Es wurde 1 Problem gefunden.</localized>')
        }
        else
        {
          returnText += sprintf(
            translate(
              '<localized>Es wurden %d Probleme gefunden.</localized>'
            ),
            wAnalyzeResult.WarningCount
          );
        }
      }
      // no break, fallback to critical
    default:
      if (wAnalyzeResult && wAnalyzeResult.CriticalCount)
      {
        var count = wAnalyzeResult.CriticalCount + wAnalyzeResult.WarningCount;
        if (count == 1)
        {
          return translate('<localized>Es wurde 1 Problem gefunden.</localized>')
        }
        else
        {
          return sprintf(translate('<localized>Es wurden %d Probleme gefunden.</localized>'), count);
        }
      }
/*      if (wAnalyzeResult.IgnoreCount)
      {
        returnText += '<br />' +
                      sprintf(
                        translate(
                          '<localized>Ausgeblendete Probleme: %s</localized>'
                        ),
                        wAnalyzeResult.IgnoreCount
                      );
      }*/
      if (returnText)
      {
        return returnText;
      }
      else
      {
        return translate('<localized>Der benötigte Dienst ist nicht aktiv.</localized>') +
          (lastResultStatus ? ' (Error: ' + lastResultStatus + ')' : '');
      }
      break;
  }
}

function statusLinkStatus(status)
{
  switch (status)
  {
    case 'good':
    case 'warning':
    case 'critical':
      return '<a onclick="execApp(\'Integrator.exe\', \'/startsystemhealth\');" tabindex="100">' +
                translate('<localized>» Details anzeigen</localized>') +
             '</a>';
      break;
    default:
      return '';
      break;
  }
}
