var icon1 = new Image();
var icon2 = new Image();
var icon3 = new Image();
var icon4 = new Image();
var icon5 = new Image();
icon1.src = "/images/icon/ic_news1depth.gif";
icon2.src = "/images/icon/ic_2depth_o.gif";
icon3.src = "/images/icon/ic_2depth.gif";
icon4.src = "/images/home/im_dot02.gif";
icon4.src = "/images/icon/ic_arrow01.gif";

StartTime = new Date();
function NoteTime() {
    StopTime = new Date();
    Diff = StopTime.getTime() - StartTime.getTime(); 
    Diff = Diff / 1000;
    window.status = ("이 페이지의 로딩시간은 " + Diff + " 초 입니다.");
}
// 회원 로그인 Popup Window Open
function Login() {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=320,height=240";
	LoginWindow = window.open("/login/UserLogin.jsp", "LoginWindow", Future)
	//LoginWindow.focus();
}
function Logout() {
    location.href = "/login/UserLogout.jsp";
}
function newLogout() {
    location.href = "/html/login/UserLogout.jsp";
}

function lengthCheck(inputOfForm, maxLen, inputName) {
	if (checkLen(inputOfForm.value) > maxLen) {
		inputOfForm.focus();
        inputOfForm.select();
        alert(inputName + " " + maxLen + "자를 넘을 수 없습니다.");
        return false;
    }
    return true;
}
function CheckLogin() {
	if (!lengthCheck(loginForm.id, 10, "아이디는")) return;
    if (!lengthCheck(loginForm.password, 10, "패스워드는")) return;
    if (loginForm.id.value == "") {
	    loginForm.id.focus();
	    return alert("아이디를 입력하십시오.");
	}
	if (loginForm.password.value == "") {
	    loginForm.password.focus();
	    return alert("패스워드를 입력하십시오.");
	}
	loginForm.submit();
}



function CheckLogin2() {
    if (loginForm.id.value == "") {
            loginForm.id.focus();
            return alert("아이디를 입력하세요");
        }
        if (loginForm.password.value == "") {
            loginForm.password.focus();
            return alert("패스워드를 입력하세요");
        }
        loginForm.submit();
}























function keyDown() { 
  	var keycode = window.event.keyCode;
   	if (keycode==13) CheckLogin();
}
// 관리자 서브메뉴 Display Function
function ShowSubMenu(nIndex) {
	var SubMenuCount = 8;
	if (document.getElementById) {
		for (var i=1; i <= SubMenuCount; i++)
		    if (document.getElementById("SubMenu" + i) != null) document.getElementById("SubMenu" + i).style.display = "NONE";
		document.getElementById("SubMenu" + nIndex).style.display = "";
	} else {
		for (var i=1; i <= SubMenuCount; i++)
			if (document.all("SubMenu" + i) != null) document.all("SubMenu" + i).style.display = "NONE";
		document.all("SubMenu" + nIndex).style.display = "";
	}
}
// 인쇄 Popup Window Open
function PrintPreview(sURL) {
	Future = "fullscreen=no,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=100,width=631,height=550";
	PrintWindow = window.open(sURL, "PrintWindow", Future);
	PrintWindow.focus();
}
// 달력 Popup Window Open
function PrintPreview() {
	Future = "fullscreen=no,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=100,width=631,height=550";
	CalendarWindow = window.open("/admin/statistics/Calendar.html", "CalendarWindow", Future);
	CalendarWindow.focus();
}
// 문자열 양쪽의 공백문자 제거
function trim(str) {
	var start = 0;
	var end = str.length-1;
	var i;
	for (i=0; i<str.length; i++) {
		if (str.charAt(i) != ' ') {
			start = i;
			break;
		}
	}
	for (i=str.length-1; i>=0; i--) {
		if (str.charAt(i) != ' ') {
			end = i;
			break;
		}
	}
	if( str.charAt(0) == ' ' && start == 0 && end == str.length-1)
		return "";
	return str.substring(start,end+1);
}
// 숫자인지 체크하는 함수
function checkNum(name) {
	var SsnNum="0123456789";
	var returnValue = true;
		if ( trim(name) == "" ) {
		return false;
	}
	for (var i=0;i< name.length;i++)
		if (-1 == SsnNum.indexOf( name.charAt(i)))
			returnValue = false;
	if (!returnValue)	{
		return false;
	}
			return returnValue;
}
// 이메일 형식이 적법한지 검사
function checkEmail(name) {
	if (name == "") {
		return false;
	} else {
		var currCh, numMail = 0;
		var currStat = 0, ok = true, started = false;
		var str = trim(name);
		for (var i = 0; i < str.length; i++) {
			currCh = str.charAt(i);
			if (currCh == '@') {
				if (currStat != 1) {
					ok = false;
					break;
				}
				currStat = 2;
			} else if (currCh == '.') {
				if (currStat != 3 && currStat != 5) {
					ok = false;
					break;
				}
				currStat = 4;
			} else if (currCh == ',') {
				if (!(currStat == 0 || currStat == 5)) {
					ok = false;
					break;
				}
				currStat = 6;
				started = false;
			} else if (currCh == ' ') {
				if (!(currStat==0 || currStat==6 || currStat==5)) {
					ok = false;
					break;
				}
				currStat = 0;
			} else {
				if (currStat == 0) {
					if (started) {
						ok = false;
						break;
					}
					currStat++;
					numMail++;
					started = true;
				} else if (currStat == 2 || currStat == 4) {
					currStat++;
				} else if (currStat == 6) {
					currStat = 1;
					numMail++;
				} else if (currStat == 1 || currStat == 3 || currStat == 5) {
				} else {
					ok = false;
					break;
				}
			}
		}
		if (ok && (currStat == 0 || currStat == 5) ) return true;
	}
	return false;
}
// 해당문자의 바이트 수를 리턴
function checkLen(str) {
    var t;
    var msglen = 0;
    var l = str.length;
    for(k=0; k < l ; k++) {
        t = str.charAt(k);
        if (escape(t).length > 4) msglen += 2; else msglen++;
	}
	return msglen;
}
// 특수문자 체크 
function dodacheck(arg) {
	var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\!\?\<\>\/\"\:\;\`\~\=\|\']/;
	var strPass = arg.value;
	var strLength = strPass.length;
	var lchar = arg.value.charAt((strLength) - 1);
	if(lchar.search(mikExp) != -1) {
		arg.focus();
		alert("특수문자는 입력할 수 없습니다.");
        return false;
    }
	return true;
}
// Full-Text 특수문자
function dodacheckAll(arg) {
	var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\!\?\<\>\/\"\:\;\`\~\=\|\']/;
	var strPass = arg;
	var strLength = strPass.length;
	var lchar = arg.charAt((strLength) - 1);		
    var j = 1;
	for(var i=0;i<arg.length;i++){
		if(lchar.search(mikExp) != -1) {
			return false;
		}
		j++;
		lchar = arg.charAt((strLength) - j);			
	}
		return true;
}
// Full-Text 특수문자 2
function dodacheckAll2(arg) {
	var mikExp = /[\"\`\']/;
	var strPass = arg;
	var strLength = strPass.length;
	var lchar = arg.charAt((strLength) - 1);		
    var j = 1;
	for(var i=0;i<arg.length;i++){
		if(lchar.search(mikExp) != -1) {
			return false;
		}
		j++;
		lchar = arg.charAt((strLength) - j);			
	}
		return true;
}
function msrDodaCheck(arg) {
	var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\!\?\<\>\/\"\:\;\`\~\=\|\']/;
	var strPass = arg;
	var strLength = strPass.length;
	var lchar = arg.charAt((strLength) - 1);		
    var j = 1;
	for(var i=0;i<arg.length;i++){
		if(lchar.search(mikExp) != -1) {
			return false;
		}
		j++;
		lchar = arg.charAt((strLength) - j);			
	}
		return true;
}
// FAQ Indexing Popup Window
function GoFAQIndexing() {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=320,height=240";
	FAQIndexingWindow = window.open("/admin/faq/FAQIndexing.html", "FAQIndexingWindow", Future);
	FAQIndexingWindow.focus();
}
// 도움말 서브메뉴 Display Function
function ShowHelpSubMenu(nIndex) {
	if (nIndex == 0) return;
	var HelpSubMenuCount = 4;
	for (var i=1; i <= HelpSubMenuCount; i++)
		eval("HelpSubMenu" + i).style.display = "none";
	eval("HelpSubMenu" + nIndex).style.display = "block";
}
// 개인정보보호정책 Popup Window
function InfoProtect() {
        Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=550,height=600";
	InfoWindow = window.open("/etc/InfoProtect.html", "개인정보보호정책", Future);
	InfoWindow.focus();
}
// 도움말 Popup Window
function GoHelp(arg) {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=550,height=570";
	HelpWindow = window.open("/etc/Help.jsp?help="+arg, "HelpWindow", Future);
	HelpWindow.focus();
}
// 용어사전 Popup Window
function GoWordDic() {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=500,height=600";
	WordDicWindow = window.open("/etc/WordDic.jsp?listNo=1", "WordDicWindow", Future);
	WordDicWindow.focus();
}
// 용어사전 Popup Window
function GoWordDic2(arg) {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=500,height=600";
	WordDicWindow = window.open("/etc/WordDic.jsp?listNo="+arg, "WordDicWindow", Future);
	WordDicWindow.focus();
}
// 용어사전 Popup Window
function GoWordDic3(arg) {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=500,height=300";
	WordDicWindow = window.open("/etc/WordDic_pop.jsp?word="+arg, "WordDicWindow", Future);
	WordDicWindow.focus();
}
// 자료실 Popup Window
function GoPds(arg) {
	Future = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=600,height=437";
	PdsWindow = window.open("/pds/PdsView_pop.jsp?pdsId="+arg, "PdsWindow", Future);
	PdsWindow.focus();
}
// 링크 Popup Window
function GoLink(arg) {
	LinkWindow = window.open("/etc/Link.jsp?link="+arg, "LinkWindow");
	LinkWindow.focus();
}
// 링크 Popup Window
function GoSearchLink(arg1,arg2) {
	SearchLinkWindow = window.open("/etc/SearchLink.jsp?link="+arg1+"&keyword="+arg2, "SearchLinkWindow");
	SearchLinkWindow.focus();
}
// 링크 Popup Window
function GoUtfSearchLink(arg1,arg2) {
	var UtfUrl = arg2;
	var normalUrl = unescape(arg2);
	var UtfValue = null;
	var urlPoint1 = 0;
	var urlPoint2 = 0;
	var urlPoint3 = 0;
	var urlPoint4 = 0;
	while((urlPoint1 = UtfUrl.indexOf("%3D",urlPoint1+3)) >= 0) {
		urlPoint2 = UtfUrl.indexOf("%26",urlPoint1+3);
		if (urlPoint2 < 0) urlPoint2 = UtfUrl.length;
		urlPoint3 = normalUrl.indexOf("=", urlPoint3+1);
		urlPoint4 = normalUrl.indexOf("&", urlPoint3+1);
		UtfValue = UtfUrl.substring(urlPoint1+3,urlPoint2);
		normalUrl = normalUrl.substring(0,urlPoint3+1) + UtfValue + ((urlPoint4 >= 0) ? normalUrl.substring(urlPoint4,normalUrl.length) : "");
	}
	document.searchUrlForm.searchUrl.value = normalUrl;
	UtfSearchLinkWindow = window.open("/etc/UtfSearchLink.jsp?link="+arg1+"&keyword="+normalUrl, "UtfSearchLinkWindow");
	UtfSearchLinkWindow.focus();
}
//----  Event Popup Window ----------------------------------------//
function getCookie(name) {
  var from_idx = document.cookie.indexOf(name+'=');
  if (from_idx != -1) { 
  from_idx += name.length + 1;
  to_idx = document.cookie.indexOf(';', from_idx) ;
  if (to_idx == -1) {
  to_idx = document.cookie.length;
  }
  return unescape(document.cookie.substring(from_idx, to_idx));
  }
}
function GoEvent() {
	var CloseDate = new Date("June 25, 2005"); //팝업 윈도우를 닫고자 하는 날짜
  var Today = new Date(); //오늘 날짜                                                    
                                                                                       
  if (Today < CloseDate)                                                                 
  {                                                                                      
    //getCookie 함수를 호출하여 쿠키값을 가져온다.                                         
    var blnCookie = getCookie("op1");                                                      
    //쿠키값이 true가 아닐 경우에만 새 창을 띄운다.      
    if ( !blnCookie ) {
	  	var opt = "fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=100,top=100,width=472,height=650";
	  	var EventWindow = window.open("/etc/event/EventDetail.htm", "EventWindow", opt);
	  	EventWindow.focus();
	  }
	}
}
//-----------------------------------------------------------------//
//동호회 바로가기
function goMyCommunity() {
    //alert(document.myCommunityForm.myCommunitySelect.options[document.myCommunityForm.myCommunitySelect.selectedIndex].value);
    var url = "/html/community/CommunityMain.jsp?comId="+document.myCommunityForm.myCommunitySelect.options[document.myCommunityForm.myCommunitySelect.selectedIndex].value;
    location.href = url;
}
//출처클릭시 기관의 검색목록 출력
function orgSubmit(orgURL, orgCode) {
	
	
	if(orgCode.toUpperCase() == 'CULTURE2' || orgCode.toUpperCase() == 'CULTURE1') {
		GoSearchLink(orgCode, unescape(orgURL));
	} else if(orgCode.toUpperCase() == 'HISTORY' || orgCode.toUpperCase() == 'ALTAVISTA') {
		GoUtfSearchLink(orgCode, orgURL);
	} else if(orgCode.toUpperCase().indexOf('KISTI') < 0) {
		var name = 'orgWindow';
		var option = 'toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=yes, width=750,height=600'; 
		var orgWindow = window.open(unescape(orgURL), name, option, false);
		//orgWindow.document.write("<HTML><BODY>이동중입니다.<SCRIPT> location.href = '"+unescape(orgURL)+"'; </SCRIPT> </BODY></HTML>");
		orgWindow.focus();
	} else { 
		kistiViewer(unescape(orgURL));
	}
}
//kisti의 검색결과 화면 Viewer
function kistiViewer(orgURL) {
	var PosX ,PosY;
	PosX = parseInt ( ( screen.width - 800 ) / 2 );
	PosY = parseInt ( ( screen.height - 700 ) / 2 );
	winproperty = "width=800,height=600,status=yes,resizable=yes,scrollbars=no,menubar=no,location=no,toolbar=yes, MaxButton=yes, top=" + PosY + ", left=" + PosX;
	winAddNew = window.open("","dist_search",winproperty);
	winAddNew.top.document.write("<html><head><title>분산통합검색</title> ");
	winAddNew.top.document.write("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head> ");
	winAddNew.top.document.write("<frameset cols='176,*'  frameborder=0 framespacing=0 > ");
	winAddNew.top.document.write("	<frame name='leftFrame' marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 scrolling='yes'> ");
	winAddNew.top.document.write("	<frame name='dist_rightFrame' marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 scrolling='auto'> ");
	winAddNew.top.document.write("</frameset> ");
	winAddNew.top.document.write("<noframes><body bgcolor=#FFFFFF text=#000000></body></noframes></html>");
	winAddNew.focus();
	winAddNew.frames[1].location.href = "about:blank";
	winAddNew.frames[0].location.href = orgURL;
}
//상세내용 출력
function articleSubmit(dbName, orgURL) {
	if (dbName.toUpperCase() == 'HISTORY' && orgURL.toUpperCase().indexOf("JAVASCRIPT") < 0) { //UTF8처리
		//alert("UTF8처리");
		return utfArticleSubmit(dbName, orgURL);
	}
	
	if (dbName.toUpperCase() == 'KERIS6') { //
		return utfArticleSubmit(dbName, orgURL);
	}
	
	if (dbName.toUpperCase().indexOf('KISTI') < 0) orgURL = unescape(orgURL);

	var sCount = 0;
	while(parseInt(orgURL.indexOf("&", sCount)) != -1) {
		sCount = parseInt(orgURL.indexOf("&", sCount)) + 3;
		orgURL = orgURL.replace("&","%26");
	}

	var recomendWindow = window.open("/metasch/OrganCount.jsp?kkpdbname="+dbName+"&kkpsitelink="+orgURL, "recommendwin", "toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=yes, width=750,height=600"); 
	recomendWindow.focus();
	return;
}
//상세내용 출력(UTF8처리)
function utfArticleSubmit(arg1, arg2) {
	var UtfUrl = arg2;
	var normalUrl = unescape(arg2);
/*
	var UtfValue = null;
	var urlPoint1 = 0;
	var urlPoint2 = 0;
	var urlPoint3 = 0;
	var urlPoint4 = 0;
	while((urlPoint1 = UtfUrl.indexOf("%3D",urlPoint1+3)) >= 0) {
		urlPoint2 = UtfUrl.indexOf("%26",urlPoint1+3);
		if (urlPoint2 < 0) urlPoint2 = UtfUrl.length;
		urlPoint3 = normalUrl.indexOf("=", urlPoint3+1);
		urlPoint4 = normalUrl.indexOf("&", urlPoint3+1);
		UtfValue = UtfUrl.substring(urlPoint1+3,urlPoint2);
		normalUrl = normalUrl.substring(0,urlPoint3+1) + UtfValue + ((urlPoint4 >= 0) ? normalUrl.substring(urlPoint4,normalUrl.length) : "");
	}
*/
	document.searchUrlForm.searchUrl.value = normalUrl;
	var recomendWindow = window.open("/metasch/UtfOrganCount.jsp?kkpdbname="+arg1, "recommendwin", "toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=yes, width=750,height=600"); 
	recomendWindow.focus();
	return;
}

