function addRandomImg()
{
	$.ajax({
		url:	"randomimage.php",
		cache:	false,
		success: function(html){
			$("#randomimage").append(html);
		}
	})
	.complete(function() {
		$.wait(3000, function() {
			$("#randomimage div:last-child").children().animate({opacity: 1}, 2000, function() {
				$.wait(12000, function() {
					$("#randomimage").children().css("z-index", "+=1");
					addRandomImg();
					$.wait(5000, function() {
						$("#randomimage div:first-child").children().fadeOut(5000, function() {
							$("#randomimage div:first-child").empty().remove();
						});
					});
				});
			});
		});
	});
}
$(document).bind('mousemove', function(e){
	var el = document.getElementById("mainmenu");
	var x = el.offsetLeft + ($("#mainmenu").width() / 2);
	var y = el.offsetTop + ($("#mainmenu").height() / 2);
	var distance = Math.sqrt( Math.pow(x - e.pageX, 2) + Math.pow(y - e.pageY, 2) );
	var blue = 96 + Math.max(0, 70 - Math.floor(distance / 17));
	var red = 72 + Math.max(0, 60 - Math.floor(distance / 3));
	$("body").css("background-color", "rgb("+red+",72,"+blue+")");
});
$(document).ready(addRandomImg());

