var timeaus= 0;
var aktiv= 0;
var step= 0;
var modus='out';
var text;
var verzoegerung=200;
var AnzahlZeichen=90;
var timerId;
var AktNr=-1;
var Lauf1=1;
//var divwidth = 298;

function FensterTermine(Adresse) 
{
  MeinFenster = window.open(Adresse, "Termine", "width=800,height=450,left=100,top=200,dependent=yes,hotkeys=no,location=no,menubar=no,resizeable=no,scrollbars=yes,status=no,toolbar=no");
  MeinFenster.focus();
}
function FensterKontakt(Adresse) 
{
  MeinFenster = window.open(Adresse, "Kontakt", "width=440,height=610,left=100,top=140,dependent=yes,hotkeys=no,location=no,menubar=no,resizeable=no,scrollbars=yes,status=no,toolbar=no");
  MeinFenster.focus();
}
function FensterImpressum(Adresse) 
{
  MeinFenster = window.open(Adresse, "Impressum", "width=420,height=610,left=100,top=140,dependent=yes,hotkeys=no,location=no,menubar=no,resizeable=no,scrollbars=yes,status=no,toolbar=no");
  MeinFenster.focus();
}

function MoveObjektStep(Bildid,xstep,steps)
{
 // aktuelle x-Position
 help = document.getElementById(Bildid).style.marginLeft;
 xpos = parseInt(help);
 if (step >= steps) 
 {
  window.clearInterval(aktiv);
  clearTimeout(timeaus);
  timeaus= 0; 
  aktiv= 0;
  step= 0;
  if ( modus == 'in' )
  {
   // Nach einer gewissen Zeit aus dem Bild laufen lassen
   timeaus=setTimeout(function(){MoveObjektX(Bildid,xstep,steps);},8000);
   modus = 'out';
  }
  else
  {
   // sonst die naechste Grafik nehmen
   modus = 'in';
   SlideShowLoad();
  }
 }
 else
 {
  // neue Position
  new_xpos = xpos + xstep + 'px'; 
  document.getElementById(Bildid).style.marginLeft = new_xpos;
 }
 step++;
}

function MoveObjektX(Bildid,xstep,steps)
{
 delay = 50;
 aktiv = window.setInterval(function(){MoveObjektStep(Bildid,xstep,steps);},delay);
}

function SlideShowInit()
{
 if ( AktNr != -1 )
 {
  //Erstmal die momentan aktuelle Div auf hidden setzen
  Divid='produkt'+AktNr;
  help=document.getElementById(Divid);
  Divid2='produkttext'+AktNr;
  help2=document.getElementById(Divid2);
  help.style.visibility='hidden';
  help2.style.visibility='hidden';
 }

 //Dann die nächste Div zur Aktuellen machen
 if ( AktNr == MaxNr ) AktNr=0;
 else AktNr++;
 Divid='produkt'+AktNr;
 Divid2='produkttext'+AktNr;
 Bildid='bild'+AktNr;

 //Parameter festlegen
 xstep=10;
 min_xpos = 0-Math.round((divwidth-xwidth[AktNr])/2)-xwidth[AktNr]-100;
 max_xpos = Math.round((divwidth-xwidth[AktNr])/2)+xwidth[AktNr]+110;
 steps=parseInt(max_xpos-min_xpos)/xstep;
 steps=Math.round(steps/2);

 if ( Lauf1 != 1 ) // 1. Lauf
 {
  //Dann das zu slidene Bild an die richtige Position setzen 
  document.getElementById(Bildid).style.marginLeft = min_xpos+'px';
 }
 else Lauf1=0;

 //und die visibility der div auf visible setzen 
 help=document.getElementById(Divid);
 help2=document.getElementById(Divid2);
 help.style.visibility='visible';
 help2.style.visibility='visible';

 // Dann in der Mitte positionieren (bzw. beim 1. Lauf geht das bild raus)
 MoveObjektX(Bildid,xstep,steps);
}

function SlideShowLoad()
{
 if ( AktNr == -1 )
 {
  clearTimeout(timeaus);
  timeaus= 0; 
 }
 timeaus=setTimeout(function(){SlideShowInit();},100);
}

function SlideShowLoadBild1()
{
 timeaus=setTimeout(function(){SlideShowInit();},4000);
}

function change(anaus, seite)
{
 if (anaus=='ein')
 {
  bildchange = new Image();
  bildchange.src = "./images/Krone.gif";
  this.document["Krone"+seite].src=bildchange.src;
 }
 else
 {
  bildchange = new Image();
  bildchange.src = "./images/Krone.png";
  this.document["Krone"+seite].src=bildchange.src;
 }
}

function ticker() 
{
 text=nachricht.substring (0, AnzahlZeichen);
 document.getElementById('ticker').innerHTML=text
 nachricht=nachricht.substring (1, nachricht.length) + nachricht.substring (0, 1)
 timerId=setTimeout("ticker()", verzoegerung)
}

function popupBildergalerie (url) 
{
 fenster = window.open(url, "Bildergalerie", "width=800,height=400,resizable=no");
 fenster.focus();
 return false;
}


