MediaWiki:Skin/Friedhof.js

var speed = 50 // "Fluggeschwindigkeit" (Achtung, je höher der Wert, desto langsamer; doof das, aber geht nicht anders)

document.write('');

window.onload = function { if(document.getElementById('rahmen')) { maxtop   = document.getElementById('rahmen').offsetHeight; maxleft  = document.getElementById('rahmen').offsetWidth; butterfly = document.getElementById('schmetterling'); fly; }	}

function fly { var direction = Math.floor(Math.random * 10) % 4; switch(direction) { case 0: if(Number(butterfly.style.top.replace(/px/, "")) + 1 <= maxtop) { butterfly.style.top = Number(butterfly.style.top.replace(/px/, "")) + 1 + 'px'; }		break; case 1: if(Number(butterfly.style.top.replace(/px/, "")) - 1 >= 0) { butterfly.style.top = Number(butterfly.style.top.replace(/px/, "")) - 1 + 'px'; }		break; case 2: if(Number(butterfly.style.left.replace(/px/, "")) + 1 <= maxleft) { butterfly.style.left = Number(butterfly.style.left.replace(/px/, "")) + 1 + 'px'; }		break; case 3: if(Number(butterfly.style.left.replace(/px/, "")) - 1 >= 0) { butterfly.style.left = Number(butterfly.style.left.replace(/px/, "")) - 1 + 'px'; }		break; }	window.setTimeout("fly", speed); }