

addLoadEvent(function() {
	nCaseStudies = (document.getElementsByClassName("caseStudy")) ? document.getElementsByClassName("caseStudy").length : 1;
	nCurrent = 1;
	for(var i=1; i<nCaseStudies+1; i++){
		window["oImageAnim" + i] = new ImageAnim("caseStudy" + i);
	};
	document.getElementById("caseStudy1").style.visibility = "visible";
	window.oBannerTimer = window.setInterval("randomBanner()", 5000);
});


document.aAnims = []
function ImageAnim(sID){
	this.sID = sID;
	this.setOpacity("", 95);
	this.index = document.aAnims.length;
	document.getElementById(this.sID).style.visibility = "hidden";
	document.getElementById(this.sID).style.display = "block";
	document.aAnims[document.aAnims.length] = this;
};
ImageAnim.prototype.setOpacity = function(n, nPercent){
	if(document.all)
		document.getElementById(this.sID).style.filter = "alpha(opacity="+nPercent+")";
	else{
		document.getElementById(this.sID).style.opacity  = nPercent/100;
	}
	this.nAlpha = nPercent;
};
ImageAnim.prototype.fadeIn = function(n){
	clearTimeout(this.oTimer);
	document.getElementById(this.sID).style.visibility = "visible";
	if(this.nAlpha == 95) return;
	this.setOpacity(n, this.nAlpha + 5);
	this.oTimer = setTimeout("document.aAnims[" + this.index + "].fadeIn(" + n + ")", 20);
};
ImageAnim.prototype.fadeOut = function(n){
	clearTimeout(this.oTimer);
	if(this.nAlpha <= 0) return document.getElementById(this.sID).style.visibility = "hidden";
	this.setOpacity(n, this.nAlpha - 5);
	this.oTimer = setTimeout("document.aAnims[" + this.index + "].fadeOut(" + n + ")", 20);
};
function randomBanner(){
	window["oImageAnim" + nCurrent].fadeOut();
	nCurrent ++;
	if(nCurrent > nCaseStudies){
		nCurrent = 1;
	};
	window["oImageAnim" + nCurrent].nAlpha = 5;
	window["oImageAnim" + nCurrent].fadeIn();
};
document.getElementsByClassName = function(sClassName){
    var aReturn = [];
    var re = new RegExp('(^| )'+sClassName+'( |$)');
    var aAll = document.all || this.getElementsByTagName("*");
    for(var i=0,j=aAll.length; i<j; i++){
        if(re.test(aAll[i].className))aReturn[aReturn.length] = aAll[i];
	}
    return aReturn;
}
