/************************************************************************************************/
/* Define Login State                                                                           */
/* loginCheck-0 : logout / loginCheck-1 : login                                                 */
/************************************************************************************************/
var loginCheck = 0;


/************************************************************************************************/
/* Go Sejong Link Function                                                                      */
/************************************************************************************************/
function goSejongLink(tidx, tlnk, topt) {
	var arrTemp;
	var vParent;
	switch (tidx) {
		case 0 :
			vParent = this.parent
			if (vParent == null )
			{
				document.location.href = tlnk;
//				window.top.document.location.href = tlnk;
			} else {
				vParent.location.href = tlnk;
			}
			break;
		case 1 :
			document.location.href = tlnk;
			break;
		case 2 :
			arrTemp = topt.split(",");

			popWin(tlnk,'',arrTemp[0],arrTemp[1],arrTemp[2],arrTemp[3],arrTemp[4])
//			var popWin = window.open(tlnk,'',topt);
//			popWin.focus();
			break;
		case 3 :
			window.open(tlnk);
			break;
	}
}


/************************************************************************************************/
/* Go Common Link Function                                                                      */
/************************************************************************************************/
function goCommonMenu(idx) {
	var tempIdx, tempLink, tempOption;
//	alert(idx);
//	return;
	tempIdx = commMenu[idx].tDir;
	tempLink = commMenu[idx].lnk;
	if (tempIdx == 2) tempOption = commMenu[idx].opt;
	goSejongLink(tempIdx, tempLink, tempOption);
}


/************************************************************************************************/
/* Go Top Link Function                                                                         */
/************************************************************************************************/
function goTopMenu(idx, idy) {
	var tempIdx, tempLink, tempOption;
//	alert(idx+":"+idy);
//	return;
	if (idy != null) {
		tempIdx = topMenu[idx].child[idy].tDir;
		tempLink = topMenu[idx].child[idy].lnk;
		if (tempIdx == 2) tempOption = topMenu[idx].child[idy].opt;
	} else {
		tempIdx = topMenu[idx].tDir;
		tempLink = topMenu[idx].lnk;
		if (tempIdx == 2) tempOption = topMenu[idx].opt;
	}
	goSejongLink(tempIdx, tempLink, tempOption);
}



/************************************************************************************************/
/* Go Left Link Function                                                                        */
/************************************************************************************************/
function goLeftMenu(idx, idy) {
	var tempIdx, tempLink, tempOption;
	if (idy != null && idy != undefined) {
		tempIdx = leftMenu[idx].child[idy].tDir;
		tempLink = leftMenu[idx].child[idy].lnk;
		if (tempIdx == 2) tempOption = leftMenu[idx].child[idy].opt;
	} else {
		tempIdx = leftMenu[idx].tDir;
		tempLink = leftMenu[idx].lnk;
		if (tempIdx == 2) tempOption = leftMenu[idx].opt;
	}
	goSejongLink(tempIdx, tempLink, tempOption);
}


/************************************************************************************************/
/* Go Quick Link Function                                                                        */
/************************************************************************************************/
function goQuickMenu(idx) {
	var tempIdx, tempLink, tempOption;
	tempIdx = quickMenu[idx].tDir;
	tempLink = quickMenu[idx].lnk;
	if (tempIdx == 2) tempOption = quickMenu[idx].opt;

	goSejongLink(tempIdx, tempLink, tempOption);
}


/************************************************************************************************/
/* Set Cookie Function                                                                          */
/************************************************************************************************/
function setCookie(cookieName, cookieValue, cookiePath, cookieExpires){
	cookieValue = escape(cookieValue);
	if(cookieExpires == ""){
		var nowDate = new Date();
		nowDate.setDate(nowDate.getDate()+1);
		cookieExpires = nowDate.toGMTString();
	}
	if(cookiePath != ""){
		cookiePath = ";Path=" + cookiePath;
	}
	document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
}


/************************************************************************************************/
/* Get Cookie Function                                                                          */
/************************************************************************************************/
function getCookieValue(cookieName){
	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	if(cookieStartsAt == -1){
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");
	}

	if(cookieStartsAt == -1){
		cookieValue = null;
	}else{
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt)+1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if(cookieEndsAt == -1){
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));
	}

	return cookieValue;
}


/************************************************************************************************/
/* Popup Window Function                                                                        */
/* url : document url / wname : window name / w : width / h : height / ptype : options type     */
/* t : top / l : left                                                                           */
/************************************************************************************************/
function popWin(url,wname,w,h,ptype,t,l){
	var popupWin, tVal, lVal;
	if (t == "c") {
		lVal = (screen.Width - w) / 2;
		tVal = (screen.Height - h) / 2;
	} else {
		tVal = (t!=null)?t:0;
		lVal = (l!=null)?l:0;
	}
	var popOpt = "width="+w+",height="+h+", top="+tVal+", left="+lVal;
	if(ptype == 0){
		popOpt += ",scrollbars=no";
	}
	if(ptype == 1){
		popOpt += ",scrollbars=yes";
	}
	if(ptype == 2){
		popOpt += ",scrollbars=yes,resizable=yes";
	}
	popupWin = window.open(url,wname,popOpt);
	popupWin.focus();
}


/************************************************************************************************/
/* Load Iframe Resize Window Function                                                           */
/* vObj : Target Iframe Object                                                                  */
/************************************************************************************************/
function initIframeView() {
	var objFrame = document.getElementById("leftFlash");
	var objBody = leftFlash.document.body;

	if (objBody != null && objBody != undefined) {
		objFrame.style.height = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
		objFrame.style.backgroundColor = 'transparent';
		window.scrollTo(0,0);
	} else {
		objFrame.style.height = 150;
		objFrame.style.backgroundColor = 'transparent';
		window.scrollTo(0,0);
	}
}


/************************************************************************************************/
/* embedFlash                                                                                   */
/* vObj : Target Iframe Object                                                                  */
/************************************************************************************************/
function embedFlash(flash_path,menu,bgcolor,width,height,name) {
	document.write("<embed src='" + flash_path + "'");
	if (bgcolor != '0') document.write("bgcolor='" + bgcolor + "'");
	if (menu != '0') document.write("menu='" + menu + "'");
	document.write("width='" + width + "'");
	document.write("height='" + height + "'");
	if (name != '0') document.write("name='" + name + "'");
	document.write("quality='high'");
	document.write("type='application/x-shockwave-flash'");
	document.write("pluginspage='http://www.macromedia.com/go/getflashplayer'>");
	document.write("</embed>");
}


/************************************************************************************************/
/* objectFlash                                                                                  */
/* vObj : Target Iframe Object                                                                  */
/************************************************************************************************/
function objectFlash(id,width,height) {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
	document.write("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'");
	if (id != '0') document.write("id='" + id + "'");
	document.write("width='" + width + "'");
	document.write("height='" + height +"'>");
}
function objectFlashEnd(){
	document.write("</object>");
}

/************************************************************************************************/
/* paramFlash                                                                                   */
/* vObj : Target Iframe Object                                                                  */
/************************************************************************************************/
function paramFlash(name,value) {
	document.write("<param name='" + name + "' value='" +value +"'>");
}