var scrollticker = Class.create();

scrollticker.prototype = {

	speed:      70,
	delay:      2000,
	oContainer: null,
	oList:      null,
	
	bScroll   : true,
	oAnimation: null,

	initialize: function(sScrolltickerId)
	{
		this.oContainer = $(sScrolltickerId);
		if (this.oContainer == null) return;

		this.oList = $(this.oContainer).down('UL');
		if (this.oList == null) return;

		// Alle LI-Elemente durchgehen
		$A(this.oList.getElementsByTagName('LI')).each(
			function(obj)
			{
				$(obj).show();
				if ( $(obj).getHeight() < 250	)
					$(obj).setStyle({'height': '250px'});
			}
		);
		
		// Start/Stop Events registrieren
		this.oContainer.onmouseover = this.stop.bind(this);
		this.oContainer.onmouseout = this.start.bind(this);

		window.setTimeout(this.scroll.bind(this), this.delay);
	}, // function initialize

	scroll: function()
	{
		var iHeight = this.oList.down('LI').getHeight();

		this.oAnimation = new Effect.Move(this.oList,
			{
				y: (iHeight * -1),
				duration: (iHeight / this.speed),
				afterFinish: function() { window.setTimeout(this.prepareNextStep.bind(this), this.delay) }.bind(this)
			}
		);
	},

	prepareNextStep: function()
	{
		if (this.bScroll)
		{
			var oCurItem = this.oList.down('LI');
	
			var iCurItemHeight = oCurItem.getHeight();
			this.oList.appendChild(oCurItem.cloneNode(true));
	
			oCurItem.remove();
			$(this.oList).setStyle({top: '0px'});
			this.scroll();
		} // if
		else
		{
			window.setTimeout(this.prepareNextStep.bind(this), 1000);
		} // else
	}, // function prepareNextScroll

	stop: function() { this.bScroll = false; },
	start: function() { this.bScroll = true; }
}