/**
 *  author:		Timothy Groves - http://www.brandspankingnew.net
 *	version:	1.3 - 2006-11-02
 *				1.2 - 2006-11-01
 *				1.1 - 2006-09-29
 *				1.0 - 2006-09-25
 *
 *	requires:	nothing
 *
 */
var useBSNns;
var sidePanelTableIDs = new Array();
var singlePanelID = new Array();

var sideGraphIDs = new Array();
var singleGraphID = new Array();

var hasSideTablePanels = false;

if (useBSNns)
{
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}
else
{
	var _bsn = this;
}


_bsn.Crossfader = function (divs, fadetime, delay)
{	
	this.nAct = -1;
	this.aDivs = divs;
	hasSideTablePanels = false;
	for (var i=0;i<divs.length;i++) {
	   if (document.getElementById(divs[i])) { 
		   hasSideTablePanels = true;
		   document.getElementById(divs[i]).style.opacity = 0;
		   document.getElementById(divs[i]).style.position = "absolute";
		   document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
		   document.getElementById(divs[i]).style.visibility = "hidden";
		} 
	}
	
	if (hasSideTablePanels) {
	    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;
	
	if (this.nAct == this.nOldAct)
		return false;

		
	document.getElementById( this.aDivs[this.nAct] ).style.visibility = "visible";

	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 ieop = Math.round( this._easeInOut(this.nTime, 0, 1, this.nDur) * 100 );

	var op = ieop / 100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	
	if (this.nOldAct > -1)
	{
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivs[this.nOldAct] ).style.visibility = "hidden"		

		var p=this;
		this.nID1 = setInterval(function() { p._newfade(); }, this.nDelay);
	}
}



_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d)
{
	//document.title = t + "(time), " + b + "(zero), " + c + "(1), " + d + "(duration), " + c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	
}


// Fade Out element //
_bsn.Fadeout = function (divs, fadetime, delay)
{	
	this.nActOut = -1;
	this.aDivsOut = divs;
	
	hasSideTablePanels = false;
	for (var i=0;i<divs.length;i++) {
	   if (document.getElementById(divs[i])) { 
		   hasSideTablePanels = true;
		   document.getElementById(divs[i]).style.opOutacity = 1;
		   document.getElementById(divs[i]).style.position = "absolute";
		   document.getElementById(divs[i]).style.filter = "alpha(opOutacity=100)";
		} 
	}
	
	if (hasSideTablePanels) {
	    this.nDurOut = fadetime;
		this.nDelayOut = delay;
	    this._newfadeOut();
	}

}


_bsn.Fadeout.prototype._newfadeOut = function()
{
	if (this.nID3)
		clearInterval(this.nID3);
		
	this.nOldAct = this.nActOut;
	this.nActOut++;
	if (!this.aDivsOut[this.nActOut])	this.nActOut = 0;
	
	if (this.nActOut == this.nOldAct)
		return false;

		
	document.getElementById( this.aDivsOut[this.nActOut] ).style.visibility = "visible";

	this.nIntOut = 50;
	this.nTimeOut = 0;
	
	var p=this;
	this.nID4 = setInterval(function() { p._fadeOut(); }, this.nIntOut);
	
}


_bsn.Fadeout.prototype._fadeOut = function()
{
	this.nTimeOut += this.nIntOut;
	
	var ieopOut = Math.round( this._easeOut(this.nTimeOut, 0, 1, this.nDurOut) * 100 );
	var opOut = ieopOut / 100;
	document.getElementById( this.aDivsOut[this.nActOut] ).style.opacity = 1 - opOut;
	document.getElementById( this.aDivsOut[this.nActOut] ).style.filter = "alpha(opacity="+ (100 - ieopOut) +")";
	
	if (this.nOldAct > -1)
	{
		document.getElementById( this.aDivsOut[this.nOldAct] ).style.opacity = 1 - opOut;
		document.getElementById( this.aDivsOut[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieopOut)+")";
		
	}
	
	if (this.nTimeOut == this.nDurOut)
	{
		clearInterval( this.nID4 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivsOut[this.nOldAct] ).style.visibility = "hidden"		

		var p=this;
		this.nID3 = setInterval(function() { p._newfadeOut(); }, this.nDelayOut);
	}
}

_bsn.Fadeout.prototype._easeOut = function(t,b,c,d)
{
	//document.title = t + "(time), " + b + "(zero), " + c + "(1), " + d + "(duration), " + c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	return (c/2 * (1 - Math.cos(Math.PI*t/d)) + b);
	
}