var useBSNns;
var USECROSSFADE = 0;
if (useBSNns)
{
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}
else
{
	var _bsn = this;
}

_bsn.Crossfader = function (divs )
{	
	if(USECROSSFADE!="1"){ return false; }
	this.nAct = -1;
	this.aDivs = new Array();
	c=0;
	for (var i=0;i<divs.length;i++)
	{
		if(getE(divs[i])){
		this.aDivs[c] = divs[i];
		d = getE(divs[i]);
		d.style.top = '110px';
		d.style.display = '';
		d.style.position = "absolute";
		
		c++;
		}else{
			
		}
	}
	fadetime = 800; delay = 8000;
	this.nDur = fadetime;
	this.nDelay = delay;		
	this._newfade();
}


_bsn.Crossfader.prototype._newfade = function()
{
	if (this.nID1)
		clearInterval(this.nID1);
	
	this.nOldAct = this.nAct;
	this.nAct++;
	
	if (!this.aDivs[this.nAct])	this.nAct = 0;
	getE( this.aDivs[this.nAct] ).style.top = "155px";
	
	this.nInt = 50;
	this.nTime = 0;
	
	var p=this;
	this.nID2 = setInterval(function() { p._fade() }, this.nInt);
}


_bsn.Crossfader.prototype._fade = function()
{
	this.nTime += this.nInt;	
	var op = this._easeInOut(this.nTime, -160, 160, this.nDur);
	var ieop = op * (-1);
	
	aa = getE( this.aDivs[this.nAct] );
	aa.style.display = '';
	aa.style.top = ieop+'px';
	
	if (this.nOldAct > -1)
	{
		bb = getE( this.aDivs[this.nOldAct] );	
		bb.style.top = ieop - 160 + 'px';
	}
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1){	}		
		var p=this;
		this.nID1 = setInterval(function() { p._newfade() }, this.nDelay);
	}
}



_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d)
{
	return (c/2 * (1 - Math.cos(Math.PI*t/d)) + b);
}