//OC Eastereggs
var keylogger = function(keys, funk, onlyOnce){
	this.keys = keys;
	this.funktion = funk;
	this.current = 0;
	this.onlyOnce = onlyOnce;
	this.done = false;
	
	this.check = function check(ev){
		if (this.done || /input|textarea/i.test(ev.target.nodeName)) return;
		var code = ev.which;
		var buch = "";
		/*if (kkjs.constTabelle.keyCodes2[code]) buch = kkjs.constTabelle.keyCodes2[code];
		else*/ if (String.fromCharCode(code)) buch = String.fromCharCode(code);
		else return;
		if (buch == this.keys[this.current]){
			this.current++;
			if (this.current == this.keys.length){
				this.funktion();
				if (this.onlyOnce){
					this.done = true;
				}
				this.current = 0;
			}
		}
		else{
			this.current = (buch == this.keys[0])? 1: 0;
		}
	}
	
	kkjs.setzeEvent(document, "keypress", kkjs.bindObj(this, this.check));
}

var pointer = function(node, center, radius){
	this.node = node;
	this.center = center;
	this.radius = radius;
	kkjs.koordAdd(node.offsetParent);
	
	this.point = function(ev){
		var m = kkjs.mausPosition(ev);
		var x = m[0] - center.x;
		var y = m[1] - center.y;
		var len = Math.sqrt(x*x + y*y);
		if (len > this.radius){
			x *= this.radius/len;
			y *= this.radius/len;
		}
		this.node.style.left = x + center.x - this.node.offsetWidth/2 - this.node.offsetParent.getX() + "px";
		this.node.style.top  = y + center.y - this.node.offsetHeight/2 - this.node.offsetParent.getY() + "px";
	}
	
	kkjs.setzeEvent(document, "mousemove", kkjs.bindObj(this, this.point));
}
var keys = ("orpheus\r").split("");
var orpheus = new keylogger(keys, function(){
	window.open("http://de.wikipedia.org/wiki/Orpheus", "_blank");
});

var guck = new keylogger(("guck").split(""), function(){
	var eyeR = kkjs.createNode("img", {src: "./images/apfel.png"}, {position: "absolute", left: "119px", top: "255px"});
	document.body.appendChild(eyeR);
	var irisR = kkjs.createNode("img", {src: "./images/iris.png"}, {position: "absolute", left: "123px", top: "259px"});
	document.body.appendChild(irisR);
	var guckerR = new pointer(irisR, {x: 126, y: 262}, 4);
	
	var eyeL = kkjs.createNode("img", {src: "./images/apfel.png"}, {position: "absolute", left: "108px", top: "277px"});
	document.body.appendChild(eyeL);
	var irisL = kkjs.createNode("img", {src: "./images/iris.png"}, {position: "absolute", left: "112px", top: "281px"});
	document.body.appendChild(irisL);
	var guckerL = new pointer(irisL, {x: 115, y: 284}, 4);
}, true);


