//Element ID ºÒ·¯¾²±â
function dEI(elementID){
	return document.getElementById(elementID);
}

// roundBox Layout
function initLayout(layoutEl,childEl) {
	var layoutId = dEI(layoutEl);
	var contentsId = dEI(childEl);
		
	//create and build div structure
	var bodyTH = document.createElement('div');
	var bodyLV = document.createElement('div');
	var bodyRV = document.createElement('div');
	var bodyBH = document.createElement('div');
	var bodyTL = document.createElement('div');
	var bodyTR = document.createElement('div');
	var bodyBL = document.createElement('div');
	var bodyBR = document.createElement('div');
	bodyTH.className = "bodyTH";
	bodyLV.className = "bodyLV";
	bodyRV.className = "bodyRV";
	bodyBH.className = "bodyBH";
	bodyTL.className = "bodyTL";
	bodyTR.className = "bodyTR";
	bodyBL.className = "bodyBL";
	bodyBR.className = "bodyBR";
	layoutId.appendChild(bodyTH);
	bodyTH.appendChild(bodyLV);
	bodyLV.appendChild(bodyRV);
	bodyRV.appendChild(bodyBH);
	bodyBH.appendChild(bodyTL);
	bodyTL.appendChild(bodyTR);
	bodyTR.appendChild(bodyBL);
	bodyBL.appendChild(bodyBR);
	bodyBR.appendChild(contentsId);
}


//Images Btn_KSS
function BtnOn(imgEl){
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function BtnOut(imgEl){
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

// first ¿¹¿ÜÃ³¸® firstChild(ºí·°Id, ÅÂ±×³×ÀÓ, Ã³¸®ÇÒ ¾ÆÀÌÅÛ ¹øÈ£) // ¾ÆÀÌÅÛ¹øÈ£´Â 0¹øºÎÅÍ ¹ÝÈ¯
function firstChild(Elid, Etn, Num){
	if(Num==""){Num=0;}
	liEl = dEI(Elid).getElementsByTagName(Etn);
	if (liEl.item(Num)) {
		liEl.item(Num).className += " first-child";
	}
}

//ÆË¾÷¶ç¿ì±â
function openPop(url,idn,intWidth,intHeight,scroll) { 
	//alert("pop_scroll");
	window.open(url, idn,"width="+intWidth+", height="+intHeight+",resizable=0,scrollbars="+scroll) ;
}

// ÀÌ¹ÌÁö ·Ñ¿À¹ö
function imgRollover(imgBoxID){
	var MenuCounts = dEI(imgBoxID).getElementsByTagName("img");
	for (i=0;i<MenuCounts.length;i++) {
		var numImg=MenuCounts.item(i);
		var ImgCheck = numImg.src.substring(numImg.src.length-6,numImg.src.length);
		if (ImgCheck!="on.gif") {
				numImg.onmouseover = function () {
					this.src = this.src.replace(".gif", "on.gif");
				}
				numImg.onmouseout = function () {
					this.src = this.src.replace("on.gif", ".gif");
				}
			}
	}
}

//IE6 pngÆÐÄ¡
function setPng24(obj) {
  obj.width=obj.height=1;
  obj.className=obj.className.replace(/\bpng24\b/i,'');
  obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
  obj.src='';
  return '';
}

//scrollbanner
function movingBanner(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = document.getElementById(target);
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}

//·¹ÀÌ¾î ÆË¿±
function openLayer(IdName){
	//alert(IdName);
	var pop = dEI(IdName);
	pop.style.display = "block";
}

//·¹ÀÌ¾î ÆË¿± ´Ý±â
function closeLayer(IdName){
	var pop = dEI(IdName);
	pop.style.display = "none";
}

//Top Button
function goTop(orix,oriy,desx,desy) {
	var Timer;
	var winHeight = document.documentElement.scrollTop;
	if(Timer) clearTimeout(Timer);
	startx = 0;
	starty = winHeight;
	if(!orix || orix < 0) orix = 0;
	if(!oriy || oriy < 0) oriy = 0;
	var speed = 5;
	if(!desx) desx = 0 + startx;
	if(!desy) desy = 0 + starty;
	desx += (orix - startx) / speed;
	if (desx < 0) desx = 0;
	desy += (oriy - starty) / speed;
	if (desy < 0) desy = 0;
	var posX = Math.ceil(desx);
	var posY = Math.ceil(desy);
	window.scrollTo(posX, posY);
	if((Math.floor(Math.abs(startx - orix)) < 1) && (Math.floor(Math.abs(starty - oriy)) < 1)){
		clearTimeout(Timer);
		window.scroll(orix,oriy);
	}else if(posX != orix || posY != oriy){
		Timer = setTimeout("goTop("+orix+","+oriy+","+desx+","+desy+")",15);
	}else{
		clearTimeout(Timer);
	}
}


//µ¿¿µ»ó ÇÃ·¡½Ã ¹× Å¸ÀÌÆ² Á¦¾î
function moviePlay(playURL){
	var ch=dEI("Murl").value;
	dEI("playImg").style.display='none';
	//µ¿¿µ»óÆË¾÷ÀÌ open»óÅÂÀÎÁö È®ÀÎ.
	if(dEI("Mplayer").style.display=="block"){
		mvPlayer.obj().setURL(playURL);
	}else{
		dEI("Murl").value=playURL;
		dEI("Mplayer").style.display="block";
		if(ch!="null"&&window.navigator.appName != "Netscape"){
			mvPlayer.obj().setURL(playURL);
		}
	}
	return;
}


// ¹«ºñ ÇÃ·¹ÀÌ
function playMovie(){
	return dEI("Murl").value;
}

//¹«ºñ stop
function stopMovie(){
	mvPlayer.obj().stopMovie();
}

//ÁÖ¼Òº¹»ç
function CopyToClipboard(ID) {
	obj = null;
	if(document.getElementById)
	obj=document.getElementById(ID);
	if (obj) { window.clipboardData.setData('Text', obj.innerText); }
	alert('Å¬¸³º¸µå¿¡ ÁÖ¼Ò°¡ º¹»çµÇ¾ú½À´Ï´Ù.\n\n¿øÇÏ´Â ºÎºÐ¿¡ CTRL + V·Î ºÙÇô³Ö±â ÇÏ¼¼¿ä.');
}

//FAQ
function initToggle(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;

		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).className="";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				this.className="";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
					tabContainer.current.className="";
				}
				this.targetEl.style.display = "block";
				this.className="on";
				tabContainer.current = this;
			}
			return false;
		}
	}
}

//Top¹öÆ° ¼û±â±â
function hiddenTop(){
	if(!dEI("wrapper")) return; 

	var Cheight = dEI("wrapper").clientHeight;
	var Top = dEI("quickarea");
	//alert(Cheight);

	if(Cheight<1000){
		Top.style.display="none";
	}
}

window.onload = hiddenTop;


/* µå¶ó¸¶ */
function dramaLink(ds1, ds2){
	location.href="/inside/inside_drama.asp?ds1="+ds1+"&amp;ds2="+ds2;
}


/* ·¯ºê¾×Ãò¾ó¸®¸¶ÀÌÅ©·Î»çÀÌÆ® */
function fun_micropop(){
		window.open('/love/', '090214','width=950, height=650, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, left=5, top=5');
}
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();
}
