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.newsTypeElement)
		{
			if(this.data[this.curIndex]['news_type'])
			{
				_WIDTH = 486;
				_HEIGHT = 220;
				_SRC = 'images/news_type_'+ this.data[this.curIndex]['news_type'] + '.swf';
				
				str = '<div style="width: ' + _WIDTH + 'px; height: ' + _HEIGHT + 'px;">';
				str += '<object width="' + _WIDTH + '" height="' + _HEIGHT + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0">';
				str += '<param name="movie" value="' + _SRC + '">';
				str += '<param name="quality" value="high">';
				str += '<param name="wmode" value="transparent">';
				str += '<param name="scale" value="1">';
				str += '<embed src="' + _SRC + '" width="' + _WIDTH + '" height="' + _HEIGHT + '" scale="exactfit" quality="high" wmode="transparent" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>';
				str += '</object>';
				str += '</div>';
				this.newsTypeElement.style.display = 'block';
				this.imageElement.style.width = '436px';
				this.imageElement.style.height = '199px';
				this.imageElement.style.left = '50px';
				
			}
			else
			{
				this.newsTypeElement.style.display = 'none';
				this.imageElement.style.width = '486px';
				this.imageElement.style.height = '220px';
				this.imageElement.style.left = '0px';
				str = '';
			}
			
			this.newsTypeElement.innerHTML = str;
		}
		
		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;
		}
		
		if(this.titleElement)
		{
			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);
	}

}

function changeNewsDetail(idx)
{
	if(previousItem != -1)
	{
		document.getElementById("news_headline_" + previousItem).style.display = 'none';
	}
	document.getElementById("news_headline_" + idx).style.display = 'block';
	
	document.getElementById("news_image").src = './images/news/' + imageArr[idx] + '.jpg';
	document.getElementById("news_spot").innerHTML = "<a href=\"" + linkArr[idx] + "\">" + spotArr[idx] + "</a>";
	document.getElementById("news_link").href = linkArr[idx];
	
	previousItem = idx;
	return false;
}
function getFlashMovie(flash)
{
	return (isIE) ? window[flash] : document[flash];
}
function changeNewsDetailFlash(idx)
{
	eval('elm = news_data');
	if(typeof(window['elm']) == "undefined")
		return;
	
	document.getElementById("news_image").src = './images/news/' + elm[idx]['image'] + '.jpg';
	//document.getElementById("news_date").innerHTML = elm[idx]['date'];
	document.getElementById("news_spot").innerHTML = '<a href="' + elm[idx]['link'] + '">' + elm[idx]['short_content'] + '</a>';
	document.getElementById("news_link").href = elm[idx]['link'];
	getFlashMovie("headlineFlashTitle").sendAUtoFlash(elm[idx]['headline']);

	return false;
}