var ChaplinFensterbreite, ChaplinFensterhoehe, Chaplinhh, Chaplinhstart;
var Chaplini, Chaplinj, Chaplinaktiv1, Chaplinaktiv2;

function ChaplinFensterbreite() {
  if (window.innerWidth) {
    return Number(window.innerWidth);
  } else if (document.body && document.body.offsetWidth) {
    return Number(document.body.offsetWidth);
  } else {
    return 0;
  };
};

function ChaplinFensterhoehe() {
  if (window.innerHeight) {
    return Number(window.innerHeight);
  } else if (document.body && document.body.offsetHeight) {
    return Number(document.body.offsetHeight);
  } else {
    return 0;
  };
};

function chaplin() {
  ChaplinFensterbreite=ChaplinFensterbreite();
  ChaplinFensterhoehe=ChaplinFensterhoehe();
  if(ChaplinFensterbreite>ChaplinFensterhoehe) {
    Chaplinhstart=ChaplinFensterbreite;
  } else {
    Chaplinhstart=ChaplinFensterhoehe;
  };
  Chaplinhh=Math.ceil(Chaplinhstart/2);
  document.getElementById("spot_oben").style.height= Chaplinhh+"px";
  document.getElementById("spot_oben").style.width= Chaplinhstart+"px";
  document.getElementById("spot_oben").style.top = ( Math.ceil(ChaplinFensterhoehe/2) - Chaplinhh )+"px";
  document.getElementById("spot_oben").style.left = ( Math.ceil(ChaplinFensterbreite/2) - Chaplinhh )+"px";

  document.getElementById("spot_links").style.width = Chaplinhh +"px";
  document.getElementById("spot_links").style.height = "0px";
  document.getElementById("spot_links").style.top = (Math.ceil(ChaplinFensterhoehe/2)) +"px";
  document.getElementById("spot_links").style.left = ( Math.ceil(ChaplinFensterbreite/2) - Chaplinhh )+"px";

  document.getElementById("spot_rechts").style.width= Chaplinhh+1 +"px";
  document.getElementById("spot_rechts").style.height = "0px";
  document.getElementById("spot_rechts").style.top = (ChaplinFensterhoehe/2) +"px";
  document.getElementById("spot_rechts").style.left = Chaplinhh-1 +"px";

  document.getElementById("spot_unten").style.height= Chaplinhh+"px";
  document.getElementById("spot_unten").style.width= Chaplinhstart+"px";
  document.getElementById("spot_unten").style.top = (ChaplinFensterhoehe/2)+"px";
  document.getElementById("spot_unten").style.left = ( (ChaplinFensterbreite/2) - Chaplinhh )+"px";

  document.getElementById("spot").style.width = "4px";
  document.getElementById("spot").style.height = "4px";
  document.getElementById("spot").style.top = (ChaplinFensterhoehe/2)-1 +"px";
  document.getElementById("spot").style.left = Chaplinhh-1 +"px";

  Chaplinwachsen();
};

function Chaplinwachsen() {
  Chaplini=1;
  Chaplinj=1;
  Chaplinaktiv1 = window.setInterval("Chaplingrow()", 20);
};

function Chaplingrow() {
  document.getElementById("spot_oben").style.height = (Chaplinhh-Chaplinj)+"px";

  document.getElementById("spot_links").style.top = ((ChaplinFensterhoehe/2)-Chaplini-1)+"px";
  document.getElementById("spot_links").style.height = ((2*Chaplinj)+2)+"px";
  document.getElementById("spot_links").style.width= (Chaplinhh-Chaplinj)+"px";

  document.getElementById("spot_rechts").style.top = (((ChaplinFensterhoehe/2)-Chaplinj)-1)+"px";
  document.getElementById("spot_rechts").style.left = ((ChaplinFensterbreite/2+Chaplinj)-1)+"px";
  document.getElementById("spot_rechts").style.height = (2*Chaplinj)+2+"px";
  document.getElementById("spot_rechts").style.width= (Chaplinhh-Chaplinj)+1+"px";

  document.getElementById("spot_unten").style.height = (Chaplinhh-Chaplinj)+"px";
  document.getElementById("spot_unten").style.top = ((ChaplinFensterhoehe/2)+Chaplinj)+"px";

  document.getElementById("spot").style.height = ((2*Chaplinj)+2)+"px";
  document.getElementById("spot").style.width =  ((2*Chaplinj)+2)+"px";
  document.getElementById("spot").style.top = ((ChaplinFensterhoehe/2) -Chaplinj-1)+"px";
  document.getElementById("spot").style.left = ((ChaplinFensterbreite/2) -Chaplinj-1)+"px";

  Chaplini=Chaplini*1.05+1;
  Chaplinj=Math.ceil(Chaplini);
  if (Chaplini >= Chaplinhh) {
    window.clearInterval(Chaplinaktiv1);
    Chaplinwachsen2();
  };
};

function Chaplinwachsen2() {
  Chaplinstop = Math.ceil(Math.sqrt((ChaplinFensterbreite*ChaplinFensterbreite)+(ChaplinFensterhoehe*ChaplinFensterhoehe))*0.6);
  document.getElementById("spot_oben").style.visibility = "hidden";
  document.getElementById("spot_links").style.visibility = "hidden";
  document.getElementById("spot_rechts").style.visibility = "hidden";
  document.getElementById("spot_unten").style.visibility = "hidden";
  Chaplinaktiv2 = window.setInterval("Chaplingrow2()", 20);
};

function Chaplingrow2() {
  document.getElementById("spot").style.height = ((2*Chaplinj)+2)+"px";
  document.getElementById("spot").style.width = ((2*Chaplinj)+2)+"px";
  document.getElementById("spot").style.top = ((ChaplinFensterhoehe/2) -Chaplinj-1)+"px";
  document.getElementById("spot").style.left = ((ChaplinFensterbreite/2) -Chaplinj-1)+"px";
  Chaplini=Chaplini*1.05+1;
  Chaplinj=Math.ceil(Chaplini);
  if (Chaplini >= Chaplinstop) {
    window.clearInterval(Chaplinaktiv2);
    document.getElementById("spot").style.visibility = "hidden";
  };
};
