
	function MoveElement(sObj) {
		eval(sObj + '.MoveElement()');
	}

	/*
		Class: AnimatedElement
			at the moment the object name must be the same as the element id
		Arguments:
			sElementID - Element ID (must be set to the same as the object name)
			sAxis - X or Y (upper case)
			iPosition - current position on this axis
			sAnimationType - type of animation / curve
			iMin - min bound on this axis
			iMax - max bound on this axis
			iInterval - update interval in milliseconds
		
	*/
	function AnimatedElement(sElementID, iMinX, iMinY, iMaxX, iMaxY, sAnimationType, iInterval) {
		if (document.getElementById(sElementID) == null) { return; }
		this.oElement = document.getElementById(sElementID);
		
		this.sElementID = sElementID;
		
		this.SetBounds(iMinX, iMinY, iMaxX, iMaxY, sAnimationType);

		setInterval('MoveElement(\'' + sElementID + '\')', iInterval);
	}
	
	/*	
		Function: MoveElement
			Moves the element onscreen within the specified boundaries
		Returns:
			null on error
	*/
	AnimatedElement.prototype.MoveElement = function() {
	
		if (!this.oBounds) { return; }
		var iMoveX = this.iMove('X', this.oElement.offsetLeft, this.sAnimationType, this.oBounds.iMinX, this.oBounds.iMaxX);
		var iMoveY = this.iMove('Y', this.oElement.offsetTop, this.sAnimationType, this.oBounds.iMinY, this.oBounds.iMaxY);
		
		/*this.oElement.offsetLeft = iMoveX
		this.oElement.offsetTop = iMoveY*/
		this.oElement.style.left = iMoveX;
		this.oElement.style.top = iMoveY;

		var iLeft = !window.innerWidth ? document.body.clientWidth : window.innerWidth;

		this.oElement.style.left = (iLeft - 250) + 'px';//document.body.clientWidth - this.oElement.style.width - 10;
		
		this.oElement.style.display = 'block';
		//alert(iMoveX + ', ' + iMoveY);
	}
	
	/*
		Function: iMove
			Determines the amount of movement required on a particular axis based on
			the current position, the bounds and the animation type
		Arguments:
			sAxis - X or Y (upper case)
			iPosition - current position on this axis
			sAnimationType - type of animation / curve
			iMin - min bound on this axis
			iMax - max bound on this axis
	*/
	AnimatedElement.prototype.iMove = function(sAxis, iPosition, sAnimationType, iMin, iMax) {
		var iAxis;
		sAxis == 'X' ? iAxis = 0: iAxis = 1;
		
		if (!this.aoAnimationTypes[sAnimationType]) { alert('sAnimationType is not defined'); return 0; }
		
		var iMoveAmount = this.aoAnimationTypes[sAnimationType][iAxis];
		
		if (iPosition >= iMax) {
			//set the motion to rebound
			this.aiMovement[iAxis] = -1
		} else if (iPosition <= iMin) {
			this.aiMovement[iAxis] = 1
		}
		
		var iReturnMove = (iMoveAmount * this.aiMovement[iAxis]) + iPosition;
		
		return iReturnMove;
		
	}
	
	//each array of integers describes a single step of movement (in pixels)
	AnimatedElement.prototype.aoAnimationTypes = {'up_and_down': [0, 2], 'up_and_down_smooth': [0, 1], 'side_to_side': [2, 0], 'diagonally': [2, 2]}
	
	/*
		Arguments:
			sElementID - a valid element id
			iMinX - the minimum x coordinate allowed
			iMinY - the minimum y coordinate allowed
			iMaxX - the maximum x coordinate allowed
			iMaxY - the maximum y coordinate allowed
			sAnimationType - the type of curve/animation profile
		Returns:
			null on error
	*/	
	AnimatedElement.prototype.SetBounds = function(iMinX, iMinY, iMaxX, iMaxY, sAnimationType) {
	
		//create a new object in the element which will contain the
		// onscreen bounds for the object
		this.oBounds = new Object;
		this.oBounds.iMinX = iMinX;
		this.oBounds.iMinY = iMinY;
		this.oBounds.iMaxX = iMaxX;
		this.oBounds.iMaxY = iMaxY;
		
		this.sAnimationType = sAnimationType;
		
		this.iInitialX = this.oElement.offsetLeft
		this.iInitialY = this.oElement.offsetTop
		
		this.aiMovement = [1, 1];
		
	}