var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

function DHTML_init() {
 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if(document.layers && !OP) {
   DHTML = 1;
   NS = 1;
 }
}

function enterCSS() {
  if (screen.width == 640)
    document.write('<link rel="stylesheet" type="text/css" href="0640.css">');
  if ((screen.width > 640) && (screen.width <= 800))
    document.write('<link rel="stylesheet" type="text/css" href="0800.css">');
  if ((screen.width > 800) && (screen.width <= 1024))
    document.write('<link rel="stylesheet" type="text/css" href="1024.css">');
  if (screen.width > 1024)
    document.write('<link rel="stylesheet" type="text/css" href="1280.css">');
}

DHTML_init();
enterCSS();
window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);

var bird1 = new Image();
bird1.src = "kuckuck1.gif";
var bird2 = new Image();
bird2.src = "kuckuck2.gif";
var bird3 = new Image();
bird3.src = "kuckuck3.gif";
var menutip = new Image();
menutip.src = "menutip.gif";

if (MS) {
	innerW  = "document.body.clientWidth";
	innerH  = "document.body.clientHeight";
	offsetX = "document.body.scrollLeft";
	offsetY = "document.body.scrollTop";
	mouseX  = "window.event.clientX";
	mouseY  = "window.event.clientY";
}else {
	innerW  = "window.innerWidth";
	innerH  = "window.innerHeight";
	offsetX = "window.pageXOffset";
	offsetY = "window.pageYOffset";
	mouseX  = "window.event.pageX";
	mouseY  = "window.event.pageY";
}



function setSize() {
  window.document.mainwidth.width=eval(innerW)-20;
  window.document.head.width  = 649 * screen.width/1200;
  window.document.head.height = 150 * screen.height/900;
  document.getElementsByTagName("div")[0].style.visibility = "visible";
}



function OpenPic(adresse) {
  f = window.open(adresse,'PicPopup',
  'width=1,height=1,left='+(screen.availWidth/2)+',top='+(screen.availHeight/2)+',toolbar=0,scrollbars=1,marginheight=0,marginwidth=0');
  f.focus();
}


/***********************************************************/


var cnt    = 1;

function BirdMove() {
  document.body.style.overflow='hidden';

  var ssizex =  80 * screen.width/1200;
  var ssizey = 120 * screen.height/900;
  var esizex = 154 * screen.width/1200;
  var esizey = 228 * screen.height/900;
  var sposx  = 120 * eval(innerW)/1200;
  var sposy  = 120 * eval(innerH)/900;
  var eposx  = (eval(innerW)-esizex)/2;
  var eposy  = (eval(innerH)-esizey)/2;
  var sstepx = (esizex-ssizex)/14;
  var sstepy = (esizey-ssizey)/14;
  var mstepx = (eposx-sposx)/14;
  var mstepy = (eposy-sposy)/14;

  if (cnt==1) {
    document.getElementsByTagName("div")[2].style.left = (eval(innerW)-600)/2;
    document.getElementsByTagName("div")[2].style.top  = eval(innerH)*3/4;
    document.getElementsByTagName("div")[2].style.visibility = "visible"
  }
  if (cnt<15) {
    if (cnt % 2 ==0) {
      window.document.bird.src=bird1.src;
    } else {
      window.document.bird.src=bird2.src;
    }
    window.document.bird.width  = ssizex+cnt*sstepx;
    window.document.bird.height = ssizey+cnt*sstepy;
    document.getElementsByTagName("div")[0].style.left = sposx+cnt*mstepx;
    document.getElementsByTagName("div")[0].style.top  = sposy+cnt*mstepy;

    cnt++;
    window.setTimeout("BirdMove()",300);
  }

  if ((cnt>14) && (cnt<24)) {
    if (cnt % 2 ==0) {
      window.document.bird.src=bird3.src;
    } else {
      window.document.bird.src=bird1.src;
    }
    cnt++;
    window.setTimeout("BirdMove()",600);
  }
  if (cnt==24) {
    window.document.menutip.width=134;
    window.document.menutip.height=87;
    document.getElementsByTagName("div")[1].style.left=eposx-134;
    document.getElementsByTagName("div")[1].style.top=eposy;
    window.setTimeout("window.location.href='main.htm'",3000);
  }
}




function checkLocation() {
  var sizex      = 80 * screen.width/1200;
  var sizey      = 120 * screen.height/900;
  var availableX = eval(innerW);
  var abstandY   = 30 * screen.height/1200;

  var currentX = eval(offsetX);
  var currentY = eval(offsetY);

  x = availableX-(sizex+abstandY)+currentX;
  y = abstandY+currentY;

  document.getElementsByTagName("div")[1].style.left = x;
  document.getElementsByTagName("div")[1].style.top  = y;

  sizex = 220 * screen.width/1200;

  x = availableX-(sizex+abstandY)+currentX;
  y = abstandY*2+sizey+currentY;

  document.getElementsByTagName("div")[2].style.left = x;
  document.getElementsByTagName("div")[2].style.top  = y;
}





function fixMenu() {
  checkLocation();
  window.document.menubird.width  = 80 * screen.width/1200;
  window.document.menubird.height = 120 * screen.height/900;
  window.document.menuback.width  = 220 * screen.width/1200;
  window.document.menuback.height = 230 * screen.height/900;

  setInterval('checkLocation()', 10);
}






function showMenu() {
  document.getElementsByTagName("div")[2].style.visibility = "visible";
}

function hideMenu() {
  document.getElementsByTagName("div")[2].style.visibility = "hidden";
}
