// JavaScript Document
function fnRolMove_Type1() {
	this.GoodsSetTime = null;
	this.BannerCurrent = 0;
	this.DateNum = 6;

	this.Start = function() {
		this.Obj = document.getElementById(this.BoxName);
		this.ObjBox = document.getElementById(this.DivName);

		this.ObjUl = this.ObjBox.getElementsByTagName("ul")[0];
		this.ObjLi = this.ObjUl.getElementsByTagName("li");

		// 배너 갯수를 파악하는 부분
		this.ObjLiNum = this.ObjLi.length;

		// 배너 부분의 총 넓이를 파악하는 부분
		this.TotalWidth = this.DateWidth * this.ObjLiNum;

		this.ObjBox.style.width = this.TotalWidth + "px";

		if ( this.ObjLiNum % this.DateNum == 0 ) {
			this.BannerEnd = this.TotalWidth - ( this.DateWidth * this.DateNum );
		} else {
			this.BannerEnd = this.TotalWidth - this.DateWidth;
		}

		// 배너를 쌓고 있는 부분의 박스에 Css를 입히기
		this._Style();
		// Javascript 작동시 다음, 이전 버튼을 삽입하기
		this._ControlAdd();

		// 다음, 이전 버튼을 클릭시 이동해야 할 위치 계산하기
		this.BannerPrevLeft = this.BannerEnd;
		this.BannerNextLeft = this.DateWidth * this.DateNum ;

		this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
		this.PrevBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
			return false;
		}

		this.NextBtnLinkImg.Num = this.BannerNextLeft;
		this.NextBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
			return false;
		}
	}

	this._ControlAdd = function() {
		this.NewControl = document.createElement('div');
		this.NewControl.id = "BannerListCon";
		this.Obj.appendChild(this.NewControl);

		//this.PrevBtnLink = document.createElement('a');
		//this.PrevBtnLink.fnName = this.fnName;
		//this.PrevBtnLink.href = "#";
		//this.NewControl.appendChild(this.PrevBtnLink);

		this.PrevBtnLinkImg = document.createElement('img');
		this.PrevBtnLinkImg.fnName = this.fnName;
		this.PrevBtnLinkImg.className = "btn";
		this.PrevBtnLinkImg.src = "/images/main/banner_pre.gif";
		this.PrevBtnLinkImg.alt = "이전";
		this.NewControl.appendChild(this.PrevBtnLinkImg);


		//this.NextBtnLink = document.createElement('a');
		//this.NextBtnLink.fnName = this.fnName;
		//this.NextBtnLink.href = "#";
		//this.NewControl.appendChild(this.NextBtnLink);

		this.NextBtnLinkImg = document.createElement('img');
		this.NextBtnLinkImg.fnName = this.fnName;
		this.NextBtnLinkImg.className = "btn";
		this.NextBtnLinkImg.src = "/images/main/banner_next.gif";
		this.NextBtnLinkImg.alt = "다음";
		this.NewControl.appendChild(this.NextBtnLinkImg);

	}

	this._Style = function() {
		this.BoxStyle = this.ObjBox.parentNode;
		this.BoxStyle.className = "BannerListStyle";
		this.BoxUlStyle = this.ObjBox.getElementsByTagName("ul")[0];
		this.BoxUlStyle.className = "BannerUlStyle";
	}

	// 다음, 이전 버튼을 클릭시 배너를 이동 처리를 하는 부분
	this._moveFrame = function(val,fnmove) {
		clearTimeout(this.GoodsSetTime);

		if ( Math.abs(val - this.BannerCurrent) > 5 ) {
			this.BannerCurrent = this.BannerCurrent + ( val - this.BannerCurrent ) * this.Speed;
		} else {
			this.BannerCurrent = val;
		}

		this.ObjUl.style.left = ( -1 * this.BannerCurrent ) + "px";

		if ( this.BannerCurrent != val ) {
			this.GoodsSetTime = setTimeout(this.fnName + "._moveFrame(" + val + ",'" + fnmove + "')",10);
		} else {
			this.CurrentPicNum = this.BannerCurrent / this.DateWidth;

			this.BannerPrevLeft = this.BannerCurrent - ( this.DateWidth * this.DateNum );
			this.BannerNextLeft = this.BannerCurrent + ( this.DateWidth * this.DateNum );

			if ( this.BannerCurrent == 0 ) {
				this.BannerPrevLeft = this.BannerEnd;
			} else if ( this.BannerCurrent == this.TotalWidth - ( this.DateWidth * this.DateNum ) ) {
				this.BannerNextLeft = 0;
			}
			this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
			this.PrevBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
				return false;
			}

			this.NextBtnLinkImg.Num = this.BannerNextLeft;
			this.NextBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
				return false;
			}
		}
	}
}


/* INPUT 배경처리 */
function hideIdBG(f){
	f.style.backgroundImage = "none";
}
function showIdBG(f){
	if(f.value == ""){
		f.style.backgroundImage = "url(/images/main/bg_idBox.gif)";
	}
}
function hidePwBG(f){
	f.style.backgroundImage = "none";
}
function showPwBG(f){
	if(f.value == ""){
		f.style.backgroundImage = "url(/images/main/bg_pwBox.gif)";
	}
}


/* 검색박스 배경처리 */
function hideBG(f){
	if(f.value == ""){
		f.style.backgroundImage = "url(/images/common/search_bg.gif)";
	}
}
function showBG(f){
	if(f.value == ""){
		f.style.backgroundImage = "url(/images/common/search_box.gif)";
	}
}
/*
function hideBG(f){ if(f.value == ""){ f.className = f.className.replace(" "," none "); }}
function showBG(f){ if(f.value == ""){ f.className = f.className.replace(" none "," "); }}
*/

// 새창
function openWindow(theURL,theName,theTop,theLeft,theWidth,theHeight,theScroll) {
	window.open(theURL, theName,'top='+theTop+',left='+theLeft+',width='+theWidth+',height='+theHeight+',marginwidth=0,marginheight=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+theScroll+',resizable=no');
}

//maxlength 만큼 옮기면 다음으로 이동하기....
function nextFocus(sFormName,sNow,sNext) {
	var sForm = 'document.'+ sFormName +'.'
	var oNow = eval(sForm + sNow);

	if (typeof oNow == 'object') {
		if ( oNow.value.length == oNow.maxLength) {
			var oNext = eval(sForm + sNext);

			if ((typeof oNext) == 'object')
				oNext.focus();
		}
	}
}

// 공공 I-Pin 인증
function testAuth(t) {
	wWidth = 360;
	wHight = 120;

	wX = (window.screen.width - wWidth) / 2;
	wY = (window.screen.height - wHight) / 2;

	// Request Page Call
	t = encodeURIComponent(t)
	//var w = window.open("http://www.hermuseum.go.kr/gpin/GpinAuth.asp?url="+t, "gPinLoginWin", "directories=no,toolbar=no,left="+wX+",top="+wY+",width="+wWidth+",height="+wHight);
	var w = window.open("/gpin/Sample-AuthRequest.asp?url="+t, "gPinLoginWin", "directories=no,toolbar=no,left="+wX+",top="+wY+",width="+wWidth+",height="+wHight);
}

function setCookie(name, value, expiredays) {
	var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCookie( name ) {
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length ) {
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie ) {
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 ) break;
	}
	return "";
}

function notice_closeWin(as_SEQ) {
	if (document.getElementById("Notice"+as_SEQ).checked )
	setCookie("Notice"+as_SEQ, "done" , 1); // 1=하룻동안 공지창 열지 않음
	self.close();
}

function viewlistpho(as_num, as_fileName, as_subject) {
	document.getElementById("template").style.display = "";
	document.getElementById("fileName1").src = as_fileName;
	document.getElementById("fileName1").alt = as_subject;
	document.getElementById("subject").innerHTML = as_subject;
}

// 메일 선택
function mailChange(obj, value) {
	document.getElementById(obj).value = value;
}

// 컨텐츠 프린터
function jsPrintContent() {
	var width = 750;
	var height = 600;
	var x, y;
	var screen_width = screen.width;
	var screen_height = screen.height;
	x = (screen_width  / 2) - (width  / 2);
	y = (screen_height / 2) - (height / 2);
	var pop = window.open ("/include/printView.asp","print","width=" + width + ", height=" + height + ", left=" + x + ", top=" + y + ", toolbar=no, status=no, menubar=no, scrollbars=yes, resizable=yes");

	pop.focus();
	pop.print();
	return false;

}

function viewFlash(fName, width, height){
	document.write('<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width='+width+' height='+height+'>');
	document.write('<param name=movie value='+fName+'>');
	document.write('<param name=quality value=high>');
	document.write('<embed src='+fName+' quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width='+width+' height='+height+'></embed>');
	document.write('</object>');
}

function viewMedia(fName, width, height) {
	document.write('<object id=mediaplayer1 codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 classid=CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95 width='+width+' height='+height+' type=application/x-oleobject standby=Loading Microsoft?Windows?Media Player components...>');
	document.write('<param name=Filename value='+fName+'>');
	document.write('<param name=loop value=1>');
	document.write('<param name=mute value=0>');
	document.write('<param name=AutoStart value=1>');
	document.write('<param name=AutoSize value=0>');
	document.write('<param name=AutoResize value=0>');
	document.write('<param name=AnimationAtStart value=1>');
	document.write('<param name=TransparentAtStart value=1>');
	document.write('<param name=AutoRewind value=1>');
	document.write('<param name=ShowDisplay value=0>');
	document.write('<param name=ClickToPlay value=1>');
	document.write('<param name=EnableContextMenu value=1>');
	document.write('<param name=ShowPositionControls value=1>');
	document.write('<param name=ShowStatusBar value=0>');
	document.write('<param name=ShowControls value=1>');
	document.write('<param name=EnableTracker value=1>');
	document.write('<param name=Volume value=1>');
	document.write('<param name=wmode value=transparent>');
	document.write('</object>');
}



//영문 q & n 스크립트
function qna(num)
{
	for (var i=1;i<=15;i++ )
	{
		document.getElementById("qna"+i).style.display="none";
	}
	document.getElementById("qna"+num).style.display="";
}

// rolling("div태그 id", "연결할 태그", 배너1개높이, 딜레이, 1칸이동속도, 0, 첫시작시 delay시간후 롤링 변수);
// rolling("roll", "div", 300, 3000, 10, 0, 1);
over = 1;
start = true;
function rolling(did, tname, height, delay, speed, theight)
{
	var div_tag = document.getElementById(did);
	var tag;
	var height_ = height;
	if(over > 0) theight++;

	if(theight < height_)
	{
		if(!start)
		{
			div_tag.style.top = -theight;
			setTimeout("rolling('" + did + "', '" + tname + "', " + height + ", " + delay + ", " + speed + "," + theight+" );", speed);
		}
		else
		{
			start = false;
			setTimeout("rolling('" + did + "', '" + tname + "', " + height + ", " + delay + ", " + speed + "," + theight +" );", delay);
		}
	}
	else
	{
		tag = div_tag.getElementsByTagName(tname);
		if(tag.length > 0)div_tag.appendChild(tag[0]);
		div_tag.style.top = 0;
		setTimeout("rolling('" + did + "', '" + tname + "', " + height + ", " + delay + ", " + speed + ",0);", delay);
	}
	return true;
}
