var newsSlideShow;
function setNewsArray(array, id, delay, duration, delimiter)
{
	newsSlideShow = new HorizontalNewsSlideShow("newsSlideShow", array, document.getElementById(id), delay, duration, 20, delimiter);
	//newsSlideShow.startSlide();
}

function NewsSlideShow(aSelfString, aNewsArray, aTargetElem, aDelay)
{
	this.selfString = aSelfString;
	this.newsArray  = aNewsArray;
	this.targetElement = aTargetElem;
	this.currentIndex = 0;
	this.delay = aDelay;
	this.slide;
	
	this.next = function()
	{
		this.currentIndex = (this.currentIndex +1) % this.newsArray.length;
		this.set();
	}
	
	this.set = function()
	{
		if(this.currentIndex < this.newsArray.length)
		{
			this.targetElement.href = this.newsArray[this.currentIndex][0];
			this.targetElement.firstChild.nodeValue = this.newsArray[this.currentIndex][1];
		}
	}
	
	this.startSlide = function()
	{
		this.slideHandle = window.setInterval(this.selfString + ".next()", this.delay);
	}
	if(this.newsArray.length > 0)
	{
		this.set();
	}
}

function HorizontalNewsSlideShow(aSelfString, aNewsArray, aTargetContainer, aDelay, aDuration, aFPS, aDelim)
{
	this.selfString = aSelfString;
	this.newsArray  = aNewsArray;
	this.targetElement = aTargetContainer;
	this.currentIndex = 0;
	this.delay = aDelay;
	this.delimiter = aDelim;
	this.slide;
	
	if(this.newsArray.length > 0)
	{
		this.targetElement.setAttributeNode(document.createAttribute("style"));
		this.targetElement.style.overflow = "hidden";
		this.targetElement.style.whiteSpace = "nowrap";
		for(var i = 0; i < this.newsArray.length; i++)
		{
			var link = document.createElement("a");
			var ref  = document.createAttribute("href");
			var desc = document.createTextNode(this.newsArray[i][1]);
			ref.nodeValue = this.newsArray[i][0];
			link.appendChild(desc);
			link.setAttributeNode(ref);
			link.setAttributeNode(document.createAttribute("style"));
			link.style.whiteSpace = "nowrap";
			this.targetElement.appendChild(link);
			this.targetElement.appendChild(document.createTextNode(this.delimiter));
		}
		var link = document.createElement("a");
		var ref  = document.createAttribute("href");
		var desc = document.createTextNode(this.newsArray[0][1]);
		ref.nodeValue = this.newsArray[0][0];
		link.appendChild(desc);
		link.setAttributeNode(ref);
		link.setAttributeNode(document.createAttribute("style"));
		link.style.whiteSpace = "nowrap";
		this.targetElement.appendChild(link);
	}
	
	var scrollSize = $(this.targetElement.id).getScrollSize();
	aDuration = aDuration * (scrollSize.x * 0.01); //Scrolldauer ist definiert für 100 pixel
	this.scroller = new Fx.Scroll(this.targetElement.id, {
	    duration: aDuration,
		fps: aFPS,
		wait: false,
		transition: 'linear',
		wheelStops: false,
		offset: {
	        'x': 0,
	        'y': 0
	    } });
		this.scroller.complete = function(){
			this.set(0,0);
			this.toRight();
			}
		this.scroller.set(0, 0);
		this.scroller.toRight();
}
