function CM_headline()
{
	this.data = null;
	this.name = "";
	this.itemsName = "headline_item_";
	this.itemCount = 10;

	this.isChangeable = 1;
	this.currIndex = 0;
	this.prevItem = -1;
	this.timeoutFunction = "";
	this.timeoutIndex = "";

	this.imageElement = null;
	this.titleElement = null;
	this.scElement = null;
	this.dateElement = null;

	this.changeItem = function(opcode)
	{		
		this.clearTimeout();

		this.currIndex += opcode;

		if(this.currIndex > this.itemCount)
			this.currIndex = 1;
		else if (this.currIndex < 1)
			this.currIndex = this.itemCount;

		this.imageElement.innerHTML = '<a href="' + this.data[this.currIndex]['l'] + '" target="_blank"><img src="images/news/' + this.data[this.currIndex]['i'] + '.jpg" /></a>';

		this.titleElement.innerHTML = this.data[this.currIndex]['t'];

		if(this.scElement)
		{
			this.scElement.innerHTML = this.data[this.currIndex]['sc'];
		}

		if(this.dateElement)
		{
			this.dateElement.innerHTML = this.data[this.currIndex]['d'];
		}

		if(this.itemsName)
		{
			document.getElementById(this.itemsName + this.currIndex).className = "item item_act";

			if(this.prevItem != -1)
			{
				document.getElementById(this.itemsName + this.prevItem).className = "item";
			}
		}

		this.prevItem = this.currIndex;

		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 = 0;

		this.changeItem(1);

		return false;
	}

	this.backClick = function()
	{
		this.isChangeable = 0;

		this.changeItem(-1);

		return false;
	}

	this.changeAuto = function()
	{
		this.isChangeable = 1;

		this.timeoutFunction = this.name + ".changeItem(1)";

		this.clearTimeout();

		this.timeoutIndex = setTimeout(this.timeoutFunction, 8000);
	}
}
