/*
 * ah3.js - ah3.dk specific functions
 */

  var allRuns = 0;
  var runsdiv = null;

  function slowResizeStep()
  {
    o = runsdiv.parentNode;
    ih = runsdiv.offsetHeight;
    oh = o.offsetHeight;
    if ( ih != oh )
    {
      if ( ih > oh )
      {
        diff = (ih - oh + 3) / 4;
      }
      else
      {
        diff = (ih - oh - 3) / 4;
      }
      o.style.height = (oh+diff)+"px";
      startSlowResize();
    }
  }
 
  function startSlowResize()
  {
    setTimeout( "slowResizeStep()", 50 );
  }

  function updaterunsdiv( txt )
  {
    runsdiv = document.getElementById( 'runsdiv' );
    o = runsdiv.parentNode;
    if ( o.style.height == "" )
    {
      o.style.height = o.offsetHeight+"px";
    }
    runsdiv = document.getElementById( 'run-container' );
    runsdiv.innerHTML = txt;
    runsdiv = document.getElementById( 'runsdiv' );
    startSlowResize();
  }

  function updateNextRun()
  {
    runsdiv = document.getElementById( 'run-container' );
    if ( null == runsdiv )
    {
      // alert( 'no runsdiv' );
      return;
    }
    url = '/ajax/nextrun.php?allruns='+allRuns;
    runreq = new XMLHttpRequester( url, null, 'updaterunsdiv' );
    runreq.execute();
  }

  function toggleAllRuns()
  {
    allRuns = 1 - allRuns;
    updateNextRun();
  }

  function toggleRun( no )
  {
    node = document.getElementById('run'+no+'line0' );
    if ( node == null ) return;
    img = document.getElementById( 'toggle'+no );
    if ( 'noshow' == node.className )
    {
      img.src = "/graphics/minus_11.png";
      idnum = 0;
      while ( null != (node = document.getElementById('run'+no+'line'+idnum)) )
      {
        node.className = '';
        idnum++;
      }
    }
    else
    {
      img.src = "/graphics/plus_11.png";
      idnum = 0;
      while ( null != (node = document.getElementById('run'+no+'line'+idnum)) )
      {
        node.className = 'noshow';
        idnum++;
      }
    }
    runsdiv = document.getElementById( "runsdiv" );
    startSlowResize();
  }

/*
  function updateNews()
  {
    if ( null == document.getElementById( 'news-container' ) )
    {
      // alert( 'no newsdiv' );
      return;
    }
    url = '/ajax/news.php';
    newsreq = new XMLHttpRequester( url, null, 'news-container' );
    newsreq.execute();
  }
*/
//updateNextRun();
//updateNews();
