/* Author and Publisher: GoBeG - Liv Christiane Daria Göhner ©2009 ; URL: http://www.gobeg.com */
/* Bitte respektieren sie das Copyright und belassen diesen Hinweis im Kopf des Scripts.********/
/* Please respect the copyright and leave the notice in the head of the script. ****************/
/***********************************************************************************************/
/***********************************************************************************************/
/*******************Überwachung von MS Internet Explorer (initialisieren)*******************/
if (!window.Breite && document.body && document.body.offsetWidth) {
  window.onresize = neuAufbau;
  Breite = Fensterweite();
  Hoehe = Fensterhoehe();
}



/*******************Variablendeklaration*******************/
/*Objekte**/
var Hg, Lg, Bu1, Bu2, Bu3, Bu4, Bu5, Bu6, Bu7, Bu8, Bu9;

/**Randabstände (fix)**/
var HgLeftGap, HgTopGap, LgLeftGap, LgTopGap, Bu7LeftGap, Bu7TopGap, Bu8LeftGap, Bu8TopGap, Bu9LeftGap, Bu9TopGap;

/**Zufällige Winkelanfangsgeschwindigkeiten(fix)**/
var Bu1Geschw, Bu2Geschw, Bu3Geschw, Bu4Geschw, Bu5Geschw, Bu6Geschw;

/**Minima-/Maxima-Punkte der elliptishen Bahnen für die umlaufenden Buttons (fix)**/
var Bu1Radiusx, Bu1Radiusy, Bu2Radiusx, Bu2Radiusy, Bu3Radiusx, Bu3Radiusy, Bu4Radiusx, Bu4Radiusy, Bu5Radiusx, Bu5Radiusy, Bu6Radiusx, Bu6Radiusy;

/**Mittelpunktskoordinaten der Ellipsen (fix)**/
var Bu1X, Bu1Y, Bu2X, Bu2Y, Bu3X, Bu3Y, Bu4X, Bu4Y, Bu5X, Bu5Y, Bu6X, Bu6Y;

/**(Anfangs-)Winkel (werden durch Positionsberechnungen aktualisiert)**/
var Bu1Grad, Bu2Grad, Bu3Grad, Bu4Grad, Bu5Grad, Bu6Grad;

/**Startwert für Abweichung in z-Richtung**/
var Bu1z, Bu2z, Bu3z, Bu4z, Bu5z, Bu6z;



/*******************Zuweisung der Startwerte*******************/
/**Randabstände (fix)**/
  HgLeftGap  = Math.round(Breite/2-360),  HgTopGap  = Math.round(Hoehe/2-195);
  LgLeftGap  = Math.round (Breite/2-270), LgTopGap  = Math.round (Hoehe/2-133);
  Bu7LeftGap = Math.round(15),            Bu7TopGap = Math.round(Hoehe-50);
  Bu8LeftGap = Math.round(Breite/2-105),  Bu8TopGap = Math.round(Hoehe-50);
  Bu9LeftGap = Math.round(Breite-225),    Bu9TopGap = Math.round(Hoehe-50);

/**Zufällige Winkelanfangsgeschwindigkeiten(fix)**/
  Bu1Geschw = 3.5 + Math.random()*2;
  Bu2Geschw = 3.5 + Math.random()*2;
  Bu3Geschw = 3.5 + Math.random()*2;
  Bu4Geschw = 3.5 + Math.random()*2;
  Bu5Geschw = 3.5 + Math.random()*2;
  Bu6Geschw = 3.5 + Math.random()*2;

/**Minima-/Maxima-Punkte der elliptishen Bahnen für die umlaufenden Buttons (fix)**/
  Bu1Radiusx = (0.65+Math.random()*0.25)*Breite/2-100, Bu1Radiusy = (0.65+Math.random()*0.25)*Hoehe/2-10;
  Bu2Radiusx = (0.65+Math.random()*0.25)*Breite/2-100, Bu2Radiusy = (0.65+Math.random()*0.25)*Hoehe/2-10;
  Bu3Radiusx = (0.65+Math.random()*0.25)*Breite/2-100, Bu3Radiusy = (0.65+Math.random()*0.25)*Hoehe/2-10;
  Bu4Radiusx = (0.65+Math.random()*0.25)*Breite/2-100, Bu4Radiusy = (0.65+Math.random()*0.25)*Hoehe/2-10;
  Bu5Radiusx = (0.65+Math.random()*0.25)*Breite/2-100, Bu5Radiusy = (0.65+Math.random()*0.25)*Hoehe/2-10;
  Bu6Radiusx = (0.65+Math.random()*0.25)*Breite/2-100, Bu6Radiusy = (0.65+Math.random()*0.25)*Hoehe/2-10;

/**Mittelpunktskoordinaten der Ellipsen (fix)**/
  Bu1X = Math.round(Breite/2-100), Bu1Y = Math.round(Hoehe/2-30);
  Bu2X = Math.round(Breite/2-100), Bu2Y = Math.round(Hoehe/2-30);
  Bu3X = Math.round(Breite/2-100), Bu3Y = Math.round(Hoehe/2-30);
  Bu4X = Math.round(Breite/2-100), Bu4Y = Math.round(Hoehe/2-30);
  Bu5X = Math.round(Breite/2-100), Bu5Y = Math.round(Hoehe/2-30);
  Bu6X = Math.round(Breite/2-100), Bu6Y = Math.round(Hoehe/2-30);

/**(Anfangs-)Winkel in Einheiten von Pi (werden durch Positionsberechnungen aktualisiert)**/
  Bu1Grad = Math.random() * 2 * Math.PI;
  Bu2Grad = Math.random() * 2 * Math.PI;
  Bu3Grad = Math.random() * 2 * Math.PI;
  Bu4Grad = Math.random() * 2 * Math.PI;
  Bu5Grad = Math.random() * 2 * Math.PI;
  Bu6Grad = Math.random() * 2 * Math.PI;

/**Startwert für Abweichung in z-Richtung**/
  Bu1z = 0.0000;
  Bu2z = 0.0278;
  Bu3z = 0.0556;
  Bu4z = 0.0833;
  Bu5z = 0.1111;
  Bu6z = 0.1389;


function Init() {
/*******************Initialisierungsphase*******************/
  Hg  = eval(document.getElementById("Hintergrund"));
  Lg  = eval(document.getElementById("Logo"));
  Bu1 = eval(document.getElementById("Button1"));
  Bu2 = eval(document.getElementById("Button2"));
  Bu3 = eval(document.getElementById("Button3"));
  Bu4 = eval(document.getElementById("Button4"));
  Bu5 = eval(document.getElementById("Button5"));
  Bu6 = eval(document.getElementById("Button6"));
  Bu7 = eval(document.getElementById("Button7"));
  Bu8 = eval(document.getElementById("Button8"));
  Bu9 = eval(document.getElementById("Button9"));



/*******************Anfangspositionen*******************/
  Hg.style.position = "absolute";
  Hg.style.zIndex = "1";
  Hg.style.left = HgLeftGap;
  Hg.style.top = HgTopGap;

  Lg.style.position = "absolute";
  Lg.style.zIndex = "2";
  Lg.style.left = LgLeftGap;
  Lg.style.top = LgTopGap;

  Bu1.style.position = "absolute";
  Bu1.style.zIndex = "8"
  Bu1.style.top = 0;

  Bu2.style.position = "absolute";
  Bu2.style.zIndex = "7"
  Bu2.style.top = 0;

  Bu3.style.position = "absolute";
  Bu3.style.zIndex = "6"
  Bu3.style.top = 0;

  Bu4.style.position = "absolute";
  Bu4.style.zIndex = "5"
  Bu4.style.top = 0;

  Bu5.style.position = "absolute";
  Bu5.style.zIndex = "4"
  Bu5.style.top = 0;

  Bu6.style.position = "absolute";
  Bu6.style.zIndex = "3"
  Bu6.style.top = 0;

  Bu7.style.position = "absolute";
  Bu7.style.left = Bu7LeftGap;
  Bu7.style.top = Bu7TopGap;

  Bu8.style.position = "absolute";
  Bu8.style.left = Bu8LeftGap;
  Bu8.style.top = Bu8TopGap;

  Bu9.style.position = "absolute";
  Bu9.style.left = Bu9LeftGap;
  Bu9.style.top = Bu9TopGap;


/*******************Aufruf der neuen Positionsberechnungen der umlaufenden Buttons,*******************/
/*******************allen anderen Buttons bleiben an den vorgegebenen Plätzen*******************/
  Bu1Ellipse();
  Bu2Ellipse();
  Bu3Ellipse();
  Bu4Ellipse();
  Bu5Ellipse();
  Bu6Ellipse();
}



/*******************Positionsberechnungen der umlaufenden Buttons*******************/
/*******************Ellipsengleichung in Parameterform*******************/
function Bu1Ellipse() {
 Bu1Grad += Bu1Geschw/1000;
 Bu1z += 1/1000;
 if(Bu1Grad > 2*Math.PI) Bu1Grad = 0;
 if(Bu1z > 2*Math.PI) Bu1z = 0;
 Bu1.style.top  = Math.round(Bu1Y + (Bu1Radiusy * Math.cos(Bu1Grad))*Math.cos(Bu1z));
 Bu1.style.left = Math.round(Bu1X + (Bu1Radiusx * Math.sin(Bu1Grad))*Math.cos(Bu1z));
 window.setTimeout("Bu1Ellipse()",100/Bu1Geschw);
}
function Bu2Ellipse() {
 Bu2Grad += Bu2Geschw/1000;
 Bu2z += 1/1000;
 if(Bu2Grad > 2*Math.PI) Bu2Grad = 0;
 Bu2.style.top  = Math.round(Bu2Y + (Bu2Radiusy * Math.cos(Bu2Grad))*Math.cos(Bu2z));
 Bu2.style.left = Math.round(Bu2X + (Bu2Radiusx * Math.sin(Bu2Grad))*Math.cos(Bu2z));
 window.setTimeout("Bu2Ellipse()",100/Bu2Geschw);
}
function Bu3Ellipse() {
 Bu3Grad += Bu3Geschw/1000;
 Bu3z += 1/1000;
 if(Bu3Grad > 2*Math.PI) Bu3Grad = 0;
 Bu3.style.top  = Math.round(Bu3Y + (Bu3Radiusy * Math.cos(Bu3Grad))*Math.cos(Bu3z));
 Bu3.style.left = Math.round(Bu3X + (Bu3Radiusx * Math.sin(Bu3Grad))*Math.cos(Bu3z));
 window.setTimeout("Bu3Ellipse()",100/Bu3Geschw);
}
function Bu4Ellipse() {
 Bu4Grad += Bu4Geschw/1000;
 Bu4z += 1/1000;
 if(Bu4Grad > 2*Math.PI) Bu4Grad = 0;
 Bu4.style.top  = Math.round(Bu4Y + (Bu4Radiusy * Math.cos(Bu4Grad))*Math.cos(Bu4z));
 Bu4.style.left = Math.round(Bu4X + (Bu4Radiusx * Math.sin(Bu4Grad))*Math.cos(Bu4z));
 window.setTimeout("Bu4Ellipse()",100/Bu4Geschw);
}
function Bu5Ellipse() {
 Bu5Grad += Bu5Geschw/1000;
 Bu5z += 1/1000;
 if(Bu5Grad > 2*Math.PI) Bu5Grad = 0;
 Bu5.style.top  = Math.round(Bu5Y + (Bu5Radiusy * Math.cos(Bu5Grad))*Math.cos(Bu5z));
 Bu5.style.left = Math.round(Bu5X + (Bu5Radiusx * Math.sin(Bu5Grad))*Math.cos(Bu5z));
 window.setTimeout("Bu5Ellipse()",100/Bu5Geschw);
}
function Bu6Ellipse() {
 Bu6Grad += Bu6Geschw/1000;
 Bu6z += 1/1000;
 if(Bu6Grad > 2*Math.PI) Bu6Grad = 0;
 Bu6.style.top  = Math.round(Bu6Y + (Bu6Radiusy * Math.cos(Bu6Grad))*Math.cos(Bu6z));
 Bu6.style.left = Math.round(Bu6X + (Bu6Radiusx * Math.sin(Bu6Grad))*Math.cos(Bu6z));
 window.setTimeout("Bu6Ellipse()",100/Bu6Geschw);
}
