$(document).ready(
  function ()
  {
    if (false)
    {
      updateActivities(
        new Array(
          new Array('C', 'text1', 100, 30, false),
          new Array('A', 'text2', 0, 40, false),
          new Array('B', 'text3', 40, 60, false),
          new Array('D', 'text4', 130, 40, false),
          new Array('E', 'text5<br />zweite zeile', 170, 10, false),
          new Array('F', 'text6', 0, 5, true)
        )
      );
      updatePotentials(
        new Array(
          new Array('G', 'text7', 180, 10, false),
          new Array('H', 'text8', 190, 10, false),
          new Array('I', 'text9', 200, 10, false),
          new Array('J', 'text10', 210, 10, false),
          new Array('K', 'text11', 220, 5, false),
          new Array('L', 'text12', 0, 16, true)
        )
      );
      highspeedDone(true);
    }
  }
);

function call(string)
{
  alert(string);
}

function updateActivities(tuArray)
{
  fillTable('activities', tuArray);
}

function updatePotentials(tuArray)
{
  fillTable('potentials', tuArray);
}

function fillTable(type, tuArray)
{
  var html = '';
  for (var i = 0; i < tuArray.length; i++)
  {
    if (tuArray[i][4])
    {
      var interval = tuArray[i][3];
      if (type == 'potentials')
      {
        interval = tuArray[i][2];
      }
      if (interval >= 0 && interval <= 16)
      {
        interval = Math.round(interval);
        if (String(interval).length == 1)
        {
          interval = '0' + interval;
        }
      }
    }
    html += '<tr valign="top" class="row' + i + '">' +
        '<td class="first">' +
          '<div class="number"' + ((tuArray[i][0] == '') ? ' style="visibility: hidden;"' : '') + '>' + tuArray[i][0] + '</div>' +
        '</td>' +
        '<td class="second">' +
          tuArray[i][1] +
        '</td>' +
        '<td class="third">' +
          (
            tuArray[i][4] ?
            '<div class="turbo turbo' + (turbomodeStatus ? 'on' : 'off') + '"><div class="turbo' + interval + '"></div></div>' :
            (
              (tuArray[i][3] > 0) ?
              '<div class="tuindex tuindex' + tuArray[i][0].toLowerCase() + '" style="width: ' + tuArray[i][3] + 'px;"></div>' :
              ''
            )
          ) +
        '</td>' +
      '</tr>';
  }
  $('#' + type).html(html);
  
  $('body').css('overflow-y', ($('body div:first').height() > 432) ? 'scroll' : 'hidden');
}

var turbomodeStatus = false;
function highspeedDone(newStatus)
{
  $('.turbo').removeClass('turbo' + (turbomodeStatus ? 'on' : 'off'));
  turbomodeStatus = newStatus;
  $('.turbo').addClass('turbo' + (turbomodeStatus ? 'on' : 'off'));
}