var ground = 300; //where the ball stops/bounces
var startYPos = 0; //starting point of the ball
var currentYPos = startYPos; //declaring and assigning a variable that keeps track of the current Y psosition of the ball

function bounceBall()	{
	//alert("boing!");
	var ball = document.getElementById("ball"); //reference to the ball object
	var speed = 10; //speed the ball moves
	//var newYPos;
	
	currentYPos += speed; //calculate the balls's next Y position
	
	//ball.style.top = oldYPos + "px";
	ball.style.top = currentYPos + "px"; //assign the balls's next position
	
	//alert(ball.style.top);
	//ground++;
	
	if (currentYPos > ground)  { //test to see if the ball has hit the ground
		clearInterval(intervalID); //if yes, stop executing the function
	}
}//end bounceBall()

var intervalID = setInterval("bounceBall()", 50); //execute the function bounceBall() every 100ms







































