scroller = {
	block : null,
	blockHeight : 0,
	height : 0,
	mTop : 0,
	timer : null,
	hasFrames : false,
	escroll : false,
	ah: 0,

	init : function() {
		if( ! this.escroll ) return;

		this.block = $('allas');

		this.blockHeight = this.block.getHeight();

		this.hasFrames = window.parent.frames.length ? true : false;
		this.ah = 0 - this.block.getHeight();

		var j = Math.ceil( this.height / this.blockHeight );
		while( j-- > 0 ) {
			var copy = new Element( 'dl', {id:'blockCopy'+j});
				copy.addClassName('blockCopy');
				copy.update( this.block.innerHTML );
				$('aScroller').insert({bottom:copy});
		}

		this.links();
		this.scroll();
	},

	setHeight : function( h ) {
		this.escroll = true;
		this.height = h;
		$('aScroller').setStyle({height:this.height+'px'});
	},

	links : function() {
		$$('dl#allas a').each( function(n){
			if( this.hasFrames ) {
				n.writeAttribute( 'target', '_blank' );
			}
			n.observe('mouseover', function(){
				scroller.stop();
			});
			n.observe('mouseout', function(){
				scroller.start();
			});
		},this );
	},

	scroll : function() {
		this.moveBlock();
		this.start();
	},

	stop : function() {
		clearTimeout( this.timer );
	},

	start : function() {
		if( ! this.escroll ) return;
		this.timer = setTimeout( 'scroller.scroll()', 100 );
	},

	moveBlock : function() {
		this.mTop -= 1;
		this.block.setStyle({marginTop:this.mTop+'px'});

		if( this.mTop == this.ah ) {
			this.stop();
			this.mTop = 0;
			this.block.setStyle({marginTop:this.mTop+'px'});
		}
	}

}

function __init() {
	scroller.init();

	Popup.show("popupWindowAd");
}
