<!--
var dx = 18;
var dy = 18;
var score = 50;
var less = 1;
var more = 11;
var time = 1000;
var counter = 0;
var visib = 7;
var level = 1;

ar_img = new Array ("images/catch/acka.gif","images/catch/pimbo1.gif","images/catch/pimbo2.gif","images/catch/pimbo3.gif",
                    "images/catch/galupy.gif","images/catch/diddl.gif","images/catch/wolly.gif","images/catch/auto2.gif",
                    "images/catch/hubi2.gif","images/catch/auto1.gif","images/catch/traktor.gif","images/catch/zug.gif",
                    "images/catch/moped.gif","images/catch/hubi.gif","images/catch/geist.gif","images/catch/zauber3.gif",
                    "images/catch/hexe2.gif","images/catch/hexe3.gif","images/catch/kuerbis1.gif","images/catch/zauber1.gif","images/catch/kuerbis2.gif");
ar_width = new Array (100,80,74,79,83,100,70,94,87,85,75,80,80,90,100,90,70,76,70,100,65);
ar_height = new Array (89,100,100,100,100,88,70,38,57,47,50,45,40,65,86,90,92,90,70,84,62);

arsp = new Array ("images/catch/sp-diddl1.gif","images/catch/sp-diddl2.gif","images/catch/sp-diddl1.gif",
                  "images/catch/sp-auto3.gif","images/catch/sp-auto2.gif","images/catch/sp-auto1.gif",
                  "images/catch/sp-zauber4.gif","images/catch/sp-zauber2.gif","images/catch/sp-zauber1.gif");
arsp_width = new Array (115,160,115,140,120,306,150,175,306);
arsp_height= new Array (121,149,121,140,80,112,72,197,156);

function init() {
  if (document.getElementById) {
    Targ1 = document.getElementById("Target1").style;
    Targ2 = document.getElementById("Target2").style;
    Targ3 = document.getElementById("Target3").style;
    Targ4 = document.getElementById("Target4").style;
    Targ5 = document.getElementById("Target5").style;
    Targ6 = document.getElementById("Target6").style;
    Targ7 = document.getElementById("Target7").style;
    Bar1 = document.getElementById("Sperre1").style;
    Bar2 = document.getElementById("Sperre2").style;
    Bar3 = document.getElementById("Sperre3").style;
    iBall = document.getElementById("Ball").style;
    Spuker = document.getElementById("Spuk").style;
  } else {
    Targ1 = document.Target1;
    Targ2 = document.Target2;
    Targ3 = document.Target3;
    Targ4 = document.Target4;
    Targ5 = document.Target5;
    Targ6 = document.Target6;
    Targ7 = document.Target7;
    Bar1 = document.Sperre1;
    Bar2 = document.Sperre2;
    Bar3 = document.Sperre3;
    iBall = document.Ball;
    Spuker = document.Spuk;

    document.captureEvents (Event.MOUSEMOVE);
  }
  document.onmousemove = moveHandler;
  
  wWidth = screen.width - 50;
  wHeight = screen.height - 50;
  window.resizeTo(wWidth,wHeight);
  window.moveTo(10,10);
  wWidth -= 150;
  wHeight -= 250;
  if (document.body.offsetWidth) {
    wWidth = document.body.offsetWidth - 100;
    wHeight = document.body.offsetHeight - 100
  }
  if (window.innerWidth) {
    wWidth = window.innerWidth - 100;
    wHeight = window.innerHeight - 100;
  } 
  walkspuk();
}

function moveHandler(evt) {
  if (document.all) {
    moveIE()
  } else {
    moveNS(evt);
  }
}

function newgame() {
  window.location = "catch_me.htm";
}
  
function showvisib(t,v) {
  t.visibility = v;
}

function showall() {
  showvisib(Targ1,"visible");
  showvisib(Targ2,"visible");
  showvisib(Targ3,"visible");
  showvisib(Targ4,"visible");
  showvisib(Targ5,"visible");
  showvisib(Targ6,"visible");
  showvisib(Targ7,"visible");
  visib = 7;
  counter = 0;
}
function playwow() {

  if (navigator.appName == "xxxMicrosoft Internet Explorer") 
    document.Wow.play();
  if (document.all) { msaudio.src="sounds/wow.wav"; }

}

function nextlevel() {
  level += 1;
  if (level < 10) {    
    playwow();   
    alert ("HURRA  GESCHAFFT !!!\n\n        LEVEL   " + level);
  }
  showlevel();
  less += 1;
  more += 1;
  time -= 20;
  switch (level) {
    case 2:
      showvisib(Bar2,"visible");
      break;
    case 3:
      dx = 16;
      dy = 16;
      document.b1.src = "images/catch/ball-d.gif";
      newimages(0);
      newbars(0);
      break;
    case 4:
      walkallbars();
      break;
    case 5:
      dx = 18;
      dy = 14;
      document.b1.src = "images/catch/ball-a.gif";
      newimages(7);
      newbars(3);
      break;
    case 6:
      showvisib(Bar3,"visible");
      break;
    case 8:
      dx = 18;
      dy = 18;
      document.b1.src = "images/catch/ball-z.gif";
      newimages(14);
      newbars(6);
      break;
    case 10:
      alert("Immer noch nicht die Schnauze voll?\nNa dann viel Spaß bei der nächsten Runde!");
      newgame();
      break;
    default:
      break;
  }
  showall();
}

function getsrc(z) {
  if (z == "b") 
    src = "images/catch/nb.gif";
  else
    eval("src = 'images/catch/n" + z + ".gif'");
  return src;
}

function showscore() {
  var s;
  var z;
  s = "0" + score;
  z = s.substr(s.length-1,1);
  document.no3.src = getsrc(z);
  z = s.substr(s.length-2,1);
  document.no2.src = getsrc(z);
  if (s.length > 3) {
    z = s.substr(s.length-3,1);
    document.no1.src = getsrc(z);
  } else {
    document.no1.src = "images/catch/nb.gif";
  }
}

function showlevel() {
  var s;
  var z;
  s = "0" + level;
  z = s.substr(s.length-1,1);
  document.lno.src = getsrc(z);
}

function countdown() {
  score -= less;
  showscore();
  if (score <= 0) {
    alert("GAME OVER");
    newgame();
  }
}

function addscore(t) {
  score += more;
  counter += 1;
  showscore();
  if (counter >= 5) {
    showvisib(t,"hidden");
    visib -=1;
    if (visib == 0) {
      nextlevel();
    }
  }
}

function change (e,x,y) {
  e.left = x;
  e.top = y;
}

function move (e,x,y,v) {
  e.left += x;
  if (e.style)
    e.style.left += x;
  e.top += y;
  if (e.style)
    e.style.top += y;
  e.visibility = v;
  if (e.style)
    e.style.visibility = v;
}

function moveIE () {
  change (iBall, event.x - dx, event.y - dy);
}

function moveNS (event) {
  change (iBall,event.pageX -dx, event.pageY - dy);
}

function Erdbeben () {
  for (i=0; i<20; i++) {
    window.moveBy (+15, -10);
    window.moveBy (-15, +5);
    window.moveBy (-15, 0);
    window.moveBy (+15, +5);
  }
}
function walk(t) {
  x = Math.round(Math.random() * wWidth);
  y = Math.round(Math.random() * wHeight);
  change (t, x, y);
}
  
function walkall() {
  walk(Targ1);
  walk(Targ2);
  walk(Targ3);
  walk(Targ4);
  walk(Targ5);
  walk(Targ6);
  walk(Targ7);
  
  window.setTimeout('walkall();',time);
}

function walkbar(t) {
  x = Math.round(Math.random() * wWidth - 100);
  y = Math.round(Math.random() * wHeight - 100);
  change (t, x, y);
}

function walkallbars() {
  walkbar(Bar2);
  if (level > 5) 
    walkbar(Bar1);
  if (level > 6) 
    walkbar(Bar3);
  window.setTimeout('walkallbars();',time);
}

function walkspuk() {
  walkbar(Spuker);
  window.setTimeout('walkspuk();',2000);
}

function newimages(n) {
  for (i=1; i<=7; i++) {
    eval("document.i" + i + ".src = ar_img[" + (i-1) + "+n]");
    eval("document.i" + i + ".width = ar_width[" + (i-1) + "+n]");
    eval("document.i" + i + ".height = ar_height[" + (i-1) + "+n]");
  }
}
  
function newbars(n) {
  for (i=1; i<=3; i++) {
    eval("document.sp" + i + ".src = arsp[" + (i-1) + "+n]");
    eval("document.sp" + i + ".width = arsp_width[" + (i-1) + "+n]");
    eval("document.sp" + i + ".height = arsp_height[" + (i-1) + "+n]");
  }
}

function showrules() {
  alert("Spielregeln ?\nDieses Spiel hält sich an keine Regeln !!!");
}

function Spuken() {
  alert ("Spuk - Spuk - Spuk");
}
//-->

