window.tickers = new Array();
			
function Ticker() {
	// create a new entry in the list of tickers, for us. this
	// is a hack, becasue window.setInterval sucks
	this.index = window.tickers.length;
	window.tickers[this.index] = this;
	
	// store the provided items structure in a local var, so we
	// can edit it later if required
	var items = new Array();
	for( var n=0; n<arguments.length; n++ ) {
		items.push(arguments[n]);
	}
	
	// create the three DOM objects
	var ticker = document.createElement('DIV');
	var scroll = document.createElement('DIV');
	var link   = document.createElement('A');
	var txt    = document.createTextNode('');
	this.link = link;
	
	// configure the ticker
	ticker.id = 'ticker';
	ticker.style.position = 'absolute';
	ticker.style.overflow = 'hidden';
	ticker.appendChild(scroll);
	
	//scroll.style.marginLeft = '1000px';
	scroll.style.marginTop = '-100px';
	scroll.appendChild(link);

	// configure the scrolling link
	link.style.whiteSpace = 'nowrap';
	link.appendChild(txt);
	
	// hook it all together. from now, everything is visible
	document.getElementsByTagName('BODY')[0].appendChild(ticker);
	
	// advance the ticker one pixel, and reset it if it has
	// fallen off the bottom of the container
	this.step = function() {
		this.currentOffset += 1;
		scroll.style.marginTop = this.currentOffset + 'px';
		
		if( this.currentOffset > (link.scrollHeight+5) ) {
			this.reset();
			
		} else {
			setTimeout(
				'window.tickers[' + this.index + '].step();',
				( this.currentOffset == ((link.scrollHeight/2) - (scroll.scrollHeight/2) + 2) ) ? 1000 : 50
			);
		}
	};
	
	// push the ticker back to it's original position (off the
	// top side of the container), and rotate the text contents
	this.reset = function() {
		var item = items.shift();
		items.push(item);
		
		this.currentOffset = -ticker.clientHeight;
		this.link.href = item[1];
		this.link.replaceChild(
			document.createTextNode(item[0]),
			this.link.childNodes[0]
		);
		
		// start the ball rolling again
		setTimeout( 'window.tickers[' + this.index + '].step();', 50 );
	};
	
	this.reset();
}
