$extend(Window || {}, {
	getPosition: function() {
		if (window.screenLeft) {
			var x = window.screenLeft;
			var y = window.screenTop;
		}
		else {
			var x = window.screenX;
			var y = window.screenY;
		}
		return { x: x, y: y };
	}
});


window.addEvent('domready', function() {
	var pos;
	var elem = $(document.body).getElement('.canvasContainer');
	elem.setStyle('position', 'relative');
	
	var fx = new Fx.Spring();
	var fx2 = new Fx.Spring();
	fx2.mass.mass = 0.01;
	fx2.mass.damping = 1;
	fx2.spring.springConst = 15;
	/*fx.mass.mass = 0.5;
	fx.mass.damping = 2;*/
	
	fx2.addEvent('step', function(arg) {
		elemPos = arg;
	});
	
	var elemPos = {x: 0, y: 0};
	var tmp;
	var tmp2;
	(function() {
		tmp = Window.getPosition();
		if (pos && pos.x != tmp.x && pos.x != tmp.y) {
			tmp2 = {x: tmp.x-pos.x, y: tmp.y-pos.y };
			fx2.setTarget( tmp2 );
			fx2.start();
			fx.setTarget( tmp2 );
			fx.start();
		}
		pos = tmp;
	}).periodical(50);
	
	fx.addEvent('step', function(arg) {
		elem.setStyles({
			top: -elemPos.y + arg.y,
			left: -elemPos.x + arg.x
		});
	});
});