// algemeen
window.defaultStatus = "Stern Nijland Illustraties";


//objects
function moveTo() {
	this.xpos += (this.nextx - this.xpos) * 0.2 + (Math.random() * 10 - 5);
	this.ypos += (this.nexty - this.ypos) * 0.2 + (Math.random() * 10 - 5);
	rannum = Math.random() * this.chance;
	if (rannum < 1) {
	// change nextx,y
		this.nextx = Math.random() * 900 - 120;
		this.nexty = Math.random() * 600 - 120;;
		this.chance += (this.chance * 0.5);
	}
	document.getElementById(this.id).style.left = this.xpos;
	document.getElementById(this.id).style.top = this.ypos;
	eval('timerID' + this.name + ' = setTimeout(this.name + ".moveTo()", 100)');;
}

function fly(id, name, xpos, ypos) {
	this.id = id;
	this.name = name;
	this.xpos = xpos;
	this.ypos = ypos;
	this.nextx = Math.random() * 780;
	this.nexty = Math.random() * 470;
	this.moveTo = moveTo;
	this.chance = 100;
}

vlieg1 = new fly("vlieg1Div", "vlieg1", -300, -30);
vlieg2 = new fly("vlieg2Div", "vlieg2", 100, -100);

function hitFly(name) {
	eval(name + ".chance = 1");
	eval(name + ".nextx = Math.random() * 780");
	eval(name + ".nexty = Math.random() * 470;");
}

function setFlyDest(name, nextx, nexty) {
	eval(name + ".nextx = " + nextx);
	eval(name + ".nexty = " + nexty);
	eval(name + ".chance = 200");
}