$(function() {
	var ww, wh;
	var fw = $('#fancy-el').width();
	var fh = $('#fancy-el').height();
	var lastPos = {x:$('#fancy-el').css('top'),y:$('#fancy-el').css('left')};
	function fancyAnim() {
		var x, y;
		do {
			x = Math.abs(Math.floor(Math.random() * ww - fw));
		} while (Math.abs(lastPos.x - x) < fw);
		do {
			y = Math.abs(Math.floor(Math.random() * wh - fh));
		} while (Math.abs(lastPos.y - y) < fh);
		$('#fancy-el').animate({
			left: x + 'px',
			top: y + 'px'
		}, 500);
		lastPos = {x:x,y:y};
	}
	function onWindowResize() {
		ww = $(window).width();
		wh = $(window).height();
		$('#fancy-bg').height(wh);
		$('#fancy-bg').width(ww);
	}
	$(window).resize(onWindowResize);
	onWindowResize();
	$('#fancy-el').mouseover(fancyAnim);
	fancyAnim();
});