Mathias Beyer: laufende Funktion ab- / anschalten

Beitrag lesen

Hallo,

ich brauch eine funktion mit setTimeout die abrupt abgeschaltet werden kann und wieder angeschaltet. Ich habes wie folgt versucht.

  
function show()	{  
   if (hint == 1)	{  
      document.all.dreist.innerHTML = '<img src="3st_show.gif" height="340" width="300" alt="">'; };  
   };  
			  
  
function animation()	{  
   var rnd  = Math.floor(Math.random() * 8);  
   var rndT = Math.floor(Math.random() * 5000);  
  
   if ((rnd == 1) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_blnk.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 2) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_clos.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 3) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_look.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 4) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_shak.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 5) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_hnds.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 6) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_slpt.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 7) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_susp.gif" height="340" width="300" alt="">'; };  
   if ((rnd == 8) && (hint == 0))	{  
      document.all.dreist.innerHTML = '<img src="3st_real.gif" height="340" width="300" alt="">'; };  
  
   window.setTimeout("animation()", rndT);  
  
};

diese Funktion steht im head, kann also sofort ausgeführt werden, im body habe ich ein Event mit der variable hint, wenn also das event von statten geht soll die funktion mit setTimeout ausgeschaltet werden und die funktion mit hint angeschaltet und das widerholt.
Ich bin kläglich gescheitert. kann mir irgend jemand helfen