//----------------------------------------------------------------
//JavaScript - Datei
//----------------------------------------------------------------
var pos_fenster = 150;
var pos_ballon = 300;
var pos_splitter = 300;
var ballonhoehe = 129;
var splitterhoehe = 129;
var gesamthoehe = 0;
var updown = 1;
var wurmaktiv = 0;
var warte = 15;
var posx = 0;
var posy = 0;
var bereiche = 0;	
var tmout = null;
document.onclick = mousepos;	

function FensterHoehe () {
  if (window.innerHeight) { return window.innerHeight; } 
  else if (document.body && document.body.offsetHeight) {return document.body.offsetHeight;} 
  else {return 1200; }
}

function ballon() {
      if (updown == 1) {pos_ballon = pos_ballon + 4;} else {pos_ballon = pos_ballon - 2;}
      pos_fenster = pos_fenster - 25;
      if (pos_ballon >= gesamthoehe ) { 
      			updown = -1;
       			document.getElementById("b2").style.backgroundImage = "url('_pics/ballonplatzt.png')";
       			if (warte > 0) {
       				pos_ballon = pos_ballon + 2;
       				warte--;
       				}
       			}
      if (warte == 0) {document.getElementById("b2").style.backgroundImage = "url('_pics/ballonbruch.png')";}
      if (pos_ballon > 15) document.getElementById("b2").style.bottom = pos_ballon + "px";
      if (pos_fenster < 0 ) pos_fenster = 0;
      document.getElementById("f3").style.bottom = pos_fenster + "px";
      if (pos_ballon > pos_fenster) {if (pos_ballon == gesamthoehe) clearInterval(ballon());}
   }

function splitter() {
      pos_splitter = pos_splitter - 5;
      if (pos_splitter > 5) {document.getElementById("kb0").style.bottom = pos_splitter + "px";}
      else {
      	clearInterval(tmout);
			document.getElementById("kb0").style.display = "none";
      	}
   }

function ballon_move(){
	gesamthoehe = FensterHoehe() - ballonhoehe;
   setInterval('ballon()',5);
} 

function mousepos(e){
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
}

function kb(bereich){	
	document.onclick = mousepos;	
	if (posx > 0) { 
		document.getElementById(bereich).innerHTML = "";
		document.getElementById(bereich).style.backgroundImage = "url('_pics/"+bereich+"0.png')";
		document.getElementById("kb0").style.display = "block";
		pos_splitter = FensterHoehe() - splitterhoehe - posy;  
		//alert("x=" + posx + " y=" + posy + " Fensterhöhe=" + FensterHoehe() + " splitter.bottom=" + pos_splitter);
      document.getElementById("kb0").style.bottom = pos_splitter + 60 + "px";
      document.getElementById("kb0").style.left = posx - 60 + "px";
   	tmout = setInterval('splitter()',15);
   	bereiche++;
   	}
   if (bereiche == 9) {
   	for (a=1;a<4;a++){
   		for (b=1;b<4;b++){
   			document.getElementById("kb"+a+b).style.backgroundImage = "url('_pics/kb"+a+b+".png')";
   		}
   	}
   }
} 

function wurm(){
		//document.getElementById("wurm").innerHTML = "";
		if (wurmaktiv == 0) {
			document.getElementById("wurm").style.backgroundImage = "url('_pics/wurm.png')";
			wurmaktiv = 1;
			}
		else {
			document.getElementById("wurm").style.backgroundImage = "url('_pics/spacer.gif')";
			wurmaktiv = 0;
		}
} 

function aus() {
    document.getElementById('hint').style.visibility = "hidden";
}

function an(txt) {
    document.getElementById('hinttext').innerHTML = txt + "<center><a href=javascript:aus();><img src='_pics/btn_close.png' border=0></a></center>";
    document.getElementById('hint').style.visibility = "visible";
}


