// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

// Tab Content World map
function WorldPartner(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("area");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

//
function aa(URL, ALT, num) {
	var imgSrc = document.getElementById('goods_view');
	imgSrc.src = URL;
	imgSrc.alt = ALT;
	var parentLi = document.getElementById('goods_tab_menu').getElementsByTagName('li');
	for (i=0; i<parentLi.length; i++) {
		if (num == i) {
			parentLi[i].getElementsByTagName('a')[0].parentNode.className = 'current';
		} else {
			parentLi[i].getElementsByTagName('a')[0].parentNode.className = '';
		}
	}

}

// Layer Show-Hide
function showLayer(tgtEl) { document.getElementById(tgtEl).style.display = "block"; }
function hideLayer(tgtEl) { document.getElementById(tgtEl).style.display = "none"; }

function showSelectLayer(tgtEl) {
	document.getElementById(tgtEl).style.display = "block";
	if ( navigator.userAgent.indexOf("MSIE") !=-1 && document.getElementById('container') )
	document.getElementById('container').style.zIndex = "-1";

}

function hideSelectLayer(tgtEl) {
	document.getElementById(tgtEl).style.display = "none";
	if (navigator.userAgent.indexOf("MSIE")!=-1&&document.getElementById('container'))
	document.getElementById('container').style.zIndex = "0";
}

//
function showSelectLang(tgtEl) {
	document.getElementById(tgtEl).style.display = "block";
	if ( navigator.userAgent.indexOf("MSIE") !=-1 && document.getElementById('container') )
	document.getElementById('container').style.zIndex = "-1";
	var lanHead = document.getElementById('top_language').getElementsByTagName('h3')[0];
	var lanLink = lanHead.getElementsByTagName('a')[0];
	lanLink.style.color = "#C70752";
	lanLink.style.backgroundColor = "#f1f1f1";
	lanLink.style.backgroundImage = "url('/images/global/common/lan_bg_on.gif')"

}

function hideSelectLang(tgtEl) {
	document.getElementById(tgtEl).style.display = "none";
	if (navigator.userAgent.indexOf("MSIE")!=-1&&document.getElementById('container'))
	document.getElementById('container').style.zIndex = "0";
	var lanHead = document.getElementById('top_language').getElementsByTagName('h3')[0];
	var lanLink = lanHead.getElementsByTagName('a')[0];
	lanLink.style.color = "#fff";
	lanLink.style.backgroundColor = "transparent";
	lanLink.style.backgroundImage = "url('/images/global/common/lan_bg.gif')"
}


// menu Show-Hide
function TopMenuMove(num){

	showhideTopMenu(num,6);
}

function showhideTopMenu(num,tol) {

	for (i=1; i<=tol; i++) {
		//var menu = eval("document.getElementById('subm_0" + i +"').style");
		sub_nm = "subm_0" + i;

		if (document.getElementById(sub_nm)){
			var menu = document.getElementById(sub_nm);

			if (num == i ) {
				menu.style.display = "block";
			} else {
				menu.style.display = "none";
			}
		}
	}
}

// swfprint
function swfprint(furl,fwidth,fheight,transoption)    {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
		document.write('<param name="movie" value="'+ furl +'"/>');
		if (transoption == "t")    {
				document.write('<param name="wmode" value="transparent"/>');
		} else if    (transoption == "o")    {
				document.write('<param name="wmode" value="opaque"/>');
		}
		document.write('<!-- Hixie method -->');
		document.write('<!--[if !IE]> <-->');
		document.write('<object type="application/x-shockwave-flash" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
		if (transoption == "t")    {
				document.write(' wmode="transparent"');
		} else if    (transoption == "o")    {
				document.write(' wmode="opaque"');
		}
		document.write('></object>');
		document.write('<!--> <![endif]-->');
		document.write('</object>');
}


//faq Drop-Down
function faq_menu(sw) {
	var faq_dl = document.getElementById('dropdown');
	var cnt = 0;
	var cnt2 = 0;
	for (i=0; i<faq_dl.childNodes.length; i++) {
		if (faq_dl.childNodes[i].tagName == 'DD') {
			cnt++;
			if (sw == cnt) {
				faq_dl.childNodes[i].className='down';
			} else {
				faq_dl.childNodes[i].className='';
			}
		}
		else if (faq_dl.childNodes[i].tagName == 'DT') {
			cnt2++;
			if (sw == cnt2) {
				faq_dl.childNodes[i].className='on';
			} else {
				faq_dl.childNodes[i].className='';
			}
		}
	}
}

//faq Drop-Down - Global
function faq_menu_global(sw) {
	var faq_dl = document.getElementById('dropfaq');
	var cnt = 0;
	var cnt2 = 0;
	for (i=0; i<faq_dl.childNodes.length; i++) {
		if (faq_dl.childNodes[i].tagName == 'DD') {
			cnt++;
			if (sw == cnt) {
				if (cnt % 2 == 0)
				{
					faq_dl.childNodes[i].className='down';
				} else {
					faq_dl.childNodes[i].className='down2';
				}
			} else {
				faq_dl.childNodes[i].className='';
			}
		}
		else if (faq_dl.childNodes[i].tagName == 'DT') {
			cnt2++;
			if (sw == cnt2) {
				if (cnt % 2 == 0)
				{
					faq_dl.childNodes[i].className='on';
				} else {
					faq_dl.childNodes[i].className='on2';
				}
			} else {
				if (cnt % 2 == 0)
				{
					faq_dl.childNodes[i].className='row_bg';
				} else {
					faq_dl.childNodes[i].className='';
				}
			}
		}
	}
}



// calendar pop up menu
// 사용자 설정 부분
Layer_popup_close=2;  //메뉴 닫는 방법 1(클릭으로 닫음 )또는 2(마우스 아웃으로 닫음 )

var satuas; //마우스가 팝업창 위에 놓여 있는지를 알기 위한 전역변수 선언
function popup_Layer(event,popup_name) {    //팝업레이어 생성
	var main,_tmpx,_tmpy,_marginx,_marginy;
	var sTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	var sLeft = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;
	main = document.getElementById(popup_name);
	if(Layer_popup_close==2){
		satuas=1;//클릭으로 인한 닫힘 방지를 위해
	}
	main.style.display = '';//팝업 생성
	_tmpx = event.clientX+parseInt(main.offsetWidth);
	_tmpy = event.clientY+parseInt(main.offsetHeight);
	_marginx = document.body.clientWidth - _tmpx;
	_marginy = document.body.clientHeight - _tmpy;

	// 좌우 위치 지정
	if(_marginx < 0){//우측;
		main.style.left = event.clientX + sLeft + _marginx-2 + "px";
	}
	else{
		main.style.left = event.clientX + sLeft-5 + "px";
	}
	//높이 지정
	if(_marginy < 0){//아래부분;
		main.style.top = event.clientY + sTop + _marginy-5 + "px";
	}
	else{
		main.style.top = event.clientY + sTop-5 + "px";
	}
}

function mouse_anchor(type) { //마우스의 위치에 따른 팝업의 닫음을 결정
	if(type=="1"){
		satuas="1";
	}
	if(type=="0"){
		satuas="0";
	}
}

function Layer_popup_Off() { //팝업 닫음
	if(satuas=="0"){
		document.getElementById("popup_table").style.display = "none";
	}
	if(Layer_popup_close==2) {
		satuas=null;
	}
}

function mouseout_close() {
	window.setTimeout('Layer_popup_Off()',850);
}

if(Layer_popup_close==1){
	document.onmousedown = Layer_popup_Off;//클릭으로 닫기
}

if(Layer_popup_close==2){
	document.onmouseover = mouseout_close;//레이어 벋어나면 닫기
}




//
// Community Photo thumbnail

function ThumbnailScroll() {
	this.GoodsSetTime = null;
	this.Speed = 2;
}

ThumbnailScroll.prototype.GoodsSetting = function() {
	this.DivName = "Thumbnail_wrap";
	this.ScrollName = "ThumbnailScroll_1";
	this.MovieWidth = 110;

	this.LiBox_Left = new Array();

	this.ThumbnailUl = document.getElementById(this.DivName).getElementsByTagName("ul")[0];
	this.ThumbnailBox = this.ThumbnailUl.getElementsByTagName("li");
	this.ThumbnailNum = this.ThumbnailBox.length;

	if ( this.ThumbnailNum < 4 ) {
		this.Default_left = 0;
	} else {
		this.Default_left = -this.ThumbnailNum*this.MovieWidth;
	}

	if ( this.ThumbnailNum > 3 ) {
		for ( var i=0; i<this.ThumbnailNum*2; i++ ) {
			this.objNewli = this.ThumbnailBox.item(i).cloneNode(true);
			this.ThumbnailUl.appendChild(this.objNewli)
		}
		this.ThumbnailNum = this.ThumbnailBox.length;
		document.getElementById("Thumbnail_Prev").href = "javascript:" + this.ScrollName + "._prevBtn();";
		document.getElementById("Thumbnail_Next").href = "javascript:" + this.ScrollName + "._nextBtn();";
	}

	for ( var i=0; i < this.ThumbnailNum; i++ ) {
		this.LiBox_Left[i] = this.Default_left + ( i * this.MovieWidth );
		this.ThumbnailBox.item(i).style.left = this.LiBox_Left[i] + "px";
	}

	this.Last_Left = this.LiBox_Left[this.ThumbnailNum-1];
}

ThumbnailScroll.prototype._nextFrame = function() {
	for ( var i=0; i<this.ThumbnailNum; i++ ) {
		this.LiBox_Left[i] = this.LiBox_Left[i] - this.MovieWidth;
		if ( this.LiBox_Left[i] == ( this.Default_left - this.MovieWidth ) ) {
			this.LiBox_Left[i] = this.Last_Left;
		}
		this.ThumbnailBox[i].style.left = this.LiBox_Left[i] + "px"
	}
}
ThumbnailScroll.prototype._prevFrame = function() {
	for ( var i=0; i<this.ThumbnailNum; i++ ) {
		this.LiBox_Left[i] = this.LiBox_Left[i] + this.MovieWidth;
		if ( this.LiBox_Left[i] == this.Last_Left + this.MovieWidth ) {
			this.LiBox_Left[i] = this.Default_left;
		}
		this.ThumbnailBox[i].style.left = this.LiBox_Left[i] + "px"
	}
}

ThumbnailScroll.prototype._nextBtn = function() {
	this.GoodsSetTime = setTimeout(this.ScrollName + "._nextFrame()",0);
}
ThumbnailScroll.prototype._prevBtn = function() {
	this.GoodsSetTime = setTimeout(this.ScrollName + "._prevFrame()",0);
}


// pagenum block center
function pagecenter() {
	var obj = document.getElementById("pagenum");
	var objwidth = obj.offsetWidth;

	var objul = obj.getElementsByTagName("ul")[0];
	var objli = objul.getElementsByTagName("li");
	var objtotal = 0;
	for ( var i=0; i<objli.length; i++ ) {
	 var objliwidth = objli.item(i).offsetWidth;
	 objtotal += objliwidth;
	}
	objul.style.width = objtotal + "px";
 }



 // IE6 selectbox over layer
	function IESelctFix () {
	var gnb = document.getElementById("dvgnb");

	for (i=0; i<gnb.getElementsByTagName ("IFRAME").length; i++) {
		var AllFrame = gnb.getElementsByTagName ("IFRAME").item(i);
		var AllUl = AllFrame.nextSibling;
		AllFrame.style.height = AllUl.offsetHeight;
	}
	setTimeout("IESelctFix()",100);
}

var originalSrc = null;

function gnbMenu() {
	var gnb = document.getElementById("dvgnb");
	var gnbmenu = gnb.getElementsByTagName('ul').item(0);
	for (i=0; i<gnbmenu.getElementsByTagName('img').length; i++) {
		gnbmenu.getElementsByTagName('img').item(i).onmouseover = function() {
			originalSrc = this.src;
			var gnbuse = (originalSrc.indexOf("use") > 0)?"_use":"" ;
			this.src = this.src.replace(gnbuse+".gif", "_on.gif");
		}
		gnbmenu.getElementsByTagName('img').item(i).onmouseout = function() {
			this.src = originalSrc; //this.src.replace("_on.gif", ".gif");
		}
	}
}

// Print Page
function PagePrint ()  {
	window.print();
}

//Background flicers on hoever IE
try
{
	document.execCommand('BackgroundImageCache',false,true);
}
catch (e) {}