//Configure the below three variables (BallSpeed from 1 to 50, larger is faster)
var ballWidth = 40;
var ballHeight = 40;
var BallSpeed = 11;

var maxBallSpeed = 50;
var xMax;
var xMin = -28;
var yMax;
var xPos1 = 21;
var yPos1 = 275;
var xPos2 = 21;
var yPos2 = 215;
var xPos3 = 21;
var yPos3 = 155;
var xPos4 = 21;
var yPos4 = 115;
var xPos5 = 21;
var yPos5 = 95;
var xPos6 = 21;
var yPos6 = 175;
var xPos7 = 21;
var yPos7 = 255;
var xPos8 = 21;
var yPos8 = 135;
var xPos9 = 21;
var yPos9 = 195;
var xPos10 = 21;
var yPos10 = 235;
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;
var newYDir;

function initializeBall() {
   if (document.all) {
      xMax = document.body.clientWidth
	if (xMax < 650) {xMax = 650}
      yMax = document.body.clientHeight
      document.all("bubble1").style.visibility = "visible";
      document.all("bubble2").style.visibility = "visible";
      document.all("bubble3").style.visibility = "visible";
      document.all("bubble4").style.visibility = "visible";
      document.all("bubble5").style.visibility = "visible";
      document.all("bubble6").style.visibility = "visible";
      document.all("bubble7").style.visibility = "visible";
      document.all("bubble8").style.visibility = "visible";
      document.all("bubble9").style.visibility = "visible";
      document.all("bubble10").style.visibility = "visible";
      }
   else if (document.layers) {
      xMax = window.innerWidth;
      yMax = window.innerHeight;
      document.layers["bubble1"].visibility = "show";
      document.layers["bubble2"].visibility = "show";
      document.layers["bubble3"].visibility = "show";
      document.layers["bubble4"].visibility = "show";
      document.layers["bubble5"].visibility = "show";
      document.layers["bubble6"].visibility = "show";
      document.layers["bubble7"].visibility = "show";
      document.layers["bubble8"].visibility = "show";
      document.layers["bubble9"].visibility = "show";
      document.layers["bubble10"].visibility = "show";
      }
   setTimeout('moveBall()',400);
   }

function moveBall() {
   if (superballRunning == true) {
      calculatePosition();
      if (document.all) {
         document.all("bubble1").style.left = xPos1;
         document.all("bubble1").style.top = yPos1;
         document.all("bubble2").style.left = xPos2;
         document.all("bubble2").style.top = yPos2;
         document.all("bubble3").style.left = xPos3;
         document.all("bubble3").style.top = yPos3;
         document.all("bubble4").style.left = xPos4;
         document.all("bubble4").style.top = yPos4;
         document.all("bubble5").style.left = xPos5;
         document.all("bubble5").style.top = yPos5;
         document.all("bubble6").style.left = xPos6;
         document.all("bubble6").style.top = yPos6;
         document.all("bubble7").style.left = xPos7;
         document.all("bubble7").style.top = yPos7;
         document.all("bubble8").style.left = xPos8;
         document.all("bubble8").style.top = yPos8;
         document.all("bubble9").style.left = xPos9;
         document.all("bubble9").style.top = yPos9;
         document.all("bubble10").style.left = xPos10;
         document.all("bubble10").style.top = yPos10;
         }
      else if (document.layers) {
         document.layers["bubble1"].left = xPos1;
         document.layers["bubble1"].top = yPos1;
         document.layers["bubble2"].left = xPos2;
         document.layers["bubble2"].top = yPos2;
         document.layers["bubble3"].left = xPos3;
         document.layers["bubble3"].top = yPos3;
         document.layers["bubble4"].left = xPos4;
         document.layers["bubble4"].top = yPos4;
         document.layers["bubble5"].left = xPos5;
         document.layers["bubble5"].top = yPos5;
         document.layers["bubble6"].left = xPos6;
         document.layers["bubble6"].top = yPos6;
         document.layers["bubble7"].left = xPos7;
         document.layers["bubble7"].top = yPos7;
         document.layers["bubble8"].left = xPos8;
         document.layers["bubble8"].top = yPos8;
         document.layers["bubble9"].left = xPos9;
         document.layers["bubble9"].top = yPos9;
         document.layers["bubble10"].left = xPos10;
         document.layers["bubble10"].top = yPos10;
         }
      setTimeout('moveBall()',30);
      }
   }

function calculatePosition() {
   if (yPos1 < 126) {
      yPos1 = 340;
      xPos1 = xMin + 80;
   }
   else {
      yPos1 = yPos1 - 3;
      xPos1 = xMin + 80;
   }
   if (yPos2 < 126) {
      yPos2 = 340;
      xPos2 = xMin + 90;
   }
   else {
      yPos2 = yPos2 - 2;
      xPos2 = xMin + 90;
   }
   if (yPos3 < 126) {
      yPos3 = 340;
      xPos3 = xMin + 100;
   }
   else {
      yPos3 = yPos3 - 4;
      xPos3 = xMin + 100;
   }
   if (yPos4 < 126) {
      yPos4 = 340;
      xPos4 = xMin + 110;
   }
   else {
      yPos4 = yPos4 - 2;
      xPos4 = xMin + 110;
   }
   if (yPos5 < 126) {
      yPos5 = 340;
      xPos5 = xMin + 120;
   }
   else {
      yPos5 = yPos5 - 3;
      xPos5 = xMin + 120;
   }
   if (yPos6 < 126) {
      yPos6 = 340;
      xPos6 = xMin + 130;
   }
   else {
      yPos6 = yPos6 - 4;
      xPos6 = xMin + 130;
   }
   if (yPos7 < 126) {
      yPos7 = 340;
      xPos7 = xMin + 140;
   }
   else {
      yPos7 = yPos7 - 2;
      xPos7 = xMin + 140;
   }
   if (yPos8 < 126) {
      yPos8 = 340;
      xPos8 = xMin + 150;
   }
   else {
      yPos8 = yPos8 - 3;
      xPos8 = xMin + 150;
   }
   if (yPos9 < 126) {
      yPos9 = 340;
      xPos9 = xMin + 160;
   }
   else {
      yPos9 = yPos9 - 2;
      xPos9 = xMin + 160;
   }
   if (yPos10 < 126) {
      yPos10 = 340;
      xPos10 = xMin + 170;
   }
   else {
      yPos10 = yPos10 - 3;
      xPos10 = xMin + 170;
   }
}

if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= "4.1") {
  if (document.all||document.layers)
	window.onload = initializeBall;
	window.onresize = new Function("window.location.reload()");
} else if (navigator.appName != "Netscape") {
  if (document.all||document.layers)
	window.onload = initializeBall;
	window.onresize = new Function("window.location.reload()");
}

