Stefan: setInterval / clearInterval

Beitrag lesen

Vielleicht ist der Bug auch hier im Code versteckt :s
Ich weiß nicht mehr weiter,
danke schonmal für Eure Hilfe!
Mein Code mit dem ich das Ganze versuche:

  
var farbe = 1;  
var counteraktiv;  
var counterstart = "stop";  
var startcount = "no";  
  
  
function LoadPage(page,formdata) {  
 .....  
 counterstart = 120;  
 startcount = "yes";  
 ....  
 xmlhttp.onreadystatechange = function(){  
  ....  
  if (startcount == "yes"){  
      counteraktiv = window.setInterval("counter('down')", 1000);	  
  }  
 }  
}  
  
  
function counter (type) {  
	if (counterstart == "stop"){  
		window.clearInterval(counteraktiv);  
		document.body.style.backgroundImage = "url('/images/background_stripes.png')";  
		document.getElementById('timer').innerHTML="test";  
	}  
	else {  
		if (type == "down"){  
			counterstart = counterstart - 1;	  
			if (counterstart <= 90){  
				if (farbe == 1){  
					document.body.style.backgroundImage = "none";  
					document.bgColor = "red";  
					farbe = 2;  
				}  
				else {  
					document.body.style.backgroundImage = "url('images/background_stripes.png')";  
					document.bgColor = "#c5ccd4";  
					farbe = 1;  
				}  
			}  
		}  
		else {  
			counterstart = counterstart + 1;	  
		}  
	  
		if (counterstart > 0){  
			var min = Math.floor(counterstart / 60);  
			var sec = counterstart - (min * 60);  
		}  
		if (document.getElementById('timer') == null){  
			window.clearInterval(counteraktiv);  
			document.body.style.backgroundImage = "url('images/background_stripes.png')";  
			document.getElementById('timer').innerHTML="test";  
		}  
		else if (min > 0){  
			document.getElementById('timer').innerHTML = min + "''" + sec + "'";  
		}  
		else {  
			document.getElementById('timer').innerHTML = sec + "'";  
		}  
	}  
		  
	  
	  
	//if (i >= 10)  
	//	window.clearInterval(aktiv);  
}