function flip(rid)
{
    current=(document.getElementById(rid).style.display == 'none') ? 'block' : 'none';
    document.getElementById(rid).style.display = current;
}

function werte()
{
  a = 2;  // x-Koordinate vom Schweinchen
  o = 20;  // y-Koordinate vom Schweinchen
  breite = 170; //Breite des Bereich in dem das Schwein läuft
  anfang = 10; //Startposition Schwein

  rechts = true;
  mitte = 0;

  hoch = true;

  schwein.style.left = a;

  setInterval('bewegung()', 50);

  stoppen = false;

}


function stop()
{
 stoppen = true;
 document.bild.src = 'lover.gif';
}

function weiter()
{
 stoppen = false;
 if (rechts == true){document.bild.src = 'rechts.gif';}else{document.bild.src = 'links.gif';}
}


function bewegung()
{


if (stoppen == false)
{

if (o > 20 && hoch == true)
{
 o-=4;
}
else
{
 hoch = false;
}


if (o < 50 && hoch == false)
{
 o+=4;
}
else
{
 hoch = true;
}


if (mitte < 1) 
{
if (rechts == true)
{
if (a < breite)
 {
  a+=5;
 }
 else
 {
  if (rechts = true){document.bild.src = 'vorne.gif'};
  mitte = 7;
  rechts = false;
 }
}
else
{
if (a > anfang)
 {
  a-=5;
 }
 else
 {
  document.bild.src = 'hinten.gif';
  mitte = 7;
  rechts = true;
 }
}
}
else
{
 mitte-=1;
 if (mitte == 0 && rechts == true){document.bild.src='rechts.gif';}
 if (mitte == 0 && rechts == false){document.bild.src='links.gif';}
}

schwein.style.left = a;
schwein.style.top = o;

}
} //ende bewegen

