var i=0;
var v=1.2;		
var dt=1.0;	
var TR=0.03;
var F=TR;
var activeHeadline=0;
var activeMember=0;
var activeBublina=0;
var count=-1;
var cpspeed = 0;
var showHeadlines = true;

function ITH(n)
{
	var result = n.toString(16);
	if (result.length==1) result = "0"+result;
	return result;
}

function HTI(hex)
{
  return parseInt(hex, 16);
}

function dark(name,w)
{
	
	rstr=ITH(w*16);
	gstr=ITH(w*16);
	bstr=ITH(w*16);
	str="#"+rstr+gstr+bstr;			
	var obj=document.getElementById(name);
	obj.style.color=str;		
	if( w!=0 ) setTimeout("dark('"+name+"',"+(w-1)+")",40);
}
		
function set(id,id2)
{	
	uvoda = document.getElementById('uvod');	
	if (document.getElementById(id).style.display=="block") return;
	document.getElementById(id).style.display = "block";		
	uvoda.style.display = "none";
	document.getElementById(id).style.color = "#fff";
	document.getElementById(id+"-menu").style.color = "#000";
	document.getElementById(id+"-menu").style.background = "#fff";
	dark(id,15);	
}

function del(id)
{
	uvoda = document.getElementById('uvod');	
	document.getElementById(id).style.display = "none";		
	uvoda.style.display = "block";		
	uvoda.style.color = "#fff";		
	document.getElementById(id+"-menu").style.color = "#fff";
	document.getElementById(id+"-menu").style.background = "#000";
	dark('uvod',15);
}


function showHeadline(number)
{
	showHeadlines = false;

	headlinesa = document.getElementById('headlines').getElementsByTagName("li");
	membersa = document.getElementById('members').getElementsByTagName("li");
	
	if (activeHeadline!=0)  {
		
		activeHeadline.style.display = 'none';			
		activeMember.getElementsByTagName("a")[0].style['opacity'] = "0.0";
		activeMember.getElementsByTagName("a")[0].style['filter'] = "alpha(opacity=0)";
	}
	
	activeMember  = membersa[number];
	
	activeMember.getElementsByTagName("a")[0].style['opacity'] = "1.0";
	activeMember.getElementsByTagName("a")[0].style['filter'] = "alpha(opacity=100)";
	
	activeHeadline = headlinesa[number];
	
	activeHeadline.style.color="#fff";
	
	activeHeadline.style.display = 'block';	
		
}

function hideHeadline(number)
{
	showHeadlines = true;	
		
}

function move()
{

	if (cpspeed==0) {
		t0 = new Date();
		tmp = 0;
		for (i=0; i<16384; i++) {
			tmp = tmp + i;
		}
		
		t1 = new Date();
		
		cpspeed = t1.getTime() - t0.getTime();
				
	}
	
	if (cpspeed>500) return;
	
	count+=1;
	
	
	
	obr1a = document.getElementById('obr1');				
	obr2a = document.getElementById('obr2');	
	obr3a = document.getElementById('obr3');				
	obr4a = document.getElementById('obr4');	
	obr5a = document.getElementById('obr5');	
	obr6a = document.getElementById('obr6');
	
	
	if (count%60==0) {
		bublinya = document.getElementById('bubliny').getElementsByTagName("li");
		if (activeBublina!=0)  {		
			activeBublina.style.display = 'none';						
		}
		if (count%120==0) {
			if ((count/120)%(2*bublinya.length)<bublinya.length) {
				activeBublina = bublinya[(count/120)%(2*bublinya.length)];
				activeBublina.style.display = 'block';
			} else {
				activeBublina.style.display = 'none';
			}
		}
	}
	
	
	if (count%100==0&&showHeadlines) {
	
		headlinesa = document.getElementById('headlines').getElementsByTagName("li");
		
		membersa = document.getElementById('members').getElementsByTagName("li");
		
			
		if (activeHeadline!=0)  {
		
			activeHeadline.style.display = 'none';			
			
		}
		
		activeHeadline = headlinesa[(count/100)%headlinesa.length];
		
		activeMember = membersa[(count/100)%headlinesa.length];
		
		activeHeadline.style.display = 'block';	
				
	}
	
	if (activeHeadline!=0&&showHeadlines) {
		if (count%100<=16 ) {
			bstr=gstr=rstr=ITH((count%100)*16);								
			if (bstr=='100') bstr=gstr=rstr="ff";		
			activeHeadline.style.color="#"+rstr+gstr+bstr;	
			
			if ((count%2)==0) {			
				activeMember.getElementsByTagName("a")[0].style['opacity'] = (count%100)/16.0;			
				activeMember.getElementsByTagName("a")[0].style['filter'] = "alpha(opacity="+(100*(count%100)/16.0)+")";			
			}
				
			
		}
		if (count%100>=100-16 ) {
			bstr=gstr=rstr=ITH((100-(count%100))*16);
			if (bstr=='100') bstr=gstr=rstr="ff";							
			activeHeadline.style.color="#"+rstr+gstr+bstr;	
			
			if ((count%2)==0) {
				activeMember.getElementsByTagName("a")[0].style['opacity'] = (100-(count%100))/16.0;
				activeMember.getElementsByTagName("a")[0].style['filter'] = "alpha(opacity="+(100*(100-(count%100))/16.0)+")";
			}	
			
		}
	}
	
	if (cpspeed<75) {
	
		if (v>0.0) a = F-TR;
		if (v==0.0) a = F;
		if (v<0.0) a = F+TR;		
		v+=a*dt;
		if (v<0.03) v=0;
		i+=v*dt;		
		if (v>1.2) F=TR;		
		
		nutace = 9;
		
		R1 = Math.sin(i/7)*nutace+170;
		R2 = Math.sin(i/7.4)*nutace+170;
		R3 = Math.sin(i/7.3)*nutace+170;
		R4 = Math.sin(i/7.8)*nutace+170;
		R5 = Math.sin(i/7.5)*nutace+170;
		R6 = Math.sin(i/7.1)*nutace+170;		
						
		obr1a.style.left = (Math.sin(i/180.0*3.141592)*R1+150)+"px";
		obr1a.style.top = (Math.cos(i/180.0*3.141592)*R1+150)+"px";
		obr2a.style.left = (Math.sin((i+60)/180.0*3.141592)*R2+150)+"px";
		obr2a.style.top = (Math.cos((i+60)/180.0*3.141592)*R2+150)+"px";
		obr3a.style.left = (Math.sin((i+120)/180.0*3.141592)*R3+150)+"px";
		obr3a.style.top = (Math.cos((i+120)/180.0*3.141592)*R3+150)+"px";
		obr4a.style.left = (Math.sin((i+180)/180.0*3.141592)*R4+150)+"px";
		obr4a.style.top = (Math.cos((i+180)/180.0*3.141592)*R4+150)+"px";
		obr5a.style.left = (Math.sin((i+240)/180.0*3.141592)*R5+150)+"px";
		obr5a.style.top = (Math.cos((i+240)/180.0*3.141592)*R5+150)+"px";
		obr6a.style.left = (Math.sin((i+300)/180.0*3.141592)*R6+150)+"px";
		obr6a.style.top = (Math.cos((i+300)/180.0*3.141592)*R6+150)+"px";
	}
	
	if (i<0) i+=18000;
	if (i>18000) i-=18000;
	window.setTimeout("move()", 50);
}

function move2()
{

	if (cpspeed==0) {
		t0 = new Date();
		tmp = 0;
		for (i=0; i<16384; i++) {
			tmp = tmp + i;
		}
		
		t1 = new Date();
		
		cpspeed = t1.getTime() - t0.getTime();
				
	}
	
	if (cpspeed>500) return;
	
	count+=1;
	
			
	
	
	if (count%60==0) {
		bublinya = document.getElementById('bubliny').getElementsByTagName("li");
		if (activeBublina!=0)  {		
			activeBublina.style.display = 'none';						
		}
		if (count%120==0) {
			if ((count/120)%(2*bublinya.length)<bublinya.length) {
				activeBublina = bublinya[(count/120)%(2*bublinya.length)];
				activeBublina.style.display = 'block';
			} else {
				activeBublina.style.display = 'none';
			}
		}
	}
	
	
	if (count%100==0&&showHeadlines) {
	
		headlinesa = document.getElementById('headlines').getElementsByTagName("li");
		
		membersa = document.getElementById('members').getElementsByTagName("li");
		
			
		if (activeHeadline!=0)  {
		
			activeHeadline.style.display = 'none';			
			
		}
		
		activeHeadline = headlinesa[(count/100)%headlinesa.length];
		
		activeMember = membersa[(count/100)%headlinesa.length];
		
		activeHeadline.style.display = 'block';	
				
	}
	
	if (activeHeadline!=0&&showHeadlines) {
		if (count%100<=16 ) {
			bstr=gstr=rstr=ITH((count%100)*16);								
			if (bstr=='100') bstr=gstr=rstr="ff";		
			activeHeadline.style.color="#"+rstr+gstr+bstr;	
			
			if ((count%2)==0) {			
				activeMember.getElementsByTagName("a")[0].style['opacity'] = (count%100)/16.0;			
				activeMember.getElementsByTagName("a")[0].style['filter'] = "alpha(opacity="+(100*(count%100)/16.0)+")";			
			}
				
			
		}
		if (count%100>=100-16 ) {
			bstr=gstr=rstr=ITH((100-(count%100))*16);
			if (bstr=='100') bstr=gstr=rstr="ff";							
			activeHeadline.style.color="#"+rstr+gstr+bstr;	
			
			if ((count%2)==0) {
				activeMember.getElementsByTagName("a")[0].style['opacity'] = (100-(count%100))/16.0;
				activeMember.getElementsByTagName("a")[0].style['filter'] = "alpha(opacity="+(100*(100-(count%100))/16.0)+")";
			}	
			
		}
	}
	
		
	if (i<0) i+=18000;
	if (i>18000) i-=18000;
	window.setTimeout("move2()", 50);
}
