
function Galerie_Init(count,stepx,stepy,startx,starty) {
  var i;
  this.PCount=0;
  for (i=0;i<count;i++)
    this.AddPoint(startx+i*stepx,starty+i*stepy);
  this.Pos();
}

function Galerie_Pos() {
  with (this)  {
    var i;
    for (i=0;i<ElCount;i++)  {
      Elements[i].left=Pointsx[(current+Numplus[i])%PCount]+Elleft[i];
      Elements[i].top=Pointsy[(current+Numplus[i])%PCount]+Eltop[i];
    }
  }
}

function Galerie_TimerFunc() {
  with (this)  {
    switch (modus)    {
      case 0:
        current=(current+1)%PCount;
        this.Pos();
	break;
      case 1:
        current=(current+PCount-1)%PCount;
        this.Pos();
        break;
    }
    if (((current+Numplus[eltarget])%PCount)==ptarget)    {
      this.eltarget=-1;
      this.ptarget=-1;
      this.timestep=0;
    }
  }
}

function Galerie_Add_Point(pointleft,pointtop) {
  with (this)  {
    Pointsx[PCount]=pointleft;
    Pointsy[PCount]=pointtop;
    PCount++;
  }
}

function Galerie_Add_Element(elementname,numplus,elleft,eltop) {
  with (this)  {
    Elleft[ElCount]=elleft;
    Eltop[ElCount]=eltop;
    if (window.document.all)
      Elements[ElCount]=eval("window.document.all."+elementname+".style");
    else
      if (typeof(window.document.getElementById)=="function")
        Elements[ElCount]=window.document.getElementById(elementname).style;
      else
        Elements[ElCount]=eval("window.document."+elementname);
    Numplus[ElCount]=numplus;
    ElCount++;
  }
}

function Galerie_RoTo(eltarget,ptarget) {
  if ((eltarget>=0)&&(ptarget>=0))  {
    this.eltarget=eltarget%this.ElCount;
    this.ptarget=ptarget%this.PCount;
  }
  else  {
    this.eltarget=-1;
    this.ptarget=-1;
  }
  this.timestep=this.time_step;
}

function Galerie_Animate(modus) {
  this.timestep=this.time_step;
  this.modus=modus;
  timer_start();
}

function Galerie(timestep) {
  this.RoTo=Galerie_RoTo;
  this.Init=Galerie_Init;
  this.Animate=Galerie_Animate;
  this.TimerFunc=Galerie_TimerFunc;
  this.Pos=Galerie_Pos;
  this.AddElement=Galerie_Add_Element;
  this.AddPoint=Galerie_Add_Point;
  this.time_step=timestep;
  this.eltarget=-1;
  this.ptarget=-1;
  this.PCount=0;
  this.ElCount=0;
  this.Pointsx=new Array();
  this.Pointsy=new Array();
  this.Elleft=new Array();
  this.Eltop=new Array();
  this.Elements=new Array();
  this.Numplus=new Array();
  this.current=0;
  this.timeval=0;
  timer_add_object(this);
}
