/**
 *  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;

if (useBSNns)
{
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}
else
{
	var _bsn = this;
}



// Constructor

_bsn.Crossfader = function (divs, fadetime, delay )
{	
	this.nAct = -1;
	this.aDivs = divs;
	
	for (var i=0;i<divs.length;i++)
	{
		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";
	}
	
	this.nDur = fadetime;
	this.nDelay = delay;

	this.stopPending = false;
	this.stopped = false;
		
	this._newfade();
}

// Public methods

_bsn.Crossfader.prototype.StopFade = function()
{
	if (this.stopped || this.stopPending)
	{
		return;
	}
	this.stopPending = true;
	//if (this.nID1)
	//	clearInterval(this.nID1);
}

_bsn.Crossfader.prototype.StartFade = function()
{
	if (this.stopPending)
	{
		this.stopPending = false; // Cancel pending stop
		return;
	}
	else if (!this.stopped)
	{
		return;
	}
	this._newfade();
}

_bsn.Crossfader.prototype.SetFade = function(newFade)
{
	newFade = parseFloat(newFade);
	if (isNaN(newFade))
	{
		return "Value provided for new fade time must be numeric";
	}
	if (newFade < 0)
	{
		return "Value provided for new fade time cannot be negative";
	}

	this.StopFade();
	this.nDur = newFade * 1000;
	this.StartFade();
	return "";
}

_bsn.Crossfader.prototype.SetDelay = function(newDelay)
{
	newDelay = parseFloat(newDelay);
	if (isNaN(newDelay))
	{
		return "Value provided for new display time must be numeric";
	}
	if (newDelay <= 0)
	{
		return "Value provided for new display time must be greater than zero";
	}

	this.StopFade();
	this.nDelay = newDelay * 1000;
	this.StartFade();
	return "";
}

// Private methods

_bsn.Crossfader.prototype._newfade = function()
{
	if (this.nID1)
		clearInterval(this.nID1);

	if (this.stopPending)
	{
		this.stopPending = false;
		this.stopped = true;
		return;
	}
	this.stopped = false;
	
	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)
{
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}


/***** END CROSSFADER *****/



sfHover = function() 
{ 
	var sfEls = document.getElementById("new-nav").getElementsByTagName("LI");
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}     
	} 
} 
if (window.attachEvent) window.attachEvent("onload", sfHover); 
	
function emptyShell(variableName) {
this.variableName = variableName;
this.variable = this;
this.enable = function () {
		for (var e = 0; e < this.enable.arguments.length; e++) 
		{
			if (typeof this.enable.arguments[e] == "object") 
			{
				for (var ee = 0; ee < this.enable.arguments[e].length; ee++) 
				{
					this[this.enable.arguments[e][ee]] = new shellGuest(this.variableName, this.enable.arguments[e][ee]);
				}
			}
			else 
			{
				this[this.enable.arguments[e]] = new shellGuest(this.variableName, this.enable.arguments[e]);
			}
		}
};
for (var i = 1; i < emptyShell.arguments.length; i++) {
	this.enable(emptyShell.arguments[i]);
}
this.timer = false;
this.abilitate = function () {return;};
}


function shellGuest(variableName, methodName) {
	this.variableName = this.managerName = variableName;
	this.owner = this.manager = this.variable = eval(variableName);
	this.methodName = methodName;
	this.exec = this.exe = this.ex = this.x = this.X = this.e = this.execute = eval(methodName);
	this.isRunning = 0;
	this.isTimed = 0;
	this.run = function (arg) {arg = arg ? arg : "";var runner = this.variableName + "." + this.methodName + ".execute(" + arg + ")";this.timer = setInterval(runner, parseFloat(this.variable.speed) ? parseFloat(this.variable.speed) : parseFloat(this.speed));};
	this.timedRun = function (arg) {arg = arg ? arg : "";var runner = this.managerName + "." + this.methodName + ".execute(" + arg + ")";this.isTimed = 1;this.timer = setTimeout(runner, parseFloat(this.variable.speed) ? parseFloat(this.variable.speed) : parseFloat(this.speed));};
	this.stop = function () {if (!this.isTimed) {clearInterval(this.timer);} else {clearTimeout(this.timer);this.isTimed = 0;}this.isRunning = 0;};
	this.setAttributes = function () {if (!this.setAttributes.arguments.length) {return;}if (this.setAttributes.arguments.length >= 2) {for (var A = 0; A < this.setAttributes.arguments.length - 1; A += 2) {this[this.setAttributes.arguments[A]] = this.setAttributes.arguments[A + 1];}} else {if (typeof this.setAttributes.arguments[0] == "object" && this.setAttributes.arguments[0].length >= 2) {for (var L = 0; L < this.setAttributes.arguments[0].length - 1; L += 2) {this[this.setAttributes.arguments[0][L]] = this.setAttributes.arguments[0][L + 1];}}}};
	this.setAttribute = this.setattribute = this.setattributes = this.attributes = this.set = this.setAttributes;

}

function scroller() {
	if (!this.isRunning) {
		this.isRunning = 1;
		this.currentCycles = 0;
		this.bareObject = document.getElementById ? document.getElementById(this.variableName) : document.all ? document.all[this.variableName] : 0;
		if (!this.bareObject) {
			this.isRunning = 0;
			return false;
		}
		this.owner.lastCalled = this.methodName;
		this.reset = function () {this.bareObject.style.top = "0px";this.bareObject.style.left = "0px";};
		this.speed = !isNaN(parseFloat(this.speed)) ? parseFloat(this.speed) : 200;
		this.scroll = !isNaN(parseFloat(this.scroll)) ? parseFloat(this.scroll) : 1;
		this.increaser = this.bareObject.offsetTop;
	}
	this.increaser -= this.scroll;
	if (this.increaser < - this.bareObject.offsetHeight) {
		++this.currentCycles;
		this.increaser = this.bareObject.parentNode.offsetHeight;
	}
	this.bareObject.style.top = this.increaser + "px";
/* keep this comment to reuse freely:
http://www.unitedscripters.com */}

var news_scroller=new emptyShell("news_scroller");

news_scroller.enable("scroller");
news_scroller.scroller.setAttributes(
	"speed", 70,
	"scroll", 1
)
news_scroller.scroller.run();

/* little js to expand/collapse hte team page */
function expand_collapse(whichDiv) {
	
	if ((document.getElementById(whichDiv).style.display == "none") || (document.getElementById(whichDiv).style.display == "")) {
		
		try {	document.getElementById('board_2').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_1').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_6').style.display = "none"; } catch(err) {}
		try {	document.getElementById('henry1').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_7').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_11').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_12').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_13').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_14').style.display = "none"; } catch(err) {}
		try {	document.getElementById('board_sh').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_1').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_3').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_11').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_12').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_13').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_14').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_15').style.display = "none"; } catch(err) {}
		try {	document.getElementById('people_63').style.display = "none"; } catch(err) {}
	 
		document.getElementById(whichDiv).style.display = "block";
	} else {
		document.getElementById(whichDiv).style.display = "none";		
	}
	
}


