﻿
////////////// 확대 이미지 새창 열기 시작 //////////////
function view(what) {
var what_change = what.replace("_t.jpg","_m.jpg");
var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=no,location=no,menu=no,width=0,height=0'); 
imgwin.focus(); 
imgwin.document.open(); 
imgwin.document.write("<html>\n"); 
imgwin.document.write("<head>\n"); 
imgwin.document.write("<title>확대이미지 미리보기</title>\n"); 
imgwin.document.write("<sc"+"ript>\n"); 
imgwin.document.write("function resize() {\n"); 
imgwin.document.write("pic = document.il;\n"); 
//imgwin.document.write("alert(eval(pic).height);\n"); 
imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n"); 
imgwin.document.write(" if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 40; myWidth = eval(pic).width + 12;\n"); 
imgwin.document.write(" } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n"); 
imgwin.document.write(" clearTimeout();\n"); 
imgwin.document.write(" var height = screen.height;\n"); 
imgwin.document.write(" var width = screen.width;\n"); 
imgwin.document.write(" var leftpos = width / 2 - myWidth / 2;\n"); 
imgwin.document.write(" var toppos = height / 2 - myHeight / 2; \n"); 
imgwin.document.write(" self.moveTo(leftpos, toppos);\n"); 
imgwin.document.write(" self.resizeTo(myWidth, myHeight);\n"); 
imgwin.document.write("}else setTimeOut(resize(), 100);}\n"); 
imgwin.document.write("</sc"+"ript>\n"); 
imgwin.document.write("</head>\n"); 
imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">\n');
imgwin.document.write("<img border=0 src="+what_change+" xwidth=100 xheight=9 name=il onload='resize();' onClick='JavaScript:window.close()' style='cursor:hand;'>\n");
imgwin.document.write("</body>\n"); 
imgwin.document.close(); 
}
////////////// 확대 이미지 새창 열기 끝 //////////////


////////////// 확대 이미지 새창 열기 시작 //////////////
function view_m(what) {
var what_change = what.replace("_s.jpg","_m.jpg");
var imgwin = window.open("",'WIN_M','scrollbars=no,status=no,toolbar=no,resizable=no,location=no,menu=no,width=0,height=0'); 
imgwin.focus(); 
imgwin.document.open(); 
imgwin.document.write("<html>\n"); 
imgwin.document.write("<head>\n"); 
imgwin.document.write("<title>확대이미지 미리보기</title>\n"); 
imgwin.document.write("<sc"+"ript>\n"); 
imgwin.document.write("function resize() {\n"); 
imgwin.document.write("pic = document.il;\n"); 
//imgwin.document.write("alert(eval(pic).height);\n"); 
imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n"); 
imgwin.document.write(" if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 40; myWidth = eval(pic).width + 12;\n"); 
imgwin.document.write(" } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n"); 
imgwin.document.write(" clearTimeout();\n"); 
imgwin.document.write(" var height = screen.height;\n"); 
imgwin.document.write(" var width = screen.width;\n"); 
imgwin.document.write(" var leftpos = width / 2 - myWidth / 2;\n"); 
imgwin.document.write(" var toppos = height / 2 - myHeight / 2; \n"); 
imgwin.document.write(" self.moveTo(leftpos, toppos);\n"); 
imgwin.document.write(" self.resizeTo(myWidth, myHeight);\n"); 
imgwin.document.write("}else setTimeOut(resize(), 100);}\n"); 
imgwin.document.write("</sc"+"ript>\n"); 
imgwin.document.write("</head>\n"); 
imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">\n');
imgwin.document.write("<img border=0 src="+what_change+" xwidth=100 xheight=9 name=il onload='resize();' onClick='JavaScript:window.close()' style='cursor:hand;'>\n");
imgwin.document.write("</body>\n"); 
imgwin.document.close(); 
}
////////////// 확대 이미지 새창 열기 끝 //////////////

/**
* 문자열 전체가 공백인지 확인
* @str			입력받은 문자열
* @return		문자열 전체가 공백이라면 true
*/
function isEmpty(str) {
	var OutStr = "";
	for(i=0; i< str.length; i++ ) {
		ch = str.charAt(i);
		if ( ch != " ") {
			OutStr = OutStr + ch;
		}
	}

	if (OutStr.length<1) {
		return true;
	}
	return false;
}

//wmv 재생
function getMediaPlayer(Media,Width,Height)
{		
	document.write("<object id='mediaPlayer' CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' type='application/x-oleobject' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' width='" + Width + "' height='" + Height + "' style='FILTER:gray();z-index:-1;'>");
	//6BF52A52-394A-11d3-B153-00C04F79FAA6
	//63485F60-6816-4D5E-8B1B-3ACD8BB228BE
	document.write ("<param name='URL' value='" + Media + "'>");
	document.write ("<param name='AutoStart' value='true'>");
	document.write ("<param name='Balence' value='0'>");
	document.write ("<param name='Volume' VALUE='100'>");
	document.write ("<param name='PlayCount' value='1'>");
	document.write ("<param name='uiMode' value='full'>");
	document.write ("<param name='BaseURL'>");
	document.write ("<param name='EnableContextMenu' value='false'>");
	document.write ("<param name='InvokeURLs' value='false'>");
	document.write ("<param name='stretchToFit' value='true'>");
	document.write ("<embed");
	document.write ("		src='" + Media + "'");
	document.write ("		autostart='-1'");
	document.write ("		invokeURLs='false'");
	document.write ("		type='application/x-mplayer2'");
	document.write ("		pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/'");
	document.write ("		id='mediaPlayer'");
	document.write ("		Name='mediaPlayer'");
	document.write ("		DisplaySize='4'");
	document.write ("		width='" + Width + "'");
	document.write ("		height='" + Height + "'");
	document.write ("		ShowControls='1'");
	document.write ("		ShowDisplay='0'");
	//document.write ("		ShowStatusBar='1'>");
	document.write ("</embed invokeURLs=false>");
	document.write ("</object>");
	/*document.write ("<OBJECT ID=NSPlay Name=NSPlay classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...'  type='application/x-oleobject' style='FILTER:gray();z-index:-1;'>");
	document.write ("<PARAM NAME='AutoStart' VALUE='-1'><PARAM NAME='AnimationAtStart' VALUE='-1'><PARAM NAME='DisplayMode' VALUE='4'><PARAM NAME='Enabled' VALUE='true'><PARAM NAME='Filename' VALUE='" + Media + "'><PARAM NAME='ShowControls' VALUE='1'><PARAM NAME='ShowAudioControls' VALUE='1'><PARAM NAME='ShowDisplay' VALUE='0'><PARAM NAME='ShowGotoBar' VALUE='0'><PARAM NAME='ShowPositionControls' VALUE='0'><PARAM NAME='ShowStatusBar' VALUE='1'><PARAM NAME='Volume' VALUE='0'><PARAM NAME='ShowCaptioning' VALUE='0'>");
	document.write ("<EMBED src='" + Media + "' autostart='-1' invokeURLs='false' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' id='NSPlay' Name='NSPlay' DisplaySize='4' AutoSize='1'  ShowControls='1' ShowDisplay='0' ShowStatusBar='1'></EMBED invokeURLs='fals'e>");
	document.write ("</OBJECT>");*/
}


/*기본검색 ***************************/
//검색 처리
function fnDefault() {
	var frm1 = document.sform;
	var frm2 = document.uform;
	
	if (frm1.mode[1].checked) { //유교넷 검색을 선택한 경우
		if (isEmpty(frm1.keyword2.value) == true) {
			//if (frm1.mode[0].checked == false) {
				alert("유교넷 통합 검색을 위하여 검색어를 입력해 주십시오");
				return;
			//}
		} else { //검색어가 있으면
			frm2.keyword.value = frm1.keyword2.value;
			frm2.action = "http://www.ugyo.net/cf/sch/srch_list.jsp";
			frm2.target = "_blank";
			frm2.submit();
		}
	}
	if (frm1.mode[0].checked) {
		frm1.submit();
	}
}


//유교넷 새창 함수
function ugyourl_win(ugyourl) {
	var ugyoWin = window.open(ugyourl, 'ugyoWin', 'width=800, height=460, scrollbars=yes, status=no, resizable=yes');
	ugyoWin.focus();
}

//교재 말말말 새창 함수
function word_win(tcode) {
	var word_win = window.open("/ground/word_pop01.jsp?t_code="+tcode, 'word_win', 'width=767, height=600, scrollbars=yes, status=no, resizable=no');
	word_win.focus();
}

//로그인 새창 함수
function login_open() {
	window.open('/login.jsp','ugyonet_login','scrollbars=no,left=400,top=400,width=450,height=215')
}


//지도로 보는 조선시대 교육기관 새창 함수
function win_open(mid_gubun,code) {
	var word_win = window.open("/map/edu_map_pop.jsp?code="+code+"&mid_gubun="+mid_gubun, 'map_win', 'width=777, height=600, scrollbars=yes, status=no, resizable=no,left=300,top=100');
	word_win.focus();
}

//검색 - 교육사상가 새창 함수
function idea_pop(i_id) {
	var idea_win = window.open("/survey/edu_mancontent.jsp?i_id="+i_id, 'idea_win', 'width=920, height=700, scrollbars=yes, status=no, resizable=no,left=100,top=100');
	idea_win.focus();
}

//검색 - 기타 새창 함수
function etc_pop(etc_url) {
	var etc_win = window.open(etc_url, 'etc_win', 'width=920, height=700, scrollbars=yes, status=no, resizable=no,left=100,top=100');
	etc_win.focus();
}

//교육사상가 - 관련URL 새창 함수
function ideaman_pop(manurl) {
	var manurl_win = window.open(manurl, 'manurl_win', 'width=600, height=500, scrollbars=yes, status=no, resizable=no,left=200,top=100');
	manurl_win.focus();
}

/**
* 인풋박스, 셀렉트 박스에 입력하지 않았을시 메시지 출력
* @obj
* @len			최대 허용 문자수
* @return		정상 입력시 true
*/
function inputChk(obj, len) {
	if (isEmpty(obj.value) == true)  {
		alert(obj.title+"을(를) 입력해 주십시오");
		obj.focus();
		return false;
	}
	if (!lengthChk(len)) {
		return false;
	}
	return true;
}

/*
문자열 길이가 맞는지 체크하여 다르면 false를 리턴
@ len			입력받을 문자열 길이
return		입력된 문자열 길이가 허용한 길이와 일치하면 true
*/
function lengthChk(obj, len) {
	if (len!=null) {
		return false;
	}
	if (len>0 && obj.value.length!=len)  {
		alert(obj.title+"은(는) "+len+"자를 입력해 주십시오");
		obj.focus();
		return false;
	}
	return true;
}







//주석팝업띄우기
function PopJuSukView(strJuSukId)
{
	var strJuSukId_Length ;
	var nNowWinX = document.body.offsetWidth;	//현재document의 가로사이즈
	var nNowWinY = document.body.offsetHeight;	//현재document의 세로사이즈
	nMouseX = event.clientX + document.body.scrollLeft;
	nMouseY = event.clientY + document.body.scrollTop;
	
	strJuSukId_Length = ((strJuSukId.text.length / 30) * 25 ) + 30;
	//alert(strJuSukId_Length);
	if ( (nMouseX + 300) > nNowWinX  )			// 현재마우스위치 + 팝업창가로사이즈 > 현재윈도우값을 벗어나는가
	{
		nMouseX = nNowWinX - 350				//벗어날경우 현재윈도우 - 팝업창가로사이즈
	}

	//주석이 화면창에서 벗어날경우 처리
	if ( (nMouseY+strJuSukId_Length - document.body.scrollTop) > nNowWinY )
	{
		nMouseY = nMouseY - strJuSukId_Length - 20				
	}
	divJusuk_Out.style.left = nMouseX ;
	divJusuk_Out.style.top = nMouseY + 10;
	TdJusuk.innerHTML = strJuSukId.text;

	TdJusukNum.innerHTML = strJuSukId.hreflang;
	divJusuk_Out.style.display='';

}


//주석팝업Close
function PopJusukHidden()
{
	divJusuk_Out.style.display = 'none';
	TdJusuk.innerText = "";
}
function goUsangiUrl(menu)
{
	if (menu=="index")
	{
		location.href="/index.asp";
	}
	else if (menu=="bd")
	{
		location.href="/mountain/spotview.asp?mou=1";
	}
	else if (menu=="kg")
	{
		location.href="/mountain/spotview.asp?mou=2";
	}
	else if (menu=="jr")
	{
		location.href="/mountain/spotview.asp?mou=3";
	}
	else if (menu=="bh")
	{
		location.href="/mountain/spotview.asp?mou=4";
	}
	else if (menu=="gy")
	{
		location.href="/mountain/spotview.asp?mou=5";
	}
	else if (menu=="cr")
	{
		location.href="/mountain/spotview.asp?mou=6";
	}
	else if (menu=="story")
	{
		location.href="/storybank/bank.asp";
	}

}
//javascript:goUsangiUrl('story')

function syncLoad( cat )
{
	var strHeaderBizName = syncHeaderParameter("cat");

	if (undefined != top.frames.fraBottom || undefined != top.frames.noFraBottom) //FRAME
	{
		//var tmpCat;
		//tmpCat = cat;
		//if (cat.substring (0, 6) == "et_pol")
			//cat = "et_pol";
		//else if (cat.substring (0, 6) == "tu_cts")
		//	cat = "tu_cts";
		
		if( cat != strHeaderBizName)
		{
			//cat = tmpCat;
			if ( top.location.pathname != "/index.jsp" )		//url만치고 들어왔을경우
			{
				var url = top.location.pathname + top.location.search;
				url = encodeURI(url);
				HeaderMoveUrlAll(cat, url);
				return true;
			}
			else
			{
				var url = location.pathname + location.search;
				HeaderMoveUrlAll(cat, url);
				return true;
			}
		}
	}
	else
	{
		if ((top.frames.fraBottom == undefined && parent == self) || (top.frames.noFraBottom == undefined && parent == self))
		{
			var url = location.pathname + top.location.search;
			url = encodeURI(url);
			HeaderMoveUrlAll(cat, url);
			return true;
		}
	}
}

function TreeView()
{
	if (top.frames.fraBottom != undefined)
	{
		if (top.fraBottom.fraContentBar.document.all("showtoc_td").style.width == "60px")
		{
			top.fraBottom.fraContentBar.showtoc.style.display = '';
		}
	}
}

function syncHeaderParameter(p)
{
  if (p) r=top.location.search.match(new RegExp("[&?]"+p+"=(.*?)(&|$)"));
  return r&&r[1]?r[1]:null;
}

//뒤로가기버튼이 제자리일경우 사용 전체Url로 걸어준다
function HeaderMoveUrlAll(strMoveCat, strUrl)	//HeaderMoveUrlAll(이동문집아이디, 이동 경로)
{
	strUrl = ncCom_Replace(strUrl, "&", "%26");
	strUrl = ncCom_Replace(strUrl, "?", "%3F");
	var strMoveUrl = "http://" + location.host + "/index.jsp?cat="+strMoveCat+"&url="+strUrl;
	top.location.href = strMoveUrl;
}





//현재위치의 정보를 네비게이션에 뿌린다
function AreaInfoUrl(strText,strTextEnd)
{
	clearTimeout (timerAreaInfo);
	//alert (top.frames.fraBottom + "::" + top.document.all.area_info);
	if ((parent.fraContentBar == undefined || parent.fraContentBar.area_info == undefined) && (top.noFraBottom == undefined || top.noFraBottom.area_info == undefined))
	{
		clearTimeout (timerAreaInfo);
		timerAreaInfo = setTimeout ("AreaInfoUrl (\"" + strText + "\", \"" + strTextEnd + "\")", 500) ;
		return;
	}

	if (top.frames.fraBottom != undefined)
		parent.fraContentBar.area_info.innerHTML = strText +  "<span class='nav'>"+strTextEnd+"</span>";
	else
		top.noFraBottom.area_info.innerHTML = strText +  "<span class='nav'>"+strTextEnd+"</span>";
}

function removeChildAll (obj)
{
	if (obj == undefined || !obj.hasChildNodes ())
		return;
	
	for (i = obj.children.length; i > 0 ; i--)
	{
		obj.removeChild (obj.children[i - 1]);
	}
}

//페이지 바로가기 처리
function directPageGo (addr, index, maxPage)
{
	var indexNum = new Number (index);
	var maxPageNum = new Number (maxPage);
	var oPage = document.getElementsByName ("directPage");
	var pageValue = oPage.item(indexNum).value;	
	
	//if (!addr) {
		addr = location.href;
	//}
	if (addr.indexOf ("?") == -1) {
		addr += "?";
	}
	if (addr.indexOf ("pageno") != -1)
		addr = addr.substring (0, addr.indexOf ("pageno"));

	if (pageValue == "")
	{
		alert ("페이지 번호를 입력해 주세요.");
		return;
	}
	else if (!checkNumber (pageValue))
	{
		alert ("페이지 번호는 숫자만 입력해 주세요.");
		return;
	}
	else if (pageValue < 1 || pageValue > maxPageNum)
	{
		alert ("1페이지 부터 " + maxPage + " 페이지 이하로 입력해 주세요.");
		return;
	}	
	location.href = addr + "&pageno=" + pageValue;
}

function checkNumber(pageValue){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(pageValue))
	{
		result=true;
	}
	else
	{
		result=false;
	}
	return (result)
}

