var InfoTextSlider = Class.create(
{
	initialize: function(infoContainerId, innerSliderId)
	{
		this.infoContainer = infoContainerId;
		this.innerSlide = innerSliderId;
		this.isActive = false;
		this.contentWidth = 0;
		var ContainerWidth = $(infoContainerId).getWidth();
		$(innerSliderId).setStyle({ 'left' : (ContainerWidth+100)+'px' });
	},
	
	setContentWidth: function(num)
	{
		this.contentWidth = num;
	},
	
	getContentWidth: function()
	{
		return this.contentWidth;
	},
	
	calculateOffsets: function()
	{
		var offsets = new Object();
		offsets.start = $(this.infoContainer).getWidth()+100;
		offsets.end = -(this.getContentWidth()+$(this.infoContainer).getWidth()+100);
		return offsets;
	},
	
	startSlide: function()
	{
		var self = this;
		var DimsObj = this.calculateOffsets();

		var tickerSlide = new Effect.Move(self.innerSlide,
		{
			x: DimsObj.end,
			y: 0,
			duration: 20.0,
			transition: Effect.Transitions.linear,
			queue: { position : 'end', scope: 'newsTicker' },
			beforeStart: function()
			{
				self.isActive = true;
			},
			afterFinish: function()
			{
				self.isActive = false;
				self.returnSlide(DimsObj);
			}
		});
		tickerSlide = null;
	},
	
	kopierSlide: function()
	{
		/*var gammelSlide = $(this.innerSlide).childElements();
		gammelSlide.each(function(elem)
		{
			var nySlide = $(elem).cloneNode(true);
			$(this.innerSlide).appendChild(nySlide);
			nySlide = null;
		}.bind(this));
		*/
	},
	
	returnSlide: function(DimsObj)
	{
		setTimeout(function()
		{
			$(this.innerSlide).setStyle({ 'left' : DimsObj.start+'px' });
			this.startSlide();			
		}.bind(this), 700);
	}
});
Event.observe(window, 'load', function()
{
	var InfoSlider = new InfoTextSlider('infotextContainer', 'infotext');
	InfoSlider.setContentWidth($('infotext').getWidth());
	InfoSlider.startSlide();
//	InfoSlider.kopierSlide();
});