// Script  : gradlinige Bewegung und/oder Versetzung von Div-Tags(braucht "init.js")
// Version : 1.6
// Autor     : (c) eleNet 2002 (http://www.elenet.de)

// Initialisierung der Objekte,
// damit mehr als eine Bewegung
// verwaltet werden können.
myTimers  = {};
z         = {};
x         = {};
distx     = {};
disty     = {};
dx        = {};
dy        = {};
num       = {};
le        = {};
to        = {};
st        = {};
stepcount = {};

// Ermittlung der noetigen Werte
function makemove(lay,lef,topp,step,vel,funct)
{
  basix(lay);
  z[lay]          = pleft[lay];
  x[lay]          = ptop[lay];
  stepcount[lay]  = 1;
  distx[lay]      = lef-z[lay];
  disty[lay]      = topp-x[lay];
  num[lay]        = Math.sqrt(Math.pow(distx[lay],2) + Math.pow(disty[lay],2))/step;
  dx[lay]         = distx[lay]/num[lay];
  dy[lay]         = disty[lay]/num[lay];
  le[lay]         = lef;
  to[lay]         = topp;
  st[lay]         = step;
  myTimers[lay]   = setInterval("moveItTo("+le[lay]+","+to[lay]+","+dx[lay]+","+dy[lay]+",'"+funct+"','"+lay+"')",vel);
}

// Bewegen der Div-Tags und 
// -optional- Ausführung einer Funktion am Ende
// der Bewegung.
function moveItTo(lef,topp,stepx,stepy,funct,lay)
{ 
  if(stepcount[lay]<num[lay])
  {
    z[lay]         = parseFloat(z[lay]+stepx);
    pa[lay].left   = 27;                //z[lay];
    x[lay]         = parseFloat(x[lay]+stepy);
    pa[lay].top    = x[lay];
    stepcount[lay] = stepcount[lay]+1;
  }
  else
  {
    finish(lef,topp,funct,lay);
  }
}

// was am Ende der Bewegung passieren soll.
function finish(lef,topp,funct,lay)
{
  if(myTimers[lay]){clearInterval(myTimers[lay]);myTimers[lay]=0;}
  pa[lay].left = lef;
  pa[lay].top  = topp;
  if(funct)
  {
    eval(funct);
  }
}

// Versetzen an eine andere Position
function getitTo(lay,endx,endy)
{
  basix(lay);
  pa[lay].left = endx;
  pa[lay].top  = endy;
}
