// JavaScript Document

function randNum(range)
{
	var now = new Date()
	var num = (now.getSeconds()) % range
	var num = num + 1
	return num;
}

var max = 5;

function view_focus(focusnum) {
	for(var i = 1; i <= max; i++)	{
		if(document.getElementById('focus'+i) != null)
		{
			if(focusnum == i) {
				if(document.getElementById('btn_img_'+i) != null) 
				document.getElementById('focus'+i).style.display = 'block';
			}
			else 	{
				if(document.getElementById('btn_img_'+i) != null) 
				document.getElementById('focus'+i).style.display = 'none';
			}
		}
	}
}


// 배너 스크롤 //

function AddSiteScroll() {

	this.GoodsSetTime = null;

	this.Speed = 2;

}



AddSiteScroll.prototype.GoodsSetting = function() {

	this.DivName = "scrollBanner_Box";

	this.ScrollName = "AddSiteScroll_1";

	this.MovieWidth = 150;

	

	this.LiBox_Left = new Array();

	this.Last_Left = new Array();

	

	this.BannerUl = document.getElementById(this.DivName).getElementsByTagName("ul")[0];

	this.BannerBox = this.BannerUl.getElementsByTagName("li");

	this.BannerBoxNum = this.BannerBox.length;

	

	for ( var i=0; i<this.BannerBoxNum*2; i++ ) {

		this.objNewli = this.BannerBox.item(i).cloneNode(true);

		this.BannerUl.appendChild(this.objNewli)

	}

	

	this.Default_left = -this.BannerBoxNum*this.MovieWidth;

	

	this.BannerBoxNum = this.BannerBox.length;

	

	for ( var i=0; i < this.BannerBoxNum; i++ ) {

		this.LiBox_Left[i] = this.Default_left + ( i * this.MovieWidth );

		this.BannerBox.item(i).style.left = this.LiBox_Left[i] + "px";

	}

	

	this.Last_Left = this.LiBox_Left[this.BannerBoxNum-1];

	

	this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",20);

}



AddSiteScroll.prototype._nextFrame = function() {

	for ( var i=0; i<this.BannerBoxNum; i++ ) {

		this.LiBox_Left[i] = this.LiBox_Left[i] - this.Speed;

		if ( this.LiBox_Left[i] == ( this.Default_left - this.MovieWidth ) ) {

			this.LiBox_Left[i] = ( ( this.BannerBoxNum - 1 ) * this.MovieWidth ) + this.Default_left;

			this.BannerBox[i].style.left = this.LiBox_Left[i] + "px"

		} else {

			this.BannerBox[i].style.left = this.LiBox_Left[i]+"px";

		}

	}

	if ( Math.abs(this.LiBox_Left[0] % this.MovieWidth) < 1 ) {

		this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",20);

	} else {

		this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",20);

	}

}

AddSiteScroll.prototype._prevFrame = function() {

	for ( var i=0; i<this.BannerBoxNum; i++ ) {

		this.LiBox_Left[i] = this.LiBox_Left[i] + this.Speed;

		if ( this.LiBox_Left[i] == this.Last_Left + this.MovieWidth ) {

			this.LiBox_Left[i] = this.Default_left;

			this.BannerBox[i].style.left = this.LiBox_Left[i] + "px"

		} else {

			this.BannerBox[i].style.left = this.LiBox_Left[i]+"px";

		}

	}

	if ( Math.abs(this.LiBox_Left[0] % this.MovieWidth)  < 1 ) {

		this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",20);

	} else {

		this.GoodsSetTime = setTimeout(this.ScrollName + "._prevFrame()",20);

	}

}



AddSiteScroll.prototype._nextBtn = function() {

	clearTimeout(this.GoodsSetTime);

	this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",20);

}

AddSiteScroll.prototype._prevBtn = function() {

	clearTimeout(this.GoodsSetTime);

	this.GoodsSetTime = setTimeout(this.ScrollName + "._prevFrame()",20);

}

function initTicker(container, mover, delay) {
	speed = 150;		// milisecond
	container.moveOffset = container.offsetHeight;
	container.cont = mover;
	container.cont.currentHeight = 0;
	container.cont.innerHTML += container.cont.innerHTML;

	container.move = window.setInterval(
		function () {
			container.cont.currentHeight--;
			container.cont.style.top = container.cont.currentHeight + "px";
			if (container.cont.currentHeight % (container.cont.offsetHeight / 2) == 0) {
				container.cont.currentHeight = 0;
			}
		}
	, speed);
}


function pop_up_korea() {
window.open('http://english.tour2korea.com/02Culture/KoreanLanguage/today/today_word.asp?fCountry=Chg','','width=530,height=680');
}
