function CM_headline()
{
	this.data = null;
	this.itemCount = 0;
	this.name = '';
	this.itemsName = '';
	
	this.isChangeable = 1;
	this.curIndex = 0;
	this.prevItem = -1;
	this.timeoutFunction = '';
	this.timeoutIndex = "";
	
	this.imageElement = null;
	this.linkElement = null;
	this.titleElement = null;
	this.displayElement = null;
	this.newsTypeElement = null;

	this.changeItem = function(opcode)
	{		
		this.clearTimeout();
	
		this.curIndex += opcode;
		
		if(this.curIndex > this.itemCount)
			this.curIndex = 1;
		else if (this.curIndex < 1)
			this.curIndex = this.itemCount;
		
		if(this.imageElement)
		{
			this.imageElement.src = "images/news/" + this.data[this.curIndex]['image'] + ".jpg";
		}
		
		if(this.linkElement)
		{
			this.linkElement.href = this.data[this.curIndex]['link'];
		}

		if(this.itemsName)
		{
			document.getElementById(this.itemsName + this.curIndex).className = "active";
			
			if(this.prevItem != -1)
			{
				document.getElementById(this.itemsName + this.prevItem).className = "";
			}
		}
		if(this.displayElement)
		{
			this.displayElement.innerHTML = this.curIndex + ' / ' + this.itemCount;
		}
		// this.titleElement.innerHTML = this.data[this.curIndex]['title'];
		
		//document.getElementById("news_arrow").style.backgroundPosition = (22 + curIndex * 58 ) + "px 0px";
				
		this.prevItem = this.curIndex;
		
		if(this.isChangeable)
			this.timeoutIndex = setTimeout(this.timeoutFunction, 8000);
		
	}
	
	this.clearTimeout = function()
	{
		if(this.timeoutIndex != "")
		{
			clearTimeout(this.timeoutIndex);
			this.timeoutIndex = "";
		}
	}
	
	this.jumpTo = function(idx)
	{
		if(idx == this.prevItem)
			return;
		this.isChangeable = 0;
		this.clearTimeout();
		this.changeItem(idx - this.prevItem);
	}
	
	this.forwClick = function()
	{
		this.isChangeable = 1;
		
		this.timeoutFunction = this.name + ".changeItem(1)";
		
		this.changeItem(1);
		
		this.clearTimeout();
		
		this.timeoutIndex = setTimeout(this.timeoutFunction, 8000);
	}
	
	this.backClick = function()
	{
		this.isChangeable = 1;
		
		this.timeoutFunction = this.name + ".changeItem(-1)";
		
		this.changeItem(-1);
		
		this.clearTimeout();
				
		this.timeoutIndex = setTimeout(this.timeoutFunction, 8000);
	}

}
