var win = null;
function query_j(v_kw_query){
v_kw_query=v_kw_query.replace("%3cfont%20color%3dblue%3e","");
v_kw_query=v_kw_query.replace("%3c/font%3e","");
location.href=v_kw_query;
}

function brief_win(mode, dbno, disp_type, start, pnum, sort, sort_type, view_close)
{
	if(mode == 1)
	{
		briefwin = window.open('','brief_window','scrollbars=yes,resizable=yes,toolbar=yes,width=750,height=620');
		briefwin.focus();

		document.brief_view.target = 'brief_window';
		document.brief_view.v_close.value = 1;
	}
	else document.brief_view.v_close.value = view_close;

	document.brief_view.v_db.value = dbno;

	document.brief_view.v_disp_type.value = disp_type;
	document.brief_view.v_start.value = start;
	document.brief_view.v_pnum.value = pnum;

	document.brief_view.v_sort.value = sort;
	document.brief_view.v_sort_type.value = sort_type;
	document.brief_view.submit();
}

function gowin(url)
{ 
	var	url = "";
	if(win != null) win.close();
	win = window.open('', 'window', 'scrollbars=yes,resizable=yes,toolbar=yes,width=800,height=620');
	if(win != null)
	{
		win.location.href = url;
		win.focus();
	}
	return;
} 

function full_win(kw_str, dbno, docno, tot, pos, go) 
{ 
        document.full_view.v_kw_str.value = kw_str; 
        document.full_view.v_db.value = dbno; 
        document.full_view.v_doc_no.value = docno; 
        document.full_view.v_tot.value = tot; 
        document.full_view.v_pos.value = pos; 
        document.full_view.v_go.value = go; 
        document.full_view.submit(); 
} 

function full_win2(kw_str, dbno, docno, tot, pos, go) 
{ 
	briefwin = window.open('','brief_window','scrollbars=yes,resizable=yes,toolbar=yes,width=750,height=620');
	briefwin.focus();

	document.full_view.target = 'brief_window';
	document.full_view.v_close.value = 1;

        document.full_view.v_kw_str.value = kw_str; 
        document.full_view.v_db.value = dbno; 
        document.full_view.v_doc_no.value = docno; 
        document.full_view.v_tot.value = tot; 
        document.full_view.v_pos.value = pos; 
        document.full_view.v_go.value = go; 
        document.full_view.v_viewlist.value = 0; 
        document.full_view.submit(); 
}

function full_win_prevnext(dbno, pos)
{
	document.full_view.v_db.value = dbno;
	document.full_view.v_pos.value = pos;
	document.full_view.submit();
} 

function go_list(dbno)
{
	document.full_view.action="brief.cgi";
	document.full_view.v_db.value = dbno;
	document.full_view.submit();
}

function go_normal()
{
	parent.right.location.href = "http://www.dlibrary.go.kr/WONMUN/Service/service_07.jsp";
        document.location.replace("wonmun_db.cgi?v_searchtype=0");
}

function go_detail()
{
   /*     document.search.action="wonmun_db.cgi";
	document.search.v_searchtype.value = 1;
	document.search.target = 'left';
	document.search.submit(); */
	parent.right.location.href = "http://www.dlibrary.go.kr/WONMUN/Service/service_07.jsp";
        document.location.replace("wonmun_db.cgi?v_searchtype=1"); 
}

function select_submit(mode)
{
        if(mode == 1)
	{
		
		if(document.search.v_kw_query.value.length == 0)
		{
			alert("키워드 : 검색어를 입력하시기 바랍니다.");
                        return false;
		}
                document.search.action="brief.cgi";
	}
        else if(mode == 0) /* scan */
                document.search.action="scan.cgi";

	
	document.search.submit();

}

function run_submit(form, mode)
{
        if(mode == 1) 
                form.action="/ndli/dasencgi/brief.cgi";
        else if(mode == 0)
                form.action="/ndli/dasencgi/scan.cgi";
	form.submit(); 
}

function multilang_open(name)
{
	var	url = "";

	if(win != null)
		win.close();

	win = window.open('', 'multilang_window', 'scrollbars=yes,resizable=yes,toolbar=yes,width=800,height=620');

	if(win != null)
	{
		win.location.href = '/multilang/print_frame.cgi?v_name='+name;
		win.focus();
	}
	return;
}

function view_win000000(mode, dbno, docid)
{
	if(mode != 'fulltext') 
		selectwin = window.open('','view_window','scrollbars=yes,resizable=yes,width=680,height=450');
	else
		document.view.action = '/ndli/dasencgi/bin/view_list.cgi//'+dbno+'_'+docid+'.dliv';
	document.view.v_mode.value = mode;
	document.view.v_db.value = dbno;
	document.view.v_doc_no.value = docid;
	if(mode != 'fulltext') 
	{
		document.view.target = 'view_window';
		selectwin.focus(); 
	}
	else
		document.view.target = '_self';
	document.view.submit();
}

function view_win20040711(mode, dbno, docid)
{
    var f = null;
	
    ////20040702 dasencgi 를 dasencgi_mir로 변경 ////
    var window_left = (screen.width-640)/2;
    var window_top = (screen.height-480)/2;

	var VCode ;
	VCode = NLViewerCheck.Version ; 
	
    ////20040702 dasencgi 를 dasencgi_mir로 변경 ////
  if(VCode == "0"){
       popOpen000();
  }else{
	
	if(mode != 'fulltext'){ 
		selectwin = window.open('','view_window','scrollbars=yes,resizable=yes,width=600,height=450');
	}else{	
	 
	 winopen = window.open('','view_dliv','width=600,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=' + window_top + ',left=' + window_left + '');
	 if(!winopen.opener){ winopen.opener=self;
	 }else{
		winopen.close();
        winopen = window.open('','view_dliv','width=600,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=' + window_top + ',left=' + window_left + '');	 
	    //if(!winopen.opener)winopen.opener=self;
	 }//..
	 document.view.action = '/ndli/dasencgi/bin/view_list.cgi//'+dbno+'_'+docid+'.dliv';
	 document.view.v_mode.value = mode;
	 document.view.v_db.value = dbno;
	 document.view.v_doc_no.value = docid;
	}//...
	if(mode != 'fulltext'){ 
		selectwin.focus();
	}else{
	 
	 document.view.target = 'view_dliv';
	 document.view.submit();
	}//..
  }//..elsclose
}


function view_win(mode, dbno, docid)
{

	//ECOSmartUpdate.AppName = "NLViewer"; // 어플리케이션의 이름을 넣는다. 이 부분을 바꾸면 작동하지 않습니다.
	
    ////20040702 dasencgi 를 dasencgi_mir로 변경 ////
  ////if(ECOSmartUpdate.IsLatest) {

	if(mode != 'fulltext') 
		selectwin = window.open('','view_window','scrollbars=yes,resizable=yes,width=680,height=450');
	else
	document.view.action = '/ndli/dasencgi/bin/view_list.cgi//'+dbno+'_'+docid+'.dliv';
	document.view.v_mode.value = mode;
	document.view.v_db.value = dbno;
	document.view.v_doc_no.value = docid;
	if(mode != 'fulltext') 
	{
		document.view.target = 'view_window';
		selectwin.focus(); 
	}
	else
		document.view.target = '_self';
	document.view.submit();

  /*}else{
		// Active-X가 설치 되지 않았습니다.
	alert("ECO에서 배포한 Active-X를 다운로드 하셔야 합니다.");
	location.reload();
  }//...*/
}

//신규 뷰어로 연결하기
function view_win_viewer(mode, dbno, docid){

	//thisfrm = document.frmViewer;
	var	popwidth = screen.availWidth;
	var	popheight = screen.availHeight;
	var	poptop = 0;
	var	popleft = 0;
	var macAddress = "";
	var dt=new Date();
	var getTime = dt.getHours()+""+dt.getMinutes()+""+dt.getSeconds();

	if(poptop < 0) { poptop = 0; }

	var	winprops = "height=" + popheight + ",width=" + popwidth + ","
			+ "top=" + poptop + ",left=" + popleft + ","
			+ "toolbar=no,resizable=yes,location=no,scrollbars=yes,status=no";
//	var	win_viewer = window.open("", "pop_viewer", winprops);
	var	win_viewer = window.open("", getTime, winprops);
	win_viewer.focus();

	/* MacAddress 가져오는부분 */
	xsys = loadActiveX("XViewer.SysRes");
	if(null == this.xsys) {
		macAddress = "none";
	}
	else {
		macAddress = this.xsys.MacAddress;
		macAddress = macAddress.substring(0,2)+'-'+macAddress.substring(2,4)+'-'+macAddress.substring(4,6)+'-'+macAddress.substring(6,8)+'-'+macAddress.substring(8,10)+'-'+macAddress.substring(10,12);
	}
	/* MacAddress 가져오는부분 */
	document.frmViewer.action = 'http://www.dlibrary.go.kr/JavaClient/jsp/dasen/viewWonmun.jsp';
	document.frmViewer.cno.value = docid;
	document.frmViewer.lip.value = macAddress;
	document.frmViewer.v_db.value = dbno;
	document.frmViewer.v_doc_id.value = '';
	document.frmViewer.sysid.value = ""; 
	document.frmViewer.target = getTime;
//	document.frmViewer.target = "pop_viewer";
	document.frmViewer.submit();

}

function loadActiveX(argClassName)
{
 try {
  var obj = new ActiveXObject(argClassName);
  if(null == obj) { throws; }
  return obj;
 }
 catch(e) { return null; }
}

/* 고지도를 보여주는 JavaScript Function */
function view_win2(controlNumber)  {
	var new_url = 'http://www.dlibrary.go.kr/Map/main.jsp?code=' + controlNumber;
	//alert('[' + new_url + ']');		// for test
//	win = window.open(new_url, 'brief_window', 'scrollbars=yes,resizable=yes,toolbar=yes,width=750,height=620');
	win = window.open(new_url, 'brief_window', 'scrollbars=yes,resizable=yes,toolbar=yes,width=750,height=620');
/*
	if (win != null)  {
		win.location = new_url;
		win.focus();
	}
	*/
}

function view_win20040811(mode, dbno, docid)
{

	var VCode ;
	VCode = NLViewerCheck.Version ; 
	
    ////20040702 dasencgi 를 dasencgi_mir로 변경 ////
  if(VCode == "0"){
       popOpen000();
	  // popOpen2002();
  }else if(VCode != "2.00.2011") {		//viewer version----------mrjoo^^  
       popOpen2002();
  }else{

	if(mode != 'fulltext') 
		selectwin = window.open('','view_window','scrollbars=yes,resizable=yes,width=680,height=450');
	else
		document.view.action = '/ndli/dasencgi/bin/view_list.cgi//'+dbno+'_'+docid+'.dliv';
	document.view.v_mode.value = mode;
	document.view.v_db.value = dbno;
	document.view.v_doc_no.value = docid;
	if(mode != 'fulltext') 
	{
		document.view.target = 'view_window';
		selectwin.focus(); 
	}
	else
		document.view.target = '_self';
	document.view.submit();
  }//...
}


function popOpen000(){
	//var url;
  var window_left = (screen.width-640)/2;
  var window_top = (screen.height-480)/2;
	url = "http://www.dlibrary.go.kr/popup/delibrary_pop.html";
	window.open(url,'xx','width=450,height=457,toolbars=no,scrollbars=no,resize=no,top=' + window_top + ',left=' + window_left + '');
}

function popOpen2002(){
	//var url;
  var window_left = (screen.width-640)/2;
  var window_top = (screen.height-480)/2;
	url = "http://www.dlibrary.go.kr/popup/dlibrary_update2002002.html";
	window.open(url,'xx','width=250,height=320,toolbars=no,scrollbars=no,resize=no,top=' + window_top + ',left=' + window_left + '');
}

function view_win3(mode, dbno, docid, v_control_no)
{
	document.view.v_mode.value = mode;
	document.view.v_db.value = dbno;
	document.view.v_doc_no.value = docid;
	document.view.v_control_no.value = v_control_no;
	document.view.target = '_self';
	document.view.action='/ndli/dasencgi/bin/view_list.cgi//원문보기';
	document.view.submit();
}



function viewer_win(url) {
        win = window.open('', 'viewer_window', 'scrollbars=yes,resizable=yes,toolbar=no,width=400,height=300');

        win.document.write("<html>\n");
        win.document.write("<head><title>Viewer 다운로드</title></head>\n");
        win.document.write("<body>\n");
        win.document.write("<font size=+1 face=돋움체>뷰어를 다운로드 합니다.</font>\n");
        win.document.write("<form name=viewer action='" + url +"'>\n");
        win.document.write("</form>\n");
        win.document.write("<script language=Javascript>\n");
        win.document.write("document.viewer.submit();\n");
        win.document.write("</script>\n");
        win.focus();
        //win.close();
}

function open_window(Seqno, ControlNo)
{
	aa = window.open('', 'win', 'scrollbars=yes,resizable=yes,toolbar=no,left=50,top=20,width=900,height=700');
	aa.document.location = '/ndli/dasencgi/NL_UH102CB?seqno='+Seqno+'&ctrno='+ControlNo;

/*
	if(aa != null)
	{
		aa.document.write("<HTML>\n");
		aa.document.write("<head>\n");
		aa.document.write("</head>\n");
		aa.document.write("<body>\n");
		aa.document.write("<form name=fmCall action=http://www.dlibrary.f.kr:8080/ndli/dasencgi/NL_UH102CB method=post>\n");
		aa.document.write("<input type=hidden name='seqno' value="+Seqno+">\n");
		aa.document.write("<input type=hidden name='ctrno' value="+ControlNo+">\n");
		aa.document.write("</form>\n");
		aa.document.write("<script language=JavaScript>\n");
		aa.document.write("document.fmCall.submit();\n");
		aa.document.write("</script>\n");
		aa.document.write("</body>\n");
		aa.document.write("</HTML>\n");
	}
*/
}

function help_win(url) {
        win = window.open('', 'help_window', 'scrollbars=yes,resizable=yes,toolbar=no,width=670,height=600');
        //var url = "../html/help.html#help_" + num;
        win.location.href = url;
        win.focus();
}

function open_codetree(db_id, code_id)
{
	var url = "/ndli/codecgi/bin/codetree.cgi?v_dbid=" + db_id;
	if(code_id.length > 0)
		url = url + "&v_codeid=" + code_id;

	parent.left.document.location.href = url;
	document.location.href = "http://www.dlibrary.go.kr/WONMUN/Service/service_07.jsp";
}

function Check_Kwstr()
{
	var find = 0;
	for(var i=0; i < document.all.length; i++)
	{
		var field_name = "" + document.all(i).name + "";
		var pos = field_name.indexOf('v_dt_query'); 
		if(pos != -1)
		{
			if(document.all(i).value.length != 0)
				find = 1;
		}
	}
	if(find == 0)
	{
		alert("필드제한 : 검색어를 입력하시기 바랍니다.");
		return false;
	}
	return true;
}
