document.onmousemove = animateLogo;
document.onload = window.setInterval("updateTime()", 50);

// Startzeit
var time = new Date();
// Maximale Pixelverschiebung des Logos
var LogoMax = 6;
// VerzÃ¶gerung Hintergrundanimation
var wait = 10;
// Maximale Verschiebung des Hintergrunds:
var maxX = 20;
var maxY = 10;

function getWindowWidth(win) {
	return window.innerWidth || document.documentElement.clientWidth;
}

function getWindowHeight(win) {
	return window.innerHeight || document.documentElement.clientHeight;
}

// LogoAnimation
function animateLogo(i) {
	var logo = document.getElementById("lab30back");
	
	var MouseX = (document.all) ? window.event.clientX + document.body.scrollLeft : i.pageX;
	var MouseY = (document.all) ? window.event.clientY + document.body.scrollTop : i.pageY;
	
	var x = ((MouseX / (getWindowWidth() / 100))*(LogoMax/100))-3;
	var y = ((MouseY / (getWindowHeight() / 100))*(LogoMax/100))-3;
	
	
	logo.style.marginLeft = (5 + Math.round(x)) + "px"; 
	logo.style.marginTop = (155 + Math.round(y)) + "px";
	
	//confirm((155 + Math.round(y)) + "px");
	
	time = new Date(); // Zeit zurÃ¼cksetzen fÃ¼r Hintergrundanimation
}

function updateTime(){
	time2 = new Date();
	timediv = (Date.parse(time2)-Date.parse(time))/1000;
	
	if (timediv > wait) {
		animate();
	}
}

var speed = 0;
var test = true;
function animate(){
	var bg = document.getElementById("bg2img");
	var x = maxX*Math.cos(speed);
	var y = maxY*Math.sin(speed); 

	bg.style.marginLeft = (-500 - maxX + Math.round(x)) + "px";
	bg.style.marginTop = (-20 + Math.round(y)) + "px";		
		
	speed += 0.05; // Speed steuert Sinus / Cosinus Geschwindigkeit
}