<!--

test = false;
ns = (document.layers) ? 1 : 0;

function init()
{	
	
	object = new Array();

	object[1] = "";
	object[2] = "";
	object[3] = "";
	object[4] = "";

	if (ns)
	{
		object[0] = document.obj0;
		object[5] = document.obj5;
		object[6] = document.obj6;
		object[7] = ducument.obj7;
		object[8] = ducument.obj8;
		object[9] = ducument.obj9;
	}
	else
	{
		object[0] = obj0.style;
		object[5] = obj5.style;
		object[6] = obj6.style;
		object[7] = obj7.style;
		object[8] = obj8.style;
		object[9] = obj9.style;
	}
	j = 0;

	dir = Array();
	dir[-4]="Mosca_3.gif";
	dir[-1]="Mosca_6.gif";
	dir[-2]="Mosca_5.gif";
	dir[-3]="Mosca_4.gif";
	dir[3]="Mosca_8.gif";
	dir[4]="Mosca_7.gif";
	dir[1]="Mosca_2.gif";
	dir[2]="Mosca_1.gif";
	dir[0]="";
	dir[5]="Mosca_3b.gif";
	dir[8]="Mosca_6b.gif";
	dir[7]="Mosca_5b.gif";
	dir[6]="Mosca_4b.gif";
	dir[12]="Mosca_8b.gif";
	dir[13]="Mosca_7b.gif";
	dir[10]="Mosca_2b.gif";
	dir[11]="Mosca_1b.gif";
	dir[9]="";

	img = Array();
	for (var i=-4; i<14; i++){
		img[i]=new Image();
		img[i].src="img/"+dir[i];
	}

	(ns)?window.captureEvents(Event.MOUSEMOVE):0;
	(ns)?window.onMouseMove=getMousePosition:document.onmousemove=getMousePosition;
	poot = 0;
	Dot_Ro = 60;
	Dot_Theta = 0;
	Dot_Speed = 0;
	Dot_Direction = 1;
	Dot_x = 0;
	Dot_y = 0;
	alpha = 0;
	mult = 0;
	picX = 20;
	picY = 100;
	mouseX = 400;
	mouseY = 200;
	step = 10;
	speed = 100;
	
	setInterval('moveFly()', speed);
	setInterval('ChangeDotDirection()', speed*50);
	showhideAnimation();

	test = true;
	toon(7);
}

function toon(i)
{
	if (test)
	{	
		if (ns)
		{
			object[j].visibility = "hide"; 
			object[i].visibility = "show";
		}
		else
		{
			object[j].visibility = "hidden";
			object[i].visibility = "visible";
		}
		j = i;
	}
}


function display(direction) {
	if (ns) {
		if (poot) { document.pic.src = img[direction].src; poot = 0;}
		else { document.pic.src = img[direction + 9].src; poot = 1; }
	}else{
		if (poot) { pic.src = img[direction].src; poot = 0;}
		else { pic.src = img[direction + 9].src; poot = 1; }
	}
}


function getMousePosition(e) {
	mouseY=(ns)?e.pageY:window.event.y + document.body.scrollTop;
	mouseX=(ns)?e.pageX:window.event.x + document.body.scrollLeft;
}

function calcNewPos() {
	dist=Math.sqrt(Math.pow(mouseY-picY,2) + Math.pow(mouseX-picX,2));
	Dot_Speed=Math.PI/15;
	Dot_Theta+=Dot_Direction*Dot_Speed;
	Dot_x=mouseX+Dot_Ro*Math.cos(Dot_Theta);
	Dot_y=mouseY+Dot_Ro*Math.sin(Dot_Theta);
	if (Dot_x < 15) Dot_x=15;
	if (Dot_y < 15) Dot_y=15;
	if (Dot_y > 405) Dot_y=405;
	arg = (Dot_y-picY) / (Dot_x-picX);
	mult = (Dot_x - picX < 0)? mult = -1:1;
	alpha = Math.atan(arg);
	dx = mult * step * Math.cos(alpha);
	dy = mult * step * Math.sin(alpha);
	picX += dx;
	picY += dy;
}

function showhideAnimation() {
	if (ns) {
		object[7].visibility=object[7].visibility=="hide"?"show":"hide";
		object[8].visibility=object[8].visibility=="hide"?"show":"hide";
		object[9].visibility=object[9].visibility=="hide"?"show":"hide";
	}else {
		object[7].visibility=object[7].visibility=="hidden"?"visible":"hidden";
		object[8].visibility=object[8].visibility=="hidden"?"visible":"hidden";
		object[9].visibility=object[9].visibility=="hidden"?"visible":"hidden";
	}
}

function moveFly() {
	calcNewPos();
	if (ns) {
		object[7].left = picX;
		object[7].top = picY;
	}else{
		object[7].left = picX - pic.width / 2;
		object[7].top = picY - pic.height / 2;
	}
	alpha=-180*alpha/Math.PI;
	alpha+=22.5;
	OK=0;
	for(var i=0; (i<4)&& !OK; i++){
		if (alpha<-Math.PI+45*i){
			display(mult*(i+1));
			OK=1;
		}
	}
}
function ChangeDotDirection() {
	Dot_Direction=-Dot_Direction;
	Dot_Theta+=Math.PI;
}

function popup(url,breedte,hoogte,name) {
 // opens a new window with url 'url'
 //  to open windows in top of each other give them a different name
 var pWidth=breedte; pHeight=hoogte; if (!name) name = "newWin";
 w = (window.screen.availWidth-pWidth)/2; h = (window.screen.availHeight-pHeight)/2; // center onscreen:
 newWin = window.open(url,name,"scrollbars=yes,resizable=no,width="+pWidth+",height="+pHeight+",screenX="+w+",screenY="+h+",top="+h+",left="+w+"'");
 if (!newWin.opener) newWin.opener = self;
 setTimeout("newWin.focus()",250); // put focus on new window
}

// -->
