
function flyingBall(elemRef, xPosInit, yPosInit, xOnInit, yOnInit, step, delay) {
	var me = this;
	this.elem = getEl(elemRef);

	this.start = function() {
		this.elem.style.left = xPosInit;
		this.elem.style.top = yPosInit;
		this.elem.xOn = xOnInit;
		this.elem.yOn = yOnInit;
		this.intervalID = setInterval(function() {me.flyBall()}, delay); // Has got to be me!

		this.flyBall = function() {
			var xPos = 0;
			var yPos = 0;

			xPos = parseInt(this.elem.style.left);
			yPos = parseInt(this.elem.style.top);

			if ((this.elem.xOn) && ((iWidth + xPos + step) >= width)) this.elem.xOn = false;
			else if ((!this.elem.xOn) && (xPos - step <= 0)) this.elem.xOn = true;

			if ((this.elem.yOn) && ((iHeight + yPos + step) >= height)) this.elem.yOn = false;
			else if ((!this.elem.yOn) && (yPos - step <= 0)) this.elem.yOn = true;

			if (this.elem.xOn) this.elem.style.left = xPos + step + 'px';
			else this.elem.style.left = xPos - step + 'px';

			if (this.elem.yOn) this.elem.style.top = yPos + step + 'px';
			else this.elem.style.top = yPos - step + 'px';
		}

		this.clearBall = function() {
			clearInterval(this.intervalID);
		}
	}
}

