

	var moveInterval;
	var currentposx;

	var viewport;
	var xposbox;
	var currentposbox;

	var aimx;

	var stepSize = 10;

	var arrBackgroundItems;
	var arrBackgroundItemsOriginalXPositions;
	var arrBackgroundItemsAcceleration;
	var docWidth;
	var docHeight;

	window.addEvent('load', function(){

		// Prepare items
		docWidth = document.getWidth();
		docHeight = document.getHeight();
		aimx = currentposx = Math.round(docWidth / 2);

		arrBackgroundItems = $(document.body).getElements('.animate_background');
		arrBackgroundItemsOriginalXPositions = new Array(arrBackgroundItems.length);
		arrBackgroundItemsOriginalYPositions = new Array(arrBackgroundItems.length);
		arrBackgroundItemsAcceleration = new Array(arrBackgroundItems.length);
		for (var i = 0; i < arrBackgroundItems.length; i++) {
			if (arrBackgroundItems[i].style.backgroundPositionX) {
				arrBackgroundItemsOriginalXPositions[i] = arrBackgroundItems[i].style.backgroundPositionX;
				arrBackgroundItemsOriginalYPositions[i] = arrBackgroundItems[i].style.backgroundPositionY;
			} else if (window.getComputedStyle) {
				arrBackgroundItemsOriginalXPositions[i] = getXPos(window.getComputedStyle(arrBackgroundItems[i],null).getPropertyValue("background-position"));
				arrBackgroundItemsOriginalYPositions[i] = getYPos(window.getComputedStyle(arrBackgroundItems[i],null).getPropertyValue("background-position"));
			} else {
				return false;
			}
			arrBackgroundItemsAcceleration[i] = 0.5 + Math.random()*2;
		}
		// arrBackgroundItemsOriginalXPositions now contains all original x positions of backgrounds
		// As mouse moves, adjust positions.

		document.addEvent('mousemove', animateBackgrounds.bindWithEvent());

		setInterval("moveView()", 1);

	});

	function animateBackgrounds(e) {
		if (e.client) {
			aimx = e.client.x;
		} else {
			if (e.pageX) {
				aimx = e.pageX;
			} else {
				aimx = 'problem'; // Can't get xpos
			}
		}
		if (aimx < 0) {
			aimx = 0;
		}
		if (aimx > docWidth) {
			aimx = docWidth;
		}
	}

	function moveView() {
		if (aimx != 'problem') {
			if (aimx < currentposx - 5) {
				moveLeft();
			} else if (aimx > currentposx + 5) {
				moveRight();
			}
		}
	}

	function moveLeft() {
		currentposx = currentposx - (currentposx - aimx) / stepSize;
		newPos();
	}

	function moveRight() {
		currentposx = currentposx + (aimx - currentposx) / stepSize;
		newPos();
	}

	function newPos() {
		// Move each element
		var x = parseInt((currentposx - (docWidth / 2)));
		x = ((100 * x) / docWidth);
		for (var i = 0; i < arrBackgroundItemsOriginalXPositions.length; i++) {
			// currentposx is an offset from center
			var tmpx = x * arrBackgroundItemsAcceleration[i];
			arrBackgroundItems[i].style.backgroundPosition = (tmpx + arrBackgroundItemsOriginalXPositions[i]) + "% " + arrBackgroundItemsOriginalYPositions[i] + "px";
		}
	}

	function getXPos(strBackground) {
		var arrPortions = strBackground.split('px ');
		if (arrPortions.length > 1) {
			arrPortions[0] = Math.round(arrPortions[0] * 100/ docWidth);
			return arrPortions[0];
		} else {
			arrPortions = strBackground.split('% ');
			return arrPortions[0];
		}
	}

	function getYPos(strBackground) {
		var arrPortions = strBackground.split('px ');
		if (arrPortions.length > 1) {
			arrPortions = arrPortions[1].split('px');
			return arrPortions[0];
		} else {
			arrPortions = strBackground.split('% ');
			arrPortions = arrPortions[1].split('px');
			return arrPortions[0];
		}
	}