tuDispatcher.bind("onload", function(evt, arg0)
{
  tuDispatcher.send("#onload");
}).bind("updateTuningStatus", function(evt, obj)
{
  console.debug("updateTuningStatus(", arguments, ")");

  // hide all segments
  jQuery(".tuningstatus .segment").hide();
  var segment = sObj = undefined, i = 0;
  for (i in obj.activities.list)
  {
    segment = obj.activities.list[i];

    // show pager-index
    sObj = jQuery(String.format(".tuningstatus .activities .segment-%s", i));

    if (sObj !== undefined)
    {
      sObj.find(".index").html((parseInt(segment.index) + 1));
      sObj.find(".text").html(segment.text);
      if (segment.length !== 0)
      {
        sObj.find(".graph").css({
          width: segment.length
        }).show();
      }
      else
      {
        sObj.find(".graph").hide();
      }
      // show segment
      sObj.show();
    }
  }
  segment = sObj = undefined, i = 0;

  jQuery(".tuningstatus .potentials .segment .graph").removeClass("last");
  for (i in obj.potentials.list)
  {
    segment = obj.potentials.list[i];
    // show pager-index
    sObj = jQuery(String.format(".tuningstatus .potentials .segment-%s", i));

    if (sObj !== undefined)
    {
      sObj.find(".index").html((parseInt(segment.index) + 1));
      sObj.find(".text").html(segment.text);

      if (segment.length !== 0)
      {
        sObj.find(".graph").css({
          width: segment.length
        }).show();
      }
      else
      {
        sObj.find(".graph, .index").hide();
      }
      // show segment
      sObj.show();
    }
  }
  jQuery(".tuningstatus .potentials .segment .graph:visible:last").addClass("last");

  if ((obj.potentials.list.length == 1) && (obj.potentials.list[0].length == 0))
  {
    console.debug("Everything seems to be optimized. Modify border-radius.");
    jQuery(".tuningstatus .activities .segment .graph:visible:last").addClass("last");
  }

  if ((obj.activities.list.length == 1) && (obj.activities.list[0].length == 0))
  {
    console.debug("Nothing seems to be optimized. Modify border-radius.");
    jQuery(".tuningstatus .potentials .segment .graph:visible:first").addClass("first");
  }

  jQuery(".tuningstatus .divider").css({
    height: jQuery(".tuningstatus").height()
  });

  tuDispatcher.send(String.format("#resizeWindow:%s", jQuery(".tuningstatus").height()));
});
