var htOverStat = new Array();

function HorizontalTicker()
{
	this.width = 0;
	this.height = 0;
	this.widthLimit = 1000;
	this.id = 'ht' + (new Date).getTime();
	this.content = null;
	htOverStat[this.id] = false;
	this.scrollSpeed = new function(){
		this.mSec = 40;
		this.step = 1;
	}
}

HorizontalTicker.prototype.draw = function() {
	html='<div style="width:'+ this.width +'px; height:' + this.height + 'px; overflow:hidden;" onMouseover="htOverStat[\'' + this.id + '\']=true" onMouseout="htOverStat[\'' + this.id + '\']=false">';
	html+='<div style="position:relative;" id="' + this.id + '">';
	html+='</div>';
	html+='<div style="width:' + this.widthLimit + 'px;">';
	html+='<table style="border-collapse: collapse;"><tr><td id="' + this.id + 'C"></td></tr></table>';
	html+='</div>';
	html+='</div>';
	document.write(html);
	document.getElementById(this.id + 'C').innerHTML = this.content;
}

HorizontalTicker.prototype.init = function() {
	var cWidth = document.getElementById(this.id + 'C').clientWidth;
	var iHTML = document.getElementById(this.id + 'C').innerHTML;
	html = '<span id="'+this.id+'L0" style="position:absolute;width:'+ cWidth +';left:0">' + iHTML + '</span>';
	html += '<span id="'+this.id+'L1" style="position:absolute;width:'+ cWidth +';left:'+ cWidth +'">' + iHTML + '</span>';
	document.getElementById(this.id).innerHTML = html;
	document.getElementById(this.id + 'C').style.display = 'none';
}

HorizontalTicker.scroll = function(id, scrollMSec, scrollStep) {
	if(!htOverStat[id])
	{
		for (i=0;i<2;i++){
			tmp = document.getElementById(id + 'L' + i).style;
			tmp.left = parseInt(tmp.left) - scrollStep;
			if (parseInt(tmp.left) <= -parseInt(tmp.width)){
				tmp.left = tmp.width;
			}
		}
	}
	window.setTimeout('HorizontalTicker.scroll("' + id + '", ' + scrollMSec + ', ' + scrollStep + ')',scrollMSec);
}

HorizontalTicker.prototype.start = function() {
	this.init();
	HorizontalTicker.scroll(this.id, this.scrollSpeed.mSec, this.scrollSpeed.step);
}

function HyperTextEntity(text, href, className)
{
	this.text = text;
	this.href = href;
	this.className = className;
}

function NewsEntity(text, href, category, cate_href, className)
{
	this.text = text;
	this.href = href;
	this.category = category;
	this.cate_href = cate_href;
	this.className = className;
}

function ContentBuilder()
{}

ContentBuilder.buildContentTypeA = function(textList){
	var content = '';
	for(i=0;i < textList.length;i++)
	{
		content += '<a href="' + textList[i].href  + '" id="test'+ i +'" class="pr">' + textList[i].text + '</a>';
		content += '<span id="space' + i +'" style="color:#bebebe">&nbsp;|&nbsp;</span>';
	}
	return content;
}

ContentBuilder.buildContentTypeB = function(newsList){
	var content = '';
	for(i=0;i < newsList.length;i++)
	{
		content += '<a href="'+newsList[i].cate_href+'"  class="pr">['+newsList[i].category+']</a> <a href="' + newsList[i].href  + '" id="test'+ i +'" class="pr">' + newsList[i].text + '</a>';
		content += '<span id="space' + i +'" style="color:#bebebe">&nbsp;&nbsp;&nbsp;&nbsp;</span>';
	}
	return content;
}
/* usage
			<script src="HorizontalTicker.js" type="text/javascript"></script>
			<script type="text/javascript">
			var textList = new Array();
			//Loop Start
			textList[0] = new HyperTextEntity('5¼¼ ÀÀ±ÞÈ¯ÀÚ,º´¿øÈÄ¼ÛÁß ¶Ç »ç°í', 'javascript:alert(0);','bg_12_555555');
			textList[1] = new HyperTextEntity('ÇÏ·çÁ¾ÀÏ ¼­¼­ ÀÏÇÏ´Â ÁÖºÎ', 'javascript:alert(1);','bg_12_555555');
			textList[2] = new HyperTextEntity('ÇÏ·çÁ¾ÀÏ ¾É¾Æ¼­ ÀÏÇÏ´Â °³¹ßÀÚ', 'javascript:alert(2);','bg_12_555555');
			//Loop End

			var ht = new HorizontalTicker();
			ht.content = ContentBuilder.buildContentTypeA(textList);
			ht.width = 360;
			ht.height = 13;
			ht.draw();

			if (window.addEventListener){
				window.addEventListener("load",function() {ht.start();}, false);
			} else {
				window.attachEvent("onload",function() {ht.start();});
			}
			</script>
*/