var alternate=0x00ff00;

var isms=navigator.appName.indexOf("Microsoft")>=0;

function MarkCurLink()
{
	if (/*navigator.appName.indexOf("Microsoft")>=0*/isms)
	list=document.all.tags("a");
	else
	list=document.links;

	for (i=0; i<list.length;i++) 
	{
		url=list[i];
		if (document.location.href.indexOf(url)>=0)
		{
		url.style.background="#00ffff";
		url.style.color=0;
		//return;
		}
	}

}

function GetVersion()
{
	sAppVer = navigator.appVersion;
	p = sAppVer.indexOf(".",0);
	v = sAppVer.substring(0,p);
        p = navigator.appName.indexOf("Microsoft");
        allow = (v>3)&&(p>=0);
	return (v);
}

function ChangeColor1(n,m)
{	
	setTimeout("ChangeColor1("+n.id+","+m.id+")",100);
	alternate+=0x020600;
	if (alternate>=0xffffff) 
		{alternate=0x00ff00;}
	n.color=alternate|0x0000f0;
	m.color=alternate+0x0f0f0f;
}

var hexfig = new Array ("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");

function IntToHex(l,size)
{        
	s = ""; l = Math.floor(l); tetr = 0; res=1;
    while (size>0)
	{
	res = (l >> (4*tetr));
	s =hexfig[res & 0x0000000f]+s;
	tetr++;size--;
	}
    return(s);
}

function HexToInt(str)
{ 
	if (str=="") return(0); 
	else 
	return(eval('0x'+str.substring(1,7)));
}

function MakeColor(R,G,B)
{
 return (((R&0xff)<<16)|((G&0xff)<<8)|(B&0xff));
}

function GetR(clr) {return((clr&0x00ff0000)>>16);}
function GetG(clr) {return((clr&0x0000ff00)>>8);}
function GetB(clr) {return(clr&0x000000ff);}

var
  colorspeed = 8;

function Rnd(r)
{
	return(Math.floor(r*Math.random(0)))
}


function LiteIt()
{
	var arg=new Array();
	for (i=0;i<arguments.length;i++)
	{
	 obj = arguments[i];
	 
	 clr = obj.style.color; 
	 
	 clr = HexToInt(clr);
	 r = GetR(clr); g = GetG(clr); b = GetB(clr);

	 if (r==0&&g==0&&b==0) {r=Rnd(256);g=255-r};
	
	 if (r!=0&&b==0) {r-=colorspeed;g+=colorspeed} else
	 if (g!=0) {g-=colorspeed;b+=colorspeed} else
	 if (b!=0) {b-=colorspeed;r+=colorspeed};
	 if (r<0) r=0;
	 if (g<0) g=0;
	 if (b<0) b=0;
	 if (r>255) r=255;
	 if (g>255) g=255;
	 if (b>255) b=255; 

	 clr = MakeColor(r,g,b);
	 obj.style.color="#"+IntToHex(clr,6);
	 arg[i]=obj.id;
	}	
	s = "LiteIt("+arg.join()+")";
	window.setTimeout(s,100);
}

function LiteItM()
{
	var r=0,g=0,b=0,rgb;
	var arg=new Array();
	for (i=0;i<arguments.length;i++)
	{
		obj = document.getElementById(arguments[i]);
	 	if (obj==null) continue;
	 
		clr = obj.style.color; 
	
		moz=clr.indexOf('rgb(')>=0;
		
		if (isms && !moz) // IE specific
		{
			clr = HexToInt(clr);
	 		r = GetR(clr); g = GetG(clr); b = GetB(clr);
		} 
		else
		{
//			alert(clr);
			bs="";
     		p1=clr.indexOf('(');
	 		p2=clr.indexOf(')');
			bs=clr.substring(p1+1,p2);
			rgb=bs.split(",");
			
			
			// window.status=rgb[0]+'+'+rgb[1]+"+"+rgb[2];
			//	 alert(bs);
	 		r=eval(rgb[0]); g=eval(rgb[1]); b=eval(rgb[2]);
			
			if (typeof(r)=='undefined') r=0;
			if (typeof(g)=='undefined') g=0;
			if (typeof(b)=='undefined') b=0;
		}
		
		

	 	if ((r==0)&&(g==0)&&(b==0)) {r=Rnd(256);g=255-r};
	
	 	if ((r!=0)&&(b==0)) {r-=colorspeed;g+=colorspeed;} 
		else
		if (g!=0) {g-=colorspeed;b+=colorspeed;} 
		else
	 	if (b!=0) {b-=colorspeed;r+=colorspeed;};
		
		if (r<0) r=0;
	 	if (g<0) g=0;
	 	if (b<0) b=0;
	 	if (r>255) r=255;
	 	if (g>255) g=255;
	 	if (b>255) b=255; 
		
		clr = MakeColor(r,g,b);
 		obj.style.color="#"+IntToHex(clr,6); 
		
	 	arg[arg.length]="'"+obj.id+"'";
	}	

	
	s = "LiteItM("+arg.join(",")+")";
	
	window.setTimeout(s,1000);
	
	return(true);
}


function ChangeColor(n)
{	
	setTimeout("ChangeColor("+n.id+")",100);
	alternate+=0x020601;
	if (alternate>=0xffffff) 
		{alternate=0x00ff00;}
	n.color=alternate;
}

function doTrans(logo)
{
	logo.filters.item(0).Apply();
	logo.style.visibility="";
	logo.filters.item(0).Play();
}

function  doLight(o)
{
	o.style.filter="Light(0)";
	o.filters[0].addPoint(20,10,100,255,255,255,1000);
	o.filters[0].addAmbient(255,255,255,50);
}

d1 = new Date("Mar 11 1994");

st=d1.getTime();// msecs 



function xclock()
{
	if (document.getElementById)
	{
	el= document.getElementById("clock");	
	d2 = new Date();
	t1=d2.getTime();
	mn = (t1-st)/60000;
	el.innerHTML = "runtime="+mn.toFixed(2)+" min";
	//st+=1000;
	window.setTimeout("xclock()",1000);
	}
}

function dumpfolders(cls)
{	if (typeof(folders) != "undefined")
	{
		for (i=0;i<folders.length;i++)
	  	document.write("<a '+cls+' href='"+folders[i][1]+"'>"+folders[i][0]+"</a> / ")
	};
	document.write(document.title);
}

function HandleChooser()
{
	str = document.location.pathname;
	arr = str.split(".");
	
	if (arr.length>0)
	{
		name = arr[0];
		base=name.substr(0,name.length-1);
	
		list = new Array("bel","deu","eng","rus");
		for (sel in list)
		{
			loc = list[sel];
			h = document.getElementById(loc);
			if (h)
			{
				lett = loc.substr(0,1);
				// localize document name in style main[lang-letter].ext
				h.pathname = base+lett+'.'+arr[1]; 
			}
			
		}
	}
}

