//if(top.frames.length>0) top.location.replace('index.html');

window.onerror = function stopErrors() { return true; }

var I4 = false, N4 = false, N6 = false, O5 = false;

if(window.opera) O5 = true;
if(document.all && !O5) var I4 = true, Dok = "document.all", LStyle = ".style", LHide = "hidden", LShow = "visible", IO = "", px = 0;
if(document.getElementById && !I4) var N6 = true, Dok = "document", LStyle = ".style", LHide = "hidden", LShow = "visible", IO = "", px = (O5) ? 0 : 'px';
if(document.layers) var N4 = true, Dok = "document.layers", LStyle = "", LHide = "hide", LShow = "show", IO = ".document", px = 0;

var	DHTML	=	(I4 || N4 || N6 || O5) ? true : false;
var	bw		=	Math.round(Math.random());

// Logo animation
var yBase = 50;
var xBase = 50;
var delay = 150;
var yAmpl = 10;
var yMax = 40;
var step = .2;
var ystep = .5;
var currStep = 0;
var tAmpl=1;
var Xpos = 50;
var Ypos = 50;
var j = 0;

function MoveHandlerN4(e) {
  Xpos = e.pageX ;
  Ypos = e.pageY ;
}

function MoveHandlerN6(e) {
  Xpos = e.clientX ;
  Ypos = e.clientY ;
}

function MoveHandlerI4() {
  Xpos = event.clientX ;
  Ypos = event.clientY ;
}

function animateN4()
{
	yBase = window.innerHeight/4 ;
	xBase = window.innerWidth/4;
	for(j = 0 ; j < 6 ; j++)
	{
		document["s"+j].top = Ypos + Math.cos((20*Math.sin(currStep/(20+j)))+j*70)*yBase*(Math.sin(10+currStep/10)+0.2)*Math.cos((currStep + j*25)/10);
		document["s"+j].left = Xpos + Math.sin((20*Math.sin(currStep/20))+j*70)*xBase*(Math.sin(10+currStep/(10+j))+0.2)*Math.cos((currStep + j*25)/10);
	}
	currStep += step;
	setTimeout("animateN4()", delay) ;
}

function animateN6()
{
	yBase = window.innerHeight/4 ;
	xBase = window.innerWidth/4;
	xlim  = window.innerWidth-50;
	for(j = 0 ; j < 6 ; j++)
	{
		var yy = Ypos + Math.cos((20*Math.sin(currStep/(20+j)))+j*70)*yBase*(Math.sin(10+currStep/10)+0.2)*Math.cos((currStep + j*25)/10);
		var xx = Xpos + Math.sin((20*Math.sin(currStep/20))+j*70)*xBase*(Math.sin(10+currStep/(10+j))+0.2)*Math.cos((currStep + j*25)/10);
		if(yy < 1) var yy = 1;
		if(xx > xlim) xx = xlim;
		document.getElementById("s"+j).style.top = yy+px;
		document.getElementById("s"+j).style.left = xx+px;
	}
	currStep += step;
	setTimeout("animateN6()", delay) ;
}

function animateI4()
{
	yBase = document.body.clientHeight/4;
	xBase = document.body.clientWidth/4;
	for(j = 0 ; j < 6 ; j++)
	{
		document.all["s"+j].style.top = Ypos + Math.cos((20*Math.sin(currStep/(20+j)))+j*70)*yBase*(Math.sin(10+currStep/10)+0.2)*Math.cos((currStep + j*25)/10);
		document.all["s"+j].style.left = Xpos + Math.sin((20*Math.sin(currStep/20))+j*70)*xBase*(Math.sin(10+currStep/(10+j))+0.2)*Math.cos((currStep + j*25)/10);
	}
	currStep += step;
	setTimeout("animateI4()", delay) ;
}

function animate()
{
	if(!bw)
	{
		document.getElementById('bw').className			=	'bodyblack';
		document.getElementById('txt1').style.color		=	'#ff4500';
		document.getElementById('txt2').style.color		=	'#f0f0f0';
	}
	document.getElementById('mind').style.visibility	=	'visible';

	Ypos = 150;
	if(N4)
	{
		Xpos = window.innerWidth-150;
		animateN4();
	}
	else if(N6 || O5)
		{
			Xpos = window.innerWidth-150;
			animateN6();
		}
		else if(I4)
			{
				Xpos = document.body.clientWidth-150;
				animateI4();
			}
}

//	if(nn)
//	{
//		window.captureEvents(Event.MOUSEMOVE);
//		window.onmousemove = MoveHandlerNN;
//	}
//	if (ie)
//		document.onmousemove = MoveHandlerIE;
function Refresch()
{
	if ((Sav_width != self.innerWidth) || (Sav_height != self.innerHeight)) history.go(0);
}

function	MM(n,id,from)
{
	if(n)
	{
		var	mids	=	new	Array	(
										'mgal_1',
										'mgal_2',
										'mgal_3',
										'mlinks',
										'mnonsense',
										'mpurpur',
										'mimpressum',
										'mkontakt',
										'mvita'
									)
									
		for(var i=0; i<mids.length;i++)
		{
			document.getElementById(mids[i]).style.display	=	(id	==	mids[i])	?	'block'	:	'none';
		}

		document.getElementById(id).firstChild.title	=	from.title;
	}
	else
	{
		document.getElementById(id).style.display		=	'none';
	}

	return	true;
}

if (N4)
{
	Sav_width = self.innerWidth;
	Sav_height = self.innerHeight;
	window.onresize = Refresch;
}

if(DHTML) window.onload = animate;
