//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";
	}
}

// first 예외처리 listFirst(블럭Id, 태그네임, 처리할 아이템 갯수) // 아이템번호는 0번부터 반환
function listFirst(Elid, Etn, Num){
	liEl = dEI(Elid).getElementsByTagName(Etn);
	for(i=0; liEl.length>i; i=i+Num){
		liEl.item(i) .className += " first";
	}
}

// Tab Content
function tabCheck(dotabid, num){
		var inum=parseInt(num)-1;
		var linkTab=dEI(dotabid).getElementsByTagName("a");
		for (i=0;i<linkTab.length;i++) {
			var tabimg = linkTab.item(i).getElementsByTagName("img").item(0);
			var  tabContents= dEI(dotabid+(1+i));
			if (i==inum) {
				if(tabContents.style.display!="block"){
					tabimg.src=tabimg.src.replace(".gif", "on.gif");
					tabContents.style.display="block";
				}
		}else{
			tabimg.src=tabimg.src.replace("on.gif", ".gif");
			tabContents.style.display="none";
		}
	}
}

//팝업띄우기
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 '';
}


//레이어 팝엽
function openLayer(IdName, tpos, lpos){
	//alert(IdName);
	var pop = dEI(IdName);
	pop.style.display = "block";
	pop.style.top = tpos + "px";
	pop.style.left = lpos + "px";
}

//레이어 팝엽 닫기
function closeLayer(IdName){
	var pop = dEI(IdName);
	pop.style.display = "none";
}

function doClose(IdName){
	var closeMovie = parent.dEI(IdName);
	closeMovie.style.display = "none";
}

//secondNav height control
function changeDiv(eleId, mH){
	//alert(mH);
	document.getElementById(eleId).style.height=mH+"px";
}

//FAQ
function initToggle(tabContainer,type) {
	triggers = tabContainer.getElementsByTagName("a");

	if(type==""||type==null){
		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).onclick = function () {
				if (tabContainer.current == this) {
					this.targetEl.style.display = "none";
					this.parentNode.className="";
					tabContainer.current = null;
				} else {
					if (tabContainer.current) {
						tabContainer.current.targetEl.style.display = "none";
						tabContainer.current.parentNode.className="";
					}
					this.targetEl.style.display = "block";
					this.parentNode.className="on";
					tabContainer.current = this;
				}
				return false;
			}
		}
	}else if(type=="poll"){
		for(i = 0; i < triggers.length; i++) {
			var result = dEI("result"+i);
			//alert(result);
			if(triggers.item(i).getAttribute("rel")){
				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).onclick = function () {
					if (triggers.current == this) {
						this.targetEl.style.display = "none";
						this.parentNode.parentNode.className="";
						tabContainer.current = null;
					} else {
						if (tabContainer.current) {
							tabContainer.current.targetEl.style.display = "none";
							tabContainer.current.parentNode.parentNode.className="";
						}
						this.targetEl.style.display = "block";
						this.parentNode.parentNode.className="on";
						tabContainer.current = this;
					}
					//alert(this.parentNode.parentNode.className+"||"+this.parentNode.parentNode);
					return false;
				}
			}
		}
	}

}

//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.right = obj.initRight;

	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)
}

//new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);

function Floating(FloatingObj,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollTop) > (document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}

	var This = this;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocTop = this.Body.scrollTop + this.MarginY;

	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);

	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}

	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}


//show Image
function showImg(murl,idNum){
	var momEl=dEI("imgGallery"+idNum);
	if (dEI("showImg"+idNum)) {
		var showImg = dEI("showImg"+idNum);
	} else {
		var showImg = document.createElement("div");
		showImg.setAttribute("id", "showImg"+idNum);
		momEl.appendChild(showImg)
	}
	dEI("showImg"+idNum).className="showImg";
	var inFrame="<img src='"+murl+"' alt='' />";
	inFrame=inFrame+"<p id=\"closeBtn"+idNum+"\" class=\"closeBtn\"><a href=\"#\" onclick=\"hiddenImg('"+idNum+"');return false;\"><img src=\"/images/common/btn/btn_imgClose.gif\" alt=\"close\" /></a></p>";

	showImg.innerHTML=inFrame;
	imgRollover("closeBtn"+idNum);
}
function hiddenImg(idNum){
	//alert(idNum);
	var clearEl=dEI("showImg"+idNum);
	var momEl = dEI("imgGallery"+idNum);
	momEl.removeChild(clearEl);
	var tit = document.documentElement.getElementsByTagName("h4");
	for(i = 0; i < tit.length; i++){
		tit.item(i).style.zIndex=0;
	}
	//alert(momEl+"||"+clearEl);
}

//show media
function showMedia(murl,idNum){
	var momEl=dEI("imgGallery"+idNum);
	var showMedia = document.createElement("div");
	//alert(dEI("showMedia"+idNum));
	if(dEI("showMedia"+idNum) == null){
		showMedia.setAttribute("id", "showMedia"+idNum);
		momEl.appendChild(showMedia)
		dEI("showMedia"+idNum).className="showMedia";
		//alert(murl);
		var inFrame="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='400' height='300' title='media player'>";
		inFrame=inFrame+"<param name='movie' value='/swf/MediaPlayer.swf?flvURL="+murl+"' />";
		inFrame=inFrame+"<param name='quality' value='high' />";
		inFrame=inFrame+"<param name='wmode' value='transparent' />";
		inFrame=inFrame+"<param name='allowfullscreen' value='true' />";
		inFrame=inFrame+"<embed src='/swf/MediaPlayer.swf?flvURL="+murl+"' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='400' height='300' wmode='transparent' allowfullscreen='true'></embed>";
		inFrame=inFrame+"</object>";
		inFrame=inFrame+"<p id=\"closeMedia"+idNum+"\" class=\"closeBtn\"><a href=\"#\" onclick=\"hiddenMedia('"+idNum+"');return false;\"><img src=\"/images/common/btn/btn_imgClose.gif\" alt=\"close\" /></a></p>";
		showMedia.innerHTML=inFrame;
		imgRollover("closeMedia"+idNum);
	}else{
		return;
	}
}
function hiddenMedia(idNum){
	//alert(idNum);
	var clearEl=dEI("showMedia"+idNum);
	var momEl = dEI("imgGallery"+idNum);
	momEl.removeChild(clearEl);
	//alert(momEl+"||"+clearEl);
}

//main media
function mainMedia(murl){
	var momEl=dEI("mainContainer");
	var showMedia = document.createElement("div");
	showMedia.setAttribute("id", "mainMedia");
	momEl.appendChild(showMedia)
	var inFrame="<div id=\"deemed\"></div><iframe src='/common/inc/main_media.asp?flvURL="+murl+"' frameborder='0' scrolling='no' width='500px' height='375px' id='mainFrame' ' title='media player'></iframe>";
	showMedia.innerHTML=inFrame;
}
function hiddenmain(){
	var clearEl=parent.dEI("mainMedia");
	var momEl = parent.dEI("mainContainer");
	momEl.removeChild(clearEl);
}

//album View
function showAlbum(murl){
	var momEl=dEI("albumBox");
	var showAlbum = document.createElement("div");
	showAlbum.setAttribute("id", "showAlbum");
	momEl.appendChild(showAlbum)
	var inFrame="<div class='deemed'></div><a href='#' onclick='hiddenAlbum();return false;'><img src='"+murl+"' alt='' /></a>";
	showAlbum.innerHTML=inFrame;
}
function hiddenAlbum(){
	var clearEl=dEI("showAlbum");
	var momEl = dEI("albumBox");
	momEl.removeChild(clearEl);
	//alert(momEl+"||"+clearEl);
}



//아이프레임 동적으로 삭제
function closeMenupan(){
	var clearEl=parent.dEI("menuFrame");
	var momEl=parent.dEI("menuBox");
	//alert(clearEl+"||"+momEl);
	momEl.style.zIndex=-1;
	momEl.removeChild(clearEl);
}

//예약
function reservation(rMenu, rLocation, rDate, isModify, rCode, rUserCode){
	var wrap = dEI("wrapper");
	var reservation = document.createElement("div");
	reservation.setAttribute("id", "reserWrap");
	wrap.appendChild(reservation);
	var	inFrame="<div id=\"deemed\"></div><iframe src='/common/include/reservation.asp?";
			inFrame=inFrame+"rMenu="+rMenu+"&amp;rLocation="+rLocation+"&amp;rDate="+rDate +"&amp;isModify="+isModify+"&amp;rCode="+rCode+"&amp;rUserCode="+rUserCode+"'";
			inFrame=inFrame+" frameborder='0' scrolling='no' width='847px' height='514px' id='reserFram' ' title='빠른예약'></iframe>";
	reservation.innerHTML=inFrame;
}
function reservationModify(fUrl){
	var wrap = dEI("wrapper");
	var reservation = document.createElement("div");
	reservation.setAttribute("id", "reserWrap");
	wrap.appendChild(reservation);
	var	inFrame="<div id=\"deemed\"></div><iframe src='/common/include/reservation_modify.asp' frameborder='0' scrolling='no' width='847px' height='514px' id='reserFram' ' title='예약 수정'></iframe>";
	reservation.innerHTML=inFrame;
}
function closeReservation(){
	var clearEl=parent.dEI("reserWrap");
	var momEl = parent.dEI("wrapper");
	momEl.removeChild(clearEl);
	//alert(momEl+"||"+clearEl);
}

// mediaList Rollover
function listRollover(imgBoxID){
	var listCounts = dEI(imgBoxID).getElementsByTagName("li");
	for (k=0;k<listCounts.length;k++) {
		var numList=listCounts.item(k);
		var listCheck = numList.className;
		var chImg = numList.getElementsByTagName("img").item(0);
		//alert(listCheck);
		if (listCheck != "on") {
			numList.onmouseover = function () {
				this.className="on";
			//	this.getElementsByTagName("img").item(0).src = this.getElementsByTagName("img").item(0).src.replace(".gif", "on.gif");
				//alert(chImg);
			}
			numList.onmouseout = function () {
				this.className="";
			//	this.getElementsByTagName("img").item(0).src = this.getElementsByTagName("img").item(0).src.replace("on.gif", ".gif");
			}
		}
	}
}

//poll
function pollToggle(num){
	var obj = dEI("poll"+num);
	var targetObj = dEI("result"+num);
	if(targetObj.style.display==""||targetObj.style.display=="none"){
		targetObj.style.display="block";
		obj.style.display="none";
	}else{
		obj.style.display="block";
		targetObj.style.display="none";
	}
}


//Element toggle
function eleToggle2(eleId){
	var targetObj = dEI(eleId);

	if(targetObj.style.display==""||targetObj.style.display=="none"){
		targetObj.style.display="block";
	}else{
		targetObj.style.display="none";
	}
}

////Element toggle
//function eleToggle(eleId, eleId2){
//
//	for (i=1;i<5;i++) {
//		if (dEI("commentBox" + i)) {
//		dEI("commentBox" + i).style.display="block";
//		dEI("modifyArea" + i).style.display="none";
//		dEI("quoteArea" + i).style.display="none";
//		dEI("replyArea" + i).style.display="none";
//		}
//	}
//
//	var targetObj = dEI(eleId);
//	var targetObj2 = dEI(eleId2);
//
//	targetObj2.style.display="none";
//	targetObj.style.display="block";
//
//}

//Element toggle
function eleToggle(eleId, eleId2){
	for ( i=1 ; i < 6 ; i++ ) {
		if (dEI("commentBox" + i)) {
		dEI("commentBox" + i).style.display="block";
		dEI("modifyArea" + i).style.display="none";
		dEI("quoteArea" + i).style.display="none";
		dEI("replyArea" + i).style.display="none";
		}
	}
	var targetObj = dEI(eleId);
	var targetObj2 = dEI(eleId2);
	targetObj2.style.display="none";
	targetObj.style.display="block";

}

//change award
function chAward(url){
	//alert(url);
	location.href=url;
}



