// 전문용어확장 div 화면입니다.
var docHTML = "";
docHTML +="<div id=\"div_word1\" style=\"left:420px; top:0px; width: 0px; position: relative; height:0px;\" onmouseleave=\"//MM_showHideLayers('div_word1','','hide','div_word2','','hide','div','','hide','div2','','hide')\">";
docHTML +="<iframe id=\"DivShim\" src=\"\" scrolling=\"no\" frameborder=0 style=\"position:absolute; top:0px; left:0px;width:256px; height:213px; display:none;\" title=\"다국어 전무용어 확장기\"></iframe>";
docHTML +="<div id=\"div_word2\" class=\"manylang\">";

docHTML +="				<h1 class=\"dsear\"><img src=\"/img/common/top_title.gif\" alt='다국어 전문용어 확장기' border=\"0\" usemap=\"#ExtendMap\"></h1>";
docHTML +="<div class=\"junmun\">";
docHTML +="				<div class=\"graydic\">";

docHTML +="					<span class=\"style1\" id=\"eSearchText\"></span>";

docHTML +="				</div>";

docHTML +="				<div class=\"mgb_10 center\" id=\"subjectSet\">";
docHTML += "<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >";
docHTML +="<tr>";
docHTML +="<td align=\"center\"><img src=\"/img/patent/loading.gif\" width=\"28\" height=\"28\" alt=''></td>";
docHTML +="</tr>";
docHTML +="</table>";
docHTML +="				</div>";

docHTML +="				<div class=\"mgb_10\">";
docHTML +="						<a href=\"javascript:gf_sendQueryString();\" title='선택'><img src=\"/img/common/btn_choice.gif\" alt='선택' border='0' style=\"cursor:pointer\"></a>";
docHTML +="						<a href=\"javascript:gf_closeQueryString();\" title='취소'><img src=\"/img/common/btn_cancel.gif\" alt='취소' border='0' style=\"cursor:pointer\"></a>";
docHTML +="				</div>";

docHTML +="						<div class=\"graywiki\" id=\"resultSet\">";
docHTML += "<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >";
docHTML +="<tr>";
docHTML +="<td align=\"center\"><img src=\"/img/patent/loading.gif\" width=\"28\" height=\"28\" alt=''></td>";
docHTML +="</tr>";
docHTML +="</table>";
docHTML +="						</div>";
docHTML +="</div>";

docHTML +="<map name=\"ExtendMap\">";
docHTML +="<area shape=\"rect\" coords=\"252,6,268,20\"";
docHTML +=" href=\"javascript:MM_showHideLayers('div_word1','','hide','div_word2','','hide','div','','hide','div2','','hide')\" alt='닫기'>";
docHTML +="</map>";
docHTML +="</div>";
docHTML +="</div>";


function cgf_ExtendQueryClick(){
	var sText = document.getElementById("search_form_query0").value;
	sText = gf_Trim(sText,'a');
	if(sText == "") {
	  	alert("검색어를 넣은 후에 이용하세요.");
	  	//document.getElementById("search_form_query0").focus();
	  	//return;
  	} else {
		
		var oExtendQuery=document.getElementById("ExtendQuery");
		if(oExtendQuery != null){
			oExtendQuery.innerHTML = docHTML;
		}
		DivSetVisible(true);
		
		if(sText.indexOf("|") > -1){
			var arrTxt = sText.split("|");
			sText = Replace(arrTxt[0],"\"","");
			sText = gf_Trim(sText,'a');
		}
		gf_extendQuery(sText);
	}
}

//=================================
//cgf_ExtendQueryClick() 
function logsave_cgf_ExtendQueryClick(){
	var sText = document.getElementById("search_form_query0").value;
	sText = gf_Trim(sText,'a');
	if(sText == "") {
	  	alert("검색어를 넣은 후에 이용하세요.");
	  	//document.getElementById("search_form_query0").focus();
	  	//return;
  	} else {
		var oExtendQuery=document.getElementById("ExtendQuery");
		
		// 2010.02.04. 김진성. style의 visible은 공간을 차지하기 때문에 display값을 변경하도록 수정.
		oExtendQuery.style.display = '';
		
		if(oExtendQuery != null){
			oExtendQuery.innerHTML = docHTML;
		}
		DivSetVisible(true);
		
		if(sText.indexOf("|") > -1){
			var arrTxt = sText.split("|");
			sText = Replace(arrTxt[0],"\"","");
			sText = gf_Trim(sText,'a');
		}
		
		//=================================
		f_logsave_specialterm_exp(1);
		//=================================

		gf_extendQuery(sText);
	}
}

function gf_extendQuery(sText) {
	// var f = document.portalForm;
	// var sText = f.searchText.value;
 
	var wikilink = "";
	var arrStr = sText.split(" ");
	if(CheckHangul(arrStr[0])){
		wikilink= "http://ko.wikipedia.org/wiki/";
	} else {
		 wikilink= "http://en.wikipedia.org/wiki/";
	}
	var sLinkHtml = "&nbsp;<a href=\"javascript:gf_NaverOpen('" + sText + "');\" title=\"Naver 새창\"><img src=\"/img/common/btn_dic.gif\" alt=\"Naver Dic\" border=\"0\" style=\"cursor:pointer\"></a>&nbsp;";
	sLinkHtml += "<a href=\"" + wikilink + sText +"\" target=\"_blank\" title=\"WIKI 새창\"><img src=\"/img/common/btn_wiki.gif\" border=\"0\" alt=\"WIKI\" ></a>";

 	var eText = document.getElementById("eSearchText").innerHTML = sText + sLinkHtml;

	var url = '/servlet/extend?keyword=' + encodeURIComponent(sText.toLowerCase());
	var method = 'GET';

	sendExtendQueryRequest(url, null, method);

	MM_showHideLayers('div_word1','','show','div_word2','','show','div','','show','div2','','show');
}

function gf_NaverOpen(as_keyword) {
	//var url = "/jsp/portal/include/naver_openapi.jsp?keyword=" + encodeURIComponent(as_keyword);
	var url = "/jsp/portal/include/naver_openapi.jsp?keyword=" + as_keyword;
	window.open(url,"NaverOpenAPI", "width=850,height=680,scrollbars=yes, status=yes, resizeable=yes, menubar=yes,toolbar=yes, location=yes");
}

function gf_sendQueryString() {
	var checkbox = document.getElementsByName("strValue");
	var f = document.portalForm;
	var sText = "\"" + document.getElementById("search_form_query0").value +"\"";
	var checkedCount = 0;
  
	for (var i = 0; i < checkbox.length; i++) {
		if (checkbox[i].checked) {
			if (checkedCount > 0) {
				sText += " | ";
			} else if(sText !="") {
				sText += " | ";
			}
			sText += "\"" + checkbox[i].value + "\"";
			checkedCount++;
		}
	}

	//f.searchText.value = sText;
	document.getElementById("search_form_query0").value = sText;
	lf_sliderhide();

	//=================================
	f_logsave_specialterm_exp(2);
	//=================================
		
}

function gf_closeQueryString(){
	lf_sliderhide();
	//=================================
	f_logsave_specialterm_exp(3);
	//=================================
}

// 검색어 자동완성 보이기_old
function lf_sliderhide(){
	MM_showHideLayers('div_word1','','hide','div_word2','','hide','div','','hide','div2','','hide');
}

function DivSetVisible(state) {
	var DivRef = document.getElementById('div_word2');
	var DivAuto= document.getElementById('completion_tooltip0');
	var IfrRef = document.getElementById('DivShim');
	if(DivRef != null || DivRef != undefined){
		if(state) {
			DivRef.style.display = "block";
			// DivAuto.style.display = "block";
			IfrRef.style.width = DivRef.offsetWidth;
			IfrRef.style.height = DivRef.offsetHeight;
			IfrRef.style.top = DivRef.style.top;
			IfrRef.style.left = DivRef.style.left;
			IfrRef.style.zIndex = DivRef.style.zIndex - 1;
			IfrRef.style.display = "block";
		} else {
			// DivRef.style.display = "none";
			DivAuto.style.display = "none";
			IfrRef.style.display = "none";
		}
	}
}
  
