bannerRotator.instances = [];
function bannerRotator(dd,to) {
	
	var cop = 100;
	var curdiv = 0;
	var nextdiv = 1;
	this.timeout = to * 1000;
		
	var divs = new Array();
	var divnodes = document.getElementById(dd).childNodes;

	this.index = bannerRotator.instances.length;
	bannerRotator.instances[this.index] = this;
		
	for (n in divnodes) if (divnodes[n].nodeName=='DIV') {
	    divs.push(divnodes[n]);
	    divnodes[n].style.opacity = 0;
	    divnodes[n].style.filter='alpha(opacity=0)';
	}
	// Make first div visible
	divs[curdiv].style.opacity = 1;
	divs[curdiv].style.filter='alpha(opacity=100)';
	divs[curdiv].style.zIndex = 999;
	document.getElementById(dd).style.display = 'block';
	// Do nothing more if there is only one banner
	if (divs.length > 1) setTimeout('bannerRotator.instances['+this.index+'].CrossFade();',this.timeout);

	this.CrossFade = function() {
	    divs[curdiv].style.opacity = cop/100;
	    divs[curdiv].style.filter='alpha(opacity='+cop+')';
	    divs[nextdiv].style.opacity = 1-cop/100;
	    divs[nextdiv].style.filter='alpha(opacity='+(100-cop)+')';
	
	    if (cop > 0) {
		cop = cop - 5;
		setTimeout('bannerRotator.instances['+this.index+'].CrossFade();',10);
	    } else {
		divs[curdiv].style.zIndex = 0;
		divs[nextdiv].style.zIndex = 999;
		curdiv += 1; if (curdiv > divs.length-1) curdiv = 0;
		nextdiv += 1; if (nextdiv > divs.length-1) nextdiv = 0;
		cop = 100;
		setTimeout('bannerRotator.instances['+this.index+'].CrossFade();',this.timeout);
	    }
	};
}