browser = testbrowser();
function testbrowser()
{
	var ureq;
	// Firefox, Opera 8.0+, Safari
	try { ureq = new XMLHttpRequest(); ureq = ''; return 'fos'; }
	catch(e) {	// Internet Explorer 6.0+
	try { ureq = new ActiveXObject("Msxml2.XMLHTTP"); ureq = ''; return 'ie'; }
	catch(e) { // Internet Explorer 5.5+
	try { ureq = new ActiveXObject("Microsoft.XMLHTTP"); ureq = ''; return 'ie'; }
	catch(e) { return 'x'; } } }
}
function opacity( idnya, opasiti )	//	opasiti: 0 - 100
{
	if( browser == 'fos' ) document.getElementById(idnya).style.MozOpacity = opasiti / 100;
	else if( browser == 'ie' ) document.getElementById(idnya).style.filter = "alpha(opacity="+opasiti+")";
	else document.getElementById(idnya).style.opacity = opasiti / 100;
}
function copacity(awalan, jumlah, namavar)
{
	this.interval = 4000;
	this.awalan = awalan;
	this.jumlah = jumlah;
	this.namavar = namavar;
	this.tmr = 0;
	this.cin = 0;
	this.tin = 0;
	this.oin = Math.floor(1 + (Math.random()*(jumlah-1)));
	this.oout = this.oin - 1;
	if( this.oout < 1 ) this.oout = jumlah;
	
	if( jumlah < 1 ) {;}
	else if( jumlah < 2 ) opacity( awalan+'1', 100 );
	else
	{
		var x;
		for( x = 1; x <= jumlah; x++ ) opacity( awalan+x, 0 );
		this.tik();
	}	
}
copacity.prototype.fadein = function()
{
	this.cin = this.cin + 5;
	if( this.cin < 100 )
	{
		opacity( this.awalan + this.oin, this.cin );
		opacity( this.awalan + this.oout, 100-this.cin );
		this.tin = setTimeout( this.namavar+".fadein()",50);
	}
	else
	{
		this.cin = 100;
		opacity( this.awalan + this.oin, this.cin );
		opacity( this.awalan + this.oout, 100-this.cin );
		clearTimeout(this.tin);
		this.cin = 0;
}	}
copacity.prototype.tik = function()
{
	this.oin = this.oin + 1;
	this.oout = this.oout + 1;
	if( this.oin > this.jumlah ) this.oin = 1;
	if( this.oout > this.jumlah ) this.oout = 1;
	this.tmr = setTimeout( this.namavar+".tik()",this.interval);
	this.fadein();
}


