/*

  coded by Imagician / BionFX for knuddels.com

  http://www.bionfx.de

  successfully tested with: IE4.0, IE5.0, NN4.5, NN6.0

  NOTE: NN4+ has some serious trouble if hscrollbar is visible, too :(

*/

var mausX  = 0;
var mausY  = 0;

var fBreiteO = 0;
var fHoeheO = 0;

var maxSpeed = 20;
var dontMove = true;

dreiundachtzig = false;
gimmick = true;

function checkPosition(e)
{
  if (!document.all)
  {
    mausX = e.pageX; mausY = e.pageY - vScrolled(); // supported by NN4+ and NN6
  }
  else
  {
    mausX = event.clientX; mausY = event.clientY;
  }
}

function fHoehe()
{
  if (!document.all)
    yy = window.innerHeight; //supported by NN4+ and NN6
  else
    yy = document.body.clientHeight;

  return yy;
}

function fBreite()
{
  if (!document.all)
    yy = window.innerWidth; //supported by NN4+ and NN6
  else
    yy = document.body.clientWidth;

  return yy;
}

function vScrolled()
{
  if (!document.all) return window.pageYOffset; //supported by NN4+ and NN6
  else return document.body.scrollTop;
}

function timerInt()
{


  if ( (fBreiteO != fBreite()) || (fHoeheO != fHoehe()) ) installHandlers();  // NN4 deinstalls after resizing! :(
  fBreiteO = fBreite();  fHoeheO = fHoehe();

  var hh = fHoehe(); var hh13 = hh/3; var hh23 = hh * (2/3); hh12 = hh/2;

  if (document.layers) dontMove = ( (mausY < 0) || (mausY > hh) );

  if ( ((mausY < hh13) || (mausY > hh23)) && (!dontMove) )
  {
    if (mausY < hh13) borderY = hh13; else borderY = hh23;

    var movementY = ((mausY < hh13) || (mausY > hh23))? (   Math.round(((borderY - mausY) / hh13) * -maxSpeed)   ):0;

   scrollBy(0, movementY);
  }
}

function installHandlers()
{
  if (document.layers)
  {
    document.captureEvents(Event.MOUSEMOVE); // only NN4+ needs this
    dontMove = false;
  }

  document.onmousemove = checkPosition;
  if (!document.layers)
  { document.onmouseout  = function qqq(){dontMove = true}
    document.onmouseover = function qqx(){dontMove = false}
  }
}

function init()
{
  fBreiteO = fBreite();  fHoeheO = fHoehe();
  installHandlers();
  window.setInterval('timerInt()',50);
}

