/* -----------------------------------------------------------------------------------
*  Description: Á¤±ÔÄ¡È¯
*  Parameters: strValue ¹®ÀÚ¿­, strReceptor ¼ö¿ë±â, strEffector ÀÛ¿ë±â
----------------------------------------------------------------------------------- */
function replaceRegExp(strValue, strReceptor, strEffector){
	var objRegExp = new RegExp(strReceptor, "gi"); //Á¤±Ô½Ä¼±¾ð
	strValue = strValue.replace(objRegExp, strEffector);
	return strValue;
}

/* -----------------------------------------------------------------------------------
*  Description: °ø¹éÁ¦°Å
*  Parameters: numType Å¸ÀÔ(0 ¿ÏÀüÁ¦°Å, 1 ÇÑÄ­À¸·ÎÁ¦°Å)
*              strValue(ÀÔ·Â°ª)
----------------------------------------------------------------------------------- */
function removeSpace(strValue, numType){
	var strEffector = ""; //ÀÛ¿ë±â
	if (parseInt(numType) > 0) strEffector = " ";
	
	strValue = strValue.replace(/^\s*/, "").replace(/\s*$/, ""); //ÀüÈÄ°ø¹éÁ¦°Å
	strValue = replaceRegExp(strValue, "\\s+", strEffector); //°ø¹éÁ¦°Å
	
	return strValue;
}

/* -----------------------------------------------------------------------------------
*  Description: Æ¯¼ö±âÈ£Á¦°Å
*  Parameters: strValue(ÀÔ·Â°ª)
----------------------------------------------------------------------------------- */
function removeMark(strValue){
	strValue = replaceRegExp(strValue, "[+@=*@<>()`\\,\\[\\]\"'\\\\]", " "); //Æ¯¼ö±âÈ£Á¦°Å
	strValue = removeSpace(strValue, 1); //°ø¹éÁ¦°Å:0(ÀüÃ¼°ø¹éÁ¦°Å),1(´Ù¼ö°ø¹éÁ¦°Å)
	
	return strValue;
}

/* -----------------------------------------------------------------------------------
*  Description: º¯¼ö ÃÊ±âÈ­
*  Parameters: strType(ÀÚ·áÇü)- 'num'
*              strValue(ÀÔ·Â°ª)
*              strInitValue(ÃÊ±â°ª)
----------------------------------------------------------------------------------- */
function checkNull(strValue, numType, strInitValue){
	if(typeof strValue == 'undefined' || strValue == null) strValue = ""; //ÃÊ±âÈ­
	if(typeof strInitValue == 'undefined' || strInitValue == null) strInitValue = ""; //±³Á¤°ªÃÊ±âÈ­
	
	if(parseInt(numType) == 1){ //¼ýÀÚÇü
		var objRegExp = /[^\d]/;
		while(objRegExp.test(strValue)) strValue = strValue.replace(objRegExp, ""); //¼ýÀÚÀÌ¿ÜÁ¦°Å
	}
	if(strValue.length == 0) strValue = strInitValue; //±³Á¤°ªÀÔ·Â
	return strValue;
}


/* -----------------------------------------------------------------------------------
*  Description: ÄíÅ°ÀúÀå
*  Parameters: strField(ÄíÅ°ÇÊµå¸í)
*              strValue(ÀÔ·Â°ª)
*              strTerm(ÄíÅ°ÀúÀå±â°£-ÀÏ±âÁØ)
----------------------------------------------------------------------------------- */
function setSrchCookie(strField, strValue, strTerm){
	var objDateExpires = new Date();
	strTerm = checkNull(strTerm, 1, "1"); //º¯¼öÃÊ±âÈ­
	objDateExpires.setTime(objDateExpires.getTime() + 1000*60*60*24*parseInt(strTerm));

	document.cookie = strField + "=" + escape(strValue) + ";expires=" + objDateExpires.toGMTString();
}



/* -----------------------------------------------------------------------------------
*  Description: ÄíÅ°ºÒ·¯¿À±â
*  Parameters: strField(ÄíÅ°ÇÊµå¸í)
----------------------------------------------------------------------------------- */
function getSrchCookie(strField){
	//ÃÊ±âÈ­
	var strValue = ""; //ÄíÅ°ÇÊµå°ª(¹ÝÈ¯°ª)
  
	strField += "=";

	if(document.cookie.length > 0) //ÄíÅ°Á¸ÀçÈ®ÀÎ
	{
		var numPointBegin = document.cookie.indexOf(strField); //ÄíÅ°ÇÊµå°ªÁ¸ÀçÈ®ÀÎ
    
		if(numPointBegin != -1)
		{
			numPointBegin += strField.length;
			numPointEnd = document.cookie.indexOf(';', numPointBegin);

			if(numPointEnd == -1)
			{
				numPointEnd = document.cookie.length;
			}
			strValue = unescape(document.cookie.substring(numPointBegin, numPointEnd)); //ÄíÅ°ÇÊµå°ªÀÔ·Â
		}
	}
	return strValue;
}

/* -----------------------------------------------------------------------------------
*  Description: ÀÌ¹ÌÁöÇÊµåº¯°æ
*  Parameters: strNode(½ÇÇà³ëµå)- 'parent.'; ''
*              strField(ÇÊµå¸í)
*              strValue(ÀÔ·Â°ª)
*              numStatus- 0(ºÒ°¡); 1(½ÇÇà)
----------------------------------------------------------------------------------- */
function changeImg(strNode, strField, strValue, numStatus){
	if(parseInt(numStatus) > 0){
		var objField = eval(strNode + "document"); //ÇÁ·¹ÀÓ¼±¾ð
		objField.images[strField].src = "/search/" + strValue; //ÀÌ¹ÌÁöº¯°æ
	}
}

/* -----------------------------------------------------------------------------------
*  Description: HTMLÇÊµåº¯°æ(innerHTML)
*  Parameters: strNode(½ÇÇà³ëµå)- 'parent.'; ''
*              strField(ÇÊµå¸í)
*              strValue(ÀÔ·Â°ª)
*              numStatus- 0(ºÒ°¡); 1(½ÇÇà)
----------------------------------------------------------------------------------- */
function changeTxt(strNode, strField, strValue){
	var objField = eval(strNode + "document.all." + strField); //ÇÊµå°´Ã¼¼±¾ð
	objField.innerHTML = strValue;
}

/* -----------------------------------------------------------------------------------
*  Description: ¹®ÀÚ¿­±æÀÌÁ¦ÇÑ
*  Parameters: strValue ÀÔ·Â°ª, numLimitLength Á¦ÇÑ±æÀÌ
----------------------------------------------------------------------------------- */
function getSubstring(strValue, limitLen, ellipsis){
	var pos = 0; //ÇöÀ§Ä¡°ÔÀÌÁö
  
	if(strValue.length > (limitLen / 2)){
		for (var i = 0; i < strValue.length; i++){
			pos += (strValue.charCodeAt(i) > 127)? 2 : 1; //2byte,1byte¹®ÀÚ
      
			if(pos > limitLen){ //Á¦ÇÑ±æÀÌÃÊ°ú½Ã
				strValue = strValue.substring(0, i) + ellipsis; //ÈÄ¹Ì»ý·«±âÈ£Ãß°¡
				break;
			}
		}
	}
	return strValue;
}

/**
*  Description: »ç¿ë¼³Á¤ÀúÀå
**/
var numAcUsed = 1; //ÀÚµ¿¿Ï¼º:0(¹Ì»ç¿ë),1(»ç¿ë)
var numAcDrt = 0; //¾Õ(0)/µÚ(1) ´Ü¾î ¸ÂÃã

function initAcOption(){
	if(numAcUsed!=1) tac.close();
	numAcUsed = parseInt(checkNull(getSrchCookie("acUsed"), 1, "1"));
	//$("acUsedField").innerHTML = (numAcUsed!=1)? "<a href='#' onclick='javascript:setAcUsed(1);'>»ç¿ë</a>" : "<a href='#' onclick='javascript:setAcUsed(0);'>²ô±â</a>";
	//$('acUsed').value = numAcUsed; //½ÇÇà¿©ºÎ°ª ÀÔ·Â
	numAcDrt = parseInt(checkNull(getSrchCookie("acDrt"), 1, "0"));	
	//$("acDrtField").innerHTML = (numAcDrt!=0)? "<a href='#' onclick='javascript:setAcDrt(0);'>Ã¹´Ü¾î ´õº¸±â</a>" : "<a href='#' onclick='javascript:setAcDrt(1);'>³¡´Ü¾î ´õº¸±â</a>";
	
	//$('query').focus();
}

function setAcUsed(numType){
	setSrchCookie("acUsed", numType, "100"); //ÄíÅ°ÀúÀå
	numAcUsed = parseInt(numType);
	initAcOption();
}

function setAcDrt(numType){
	setSrchCookie("acDrt", numType, "100"); //ÄíÅ°ÀúÀå
	numAcDrt = parseInt(numType);
	tac.get($F('qt'));
	initAcOption();
}



/**
* ÀÚµ¿¿Ï¼º ´Ü¾î È¹µæ ¹× Ãâ·Â
**/
var acListLength = 0; //ÀÚµ¿¿Ï¼º´Ü¾î¸®½ºÆ®°³¼ö
var acListPos = -1; //Ä¿¼­ÇöÀçÀ§Ä¡
function buildAcWordList(parentEl, value, query){

	query = query.toLowerCase();
	value = value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "");
	var returnValue="";
		while(parentEl.childNodes.length > 0) {
				parentEl.removeChild(parentEl.childNodes[0]);     
		}
			
	if(value.length > 0){
		
		//ÀÚµ¿¿Ï¼º È­¸éÃâ·Â
		var arrValue = value.split(","); 
		var len = acListLength = arrValue.length;
		var mistakeQuery = "";
		if(query.charCodeAt(0) < 127) mistakeQuery = assembleHangul(query);
		for(i = 0; i < len; i++){
			/*
			returnValue += "<span id='ac_aux" + i + "' ";
			returnValue += "onmouseover=\"setAcWordFocus('ac_aux" + i + "', 1)\" ";
			returnValue += "onmouseout=\"setAcWordFocus('ac_aux" + i + "', 0)\">";
			returnValue += "<a href=\"javascript:getAcSearch('" + arrValue[i] + "')\">";
			var tempValue = replaceRegExp(arrValue[i], query, G_AC_START_HL_TAG + query + G_AC_END_HL_TAG);
			if(mistakeQuery.length > 0) tempValue = replaceRegExp(tempValue, mistakeQuery, G_AC_START_HL_TAG + mistakeQuery + G_AC_END_HL_TAG);
			returnValue += tempValue;
			
			returnValue += "</a></span><br/>";
			*/
			
			var tempValue = replaceRegExp(arrValue[i], query, G_AC_START_HL_TAG + query + G_AC_END_HL_TAG);
			if(mistakeQuery.length > 0) tempValue = replaceRegExp(tempValue, mistakeQuery, G_AC_START_HL_TAG + mistakeQuery + G_AC_END_HL_TAG);
			//returnValue += tempValue;
			
			var spanEl = document.createElement("SPAN");
				spanEl.onMouseOver = function(i){setAcWordFocus('ac_aux' + i , 1);}
				spanEl.onMouseOut = function(i){setAcWordFocus('ac_aux' + i , 0);}
			var aEl = document.createElement("A");
				aEl.href = "javascript:getAcSearch('" + arrValue[i] + "')";
				aEl.innerHTML	= tempValue;	
				spanEl.appendChild(aEl);//td¿¡ ÀÌ¹ÌÁöÃß°¡
				spanEl.appendChild(document.createElement("BR"));
				parentEl.appendChild(spanEl);//tr¿¡ Ãß°¡
				
				 
		}
		acListPos = -1;

	}else{
		
		tac.close();
		//returnValue = "ÀÚµ¿¿Ï¼º ´Ü¾î°¡ ¾ø½À´Ï´Ù.";
		
	}
	//alert(returnValue);
	return returnValue;
}

function buildAcWordListXml(parentEl, xml, query){

	query = query.toLowerCase();
	xml = xml.getElementsByTagName("autokeyword");
	//value = value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "");
	var returnValue="";
		while(parentEl.childNodes.length > 0) {
				parentEl.removeChild(parentEl.childNodes[0]);     
		}
		
	if(xml.length > 0){
		
		//ÀÚµ¿¿Ï¼º È­¸éÃâ·Â
		//var arrValue = value.split(","); 
		var len = acListLength = xml.length;
		var mistakeQuery = "";
		if(query.charCodeAt(0) < 127) mistakeQuery = assembleHangul(query);
		for(i = 0; i < len; i++){
			value = xml[i].firstChild.data;
			
			value = value.toLowerCase().replace(/^\s*/, "").replace(/\s*$/, "");
			var tempValue = replaceRegExp(value, query, G_AC_START_HL_TAG + query + G_AC_END_HL_TAG);
			if(mistakeQuery.length > 0) tempValue = replaceRegExp(tempValue, mistakeQuery, G_AC_START_HL_TAG + mistakeQuery + G_AC_END_HL_TAG);
			//returnValue += tempValue;
			
			var spanEl = document.createElement("SPAN");
				spanEl.className = "autoSpan";	
				spanEl.onMouseOver = function(i){setAcWordFocus('ac_aux' + i , 1);}
				spanEl.onMouseOut = function(i){setAcWordFocus('ac_aux' + i , 0);}
			var aEl = document.createElement("A");
				aEl.href = "javascript:getAcSearch('" + value + "')";
				aEl.innerHTML	= tempValue;	
				spanEl.appendChild(aEl);//td¿¡ ÀÌ¹ÌÁöÃß°¡
				spanEl.appendChild(document.createElement("BR"));
				parentEl.appendChild(spanEl);//tr¿¡ Ãß°¡
				
				 
		}
		
		acListPos = -1;

	}else{
		
		tac.close();
		//returnValue = "ÀÚµ¿¿Ï¼º ´Ü¾î°¡ ¾ø½À´Ï´Ù.";
		
	}

	return returnValue;
}


function getAcSearch(value){

   var form = document.searchForm;
	document.getElementById('qt2').value = value;
	
	//$('searchForm').submit();
   //goSearch(form,'search');
   topSearch();
}

function setAcWordFocus(field, numType){
	
	field.style.backgroundColor = (parseInt(numType) > 0)? G_AC_BG_COLOR : "";
}

 
function setPosAcword(value, tmpListSection,tmpAutoKeywordInputId){

	try{
	
		var acListPosLast = acListPos;
		acListPos += parseInt(value);
		
		if(acListPos < 0){
			acListPos = -1;
			tac.close();
		}else{
			
			if(acListPos >= acListLength) acListPos = acListLength;
			
			tmpAutoKeywordInputId.value = tmpListSection.childNodes[acListPos].childNodes[0].innerHTML.stripTags().strip();
		
			if(acListPosLast >= 0) setAcWordFocus(tmpListSection.childNodes[acListPosLast],  0);
			setAcWordFocus(tmpListSection.childNodes[acListPos], 1);
			
			tmpListSection.scrollTop = acListPos * 20 - 60;
		}
	}catch(e){
	}
}

function a(){
	return;
}

//ÇÑ±ÛºÐÇØ Map
var firstSoundsMap = new Array(
			"¤¡", "¤¢", "¤¤", "¤§", "¤¨", "¤©", "¤±", "¤²", "¤³", "¤µ",
			"¤¶", "¤·", "¤¸", "¤¹", "¤º", "¤»", "¤¼", "¤½", "¤¾"); //ÃÊ¼º
var middleSoundsMap = new Array(
			"¤¿", "¤À", "¤Á", "¤Â", "¤Ã", "¤Ä", "¤Å", "¤Æ", "¤Ç", "¤Ç¤¿",
			"¤Ç¤À", "¤Ç¤Ó", "¤Ë", "¤Ì", "¤Ì¤Ã", "¤Ì¤Ä", "¤Ì¤Ó", "¤Ð", "¤Ñ", "¤Ñ¤Ó",
			"¤Ó"); //Áß¼º
var lastSoundsMap = new Array(
			"", "¤¡", "¤¢", "¤¡¤µ", "¤¤", "¤¤¤¸", "¤¤¤¾", "¤§", "¤©", "¤©¤¡",
			"¤©¤±", "¤©¤²", "¤©¤µ", "¤©¤¼", "¤©¤½", "¤©¤¾", "¤±", "¤²", "¤²¤µ", "¤µ",
			"¤¶", "¤·", "¤¸", "¤º", "¤»", "¤¼", "¤½", "¤¾"); //Á¾¼º

//ÇÑ±ÛÁ¶ÇÕ Map
var firstSoundsEngMap = new Array(
			"r", "R", "s", "e", "E", "f", "a", "q", "Q", "t",
			"T", "d", "w", "W", "c", "z", "x", "v", "g"); //ÃÊ¼º

var middleSoundsEngMap = new Array(
			"k", "o", "i", "O", "j", "p", "u", "P", "h", "hk", 
			"ho", "hl", "y", "n", "nj", "np", "nl", "b", "m", "ml",
			"l"); //Áß¼º

var lastSoundsEngMap = new Array(
			"","r", "R", "rt", "s", "sw", "sg", "e", "f", "fr", "fa",
			"fq", "ft", "fx", "fv", "fg", "a", "q", "qt", "t", "T",
			"d", "w", "c", "z", "x", "v", "g"); //Á¾¼º


/**
* ÇÑ±ÛºÐÇØ
* @param strValue ÀÔ·Â°ª, numAcDrt ¹æÇâ(0 ¾çÂÊ, 1 Á¤¹æ, 2 ¿ª¹æ)
**/
function disassembleHangul(strValue, numAcDrt){
	var ordinaryVal = ""; //ÇÑ±ÛºÐÇØ Á¤¹æ
	var reverseVal = ""; //ÇÑ±ÛºÐÇØ ¿ª¹æ
	var tempVal = "";
	strValue = removeSpace(removeMark(strValue), 0);				
	
	for(var i = 0; i < strValue.length; i++){
		var numCharValue = (strValue.charCodeAt(i) - 0xAC00); //44032
		
		if(numCharValue < 0 || numCharValue > 11172){ //ÇÑ±ÛÀÌ¿Ü ¹× ÇÑ±ÛÀÚÀ½ Ã³¸®
			tempVal = strValue.charAt(i);

		}else{ //ÇÑ±Û Ã³¸®
			tempVal = firstSoundsMap[Math.floor(numCharValue / 588)];
			tempVal += middleSoundsMap[Math.floor((numCharValue % 588) / 28)];
			tempVal += lastSoundsMap[Math.floor((numCharValue % 588) % 28)];
		}
		
		ordinaryVal += tempVal;
		reverseVal = tempVal + reverseVal;
	}
	
	switch(parseInt(numAcDrt)){
		case 0:
			//strValue = "<word>" + ordinaryVal + "<in>acField";
			strValue = ordinaryVal;
		break;
		case 1:
			//strValue = "<word>" + reverseVal + "<in>acFieldR";
			strValue = reverseVal;
		break;
		default:
			//strValue = "<word>" + ordinaryVal + "<in>(acField,acFieldR)";
			strValue = ordinaryVal;
		break;
	}
	
	return strValue;
}

function disassembleHangul2(strValue, numAcDrt){
	var ordinaryVal = ""; //ÇÑ±ÛºÐÇØ Á¤¹æ
	var reverseVal = ""; //ÇÑ±ÛºÐÇØ ¿ª¹æ
	var tempVal = "";
	strValue = removeSpace(removeMark(strValue), 0);				
	for(var i = 0; i < strValue.length; i++){
		var numCharValue = (strValue.charCodeAt(i) - 0xAC00); //44032
		if(numCharValue < 0 || numCharValue > 11172){ //ÇÑ±ÛÀÌ¿Ü ¹× ÇÑ±ÛÀÚÀ½ Ã³¸®
			tempVal = strValue.charAt(i);

		}else{ //ÇÑ±Û Ã³¸®
			tempVal = firstSoundsEngMap[Math.floor(numCharValue / 588)];
			tempVal += middleSoundsEngMap[Math.floor((numCharValue % 588) / 28)];
			tempVal += lastSoundsEngMap[Math.floor((numCharValue % 588) % 28)];
		}
		ordinaryVal += tempVal;
		reverseVal = tempVal + reverseVal;
	}
	
	switch(parseInt(numAcDrt)){
		case 0:
			//strValue = "<word>" + ordinaryVal + "<in>acField";
			strValue = ordinaryVal;
		break;
		case 1:
			//strValue = "<word>" + reverseVal + "<in>acFieldR";
			strValue = reverseVal;
		break;
		default:
			//strValue = "<word>" + ordinaryVal + "<in>(acField,acFieldR)";
			strValue = ordinaryVal;
		break;
	}
	return strValue;
}

String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/gi, ""); 
} 
String.prototype.strip = function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
String.prototype.stripTags = function() {
    return this.replace(/<\/?[^>]+>/gi, '');
}


function assembleHangul(strValue){
	// º¯¼ö ÃÊ±âÈ­
	var firstSoundsEngMapCode = 0;
	var middleSoundsEngMapCode  = 0;
	var lastSoundsEngMapCode   = 0;
	
	var resultValue = "";

	for(var idx=0; idx<strValue.length; idx++){
		
		//ÃÊ¼º
		firstSoundsEngMapCode = getHangulCode('firstSoundsEngMap', strValue.substring(idx, idx+1));
		idx++;
		
		//Áß¼º
		tempMedialCode = getHangulCode('middleSoundsEngMap', strValue.substring(idx, idx+2));

		if( tempMedialCode != -1 ){
			middleSoundsEngMapCode = tempMedialCode;
			idx += 2;

		}else{
			middleSoundsEngMapCode = getHangulCode('middleSoundsEngMap', strValue.substring(idx, idx+1));
			idx++;
		}

		//Á¾¼º
		tempFinalCode = getHangulCode('lastSoundsEngMap', strValue.substring(idx, idx+2));

		if( tempFinalCode != -1){
			lastSoundsEngMapCode = tempFinalCode;
			tempMedialCode = getHangulCode('middleSoundsEngMap', strValue.substring(idx+2, idx+3));
	
			if( tempMedialCode != -1){
				lastSoundsEngMapCode = getHangulCode('lastSoundsEngMap', strValue.substring(idx, idx+1));
			}else{
				idx++;
			}
		}else{
			tempMedialCode = getHangulCode('middleSoundsEngMap', strValue.substring(idx+1, idx+2));
	
			if( tempMedialCode != -1 ){
				lastSoundsEngMapCode = 0;
				idx--;
			}else{
				lastSoundsEngMapCode = getHangulCode( 'lastSoundsEngMap', strValue.substring( idx, idx + 1 ) );
				if( lastSoundsEngMapCode == -1 ) lastSoundsEngMapCode = 0;
			}
		}
	
		resultValue += String.fromCharCode(0xAC00 + firstSoundsEngMapCode + middleSoundsEngMapCode + lastSoundsEngMapCode);
	}
	
	return resultValue;
}

function getHangulCode( type, char ){
	var returnCode; // ¸®ÅÏ ÄÚµå ÀúÀå º¯¼ö
	var isFind = false; // ¹®ÀÚ¸¦ Ã£¾Ò´ÂÁö Ã¼Å© º¯¼ö

	if( type == 'firstSoundsEngMap' ){
		for( var i = 0; i < firstSoundsEngMap.length; i++ ){
			if( firstSoundsEngMap[i] == char ){
				returnCode = i * 21 * 28;
				isFind = true;
				break;
			}
		}
	}else if( type == 'middleSoundsEngMap' ){
		for( var i = 0; i < middleSoundsEngMap.length; i++ ){
			if( middleSoundsEngMap[i] == char ){
				returnCode = i * 28;
				isFind = true;
				break;
			}
		}
	}else if( type == 'lastSoundsEngMap' ){
		for( var i = 0; i < lastSoundsEngMap.length; i++ ){
			if( lastSoundsEngMap[i] == char ){
				returnCode = i + 1;
				isFind = true;
				break;
			}
		}
	}
	if( isFind == false ) returnCode = -1; // °ªÀ» Ã£Áö ¸øÇßÀ» °æ¿ì -1 ¸®ÅÏ
	return returnCode;
}

function localSearchResultClick(num) {
	var objMenu = document.getElementById("search_tab_menu").getElementsByTagName("li");
	var objNum = objMenu.length;
	for ( var i=0; i<objNum; i++ ) {
		if(num==0){
			if(i==0){
				objMenu.item(i).className = "off";
			}else{
				objMenu.item(i).className = "on";
			}
			document.getElementById("SearchResultLayout_"+i).style.display = "block";
		}else{
			if ( i == num ) {
				objMenu.item(i).className = "on";
				document.getElementById("SearchResultLayout_"+i).style.display = "block";
			} else {
				objMenu.item(i).className = "off";
				document.getElementById("SearchResultLayout_"+i).style.display = "none";
			}
		}
	}
}

// search + advanced
function localAdvancedSearchClick() {
	var obj = document.getElementById("AdvancedSearchForm");
	if(obj.style.display=="none"){
		obj.style.display = "block";
		document.searchForm.advance.value="Y";
	}else if(obj.style.display==""){
		obj.style.display = "block";
		document.searchForm.advance.value="Y";
	}else{
		obj.style.display = "none";
		document.searchForm.advance.value="N";
	}
}

function localCommunityTypeClick(obj) {
	var objType = document.getElementById("Communitydocstype");
	if ( obj.checked ) {
		objType.style.display = "block";
	} else {
		objType.style.display = "none";
	}
}



function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

var Class = {
			  create: function() {
			    return function() {
			      this.initialize.apply(this, arguments);
			    }
			  }
			}

var lastQuery = "";
var TAutoComplete = Class.create();

TAutoComplete.prototype = {
	initialize: function(listSection, autoSearchDiv, autoKeywordInputId) {
		
		//var searchDivs = document.getElementById("searchDiv");
		//var divEl = document.createElement("DIV");
		//divEl.id = listSection;
		//divEl.className = "con";
		//divEl.style.display = "none";
		//searchDivs.appendChild(divEl);//tr¿¡ Ãß°¡
		this.listSection = document.getElementById(listSection);
		this.autoSearchDiv = document.getElementById(autoSearchDiv);
		this.autoKeywordInputId = document.getElementById(autoKeywordInputId);
		
		this.listSection.style.display = "none";
		this.autoSearchDiv.style.display = "none";

			
		initAcOption();
	},
		
	get: function(value, tmplistSection){
		value = value.replace(/^\s*/, "").replace(/\s*$/, "");
		
		var listSection = this.listSection;
		var autoSearchDiv = this.autoSearchDiv;
	
		if(lastQuery==value) return;
		
		if(value==""){
			lastQuery = value;
			tmplistSection.style.display = "none";
			return;
		}
		
		
		
		
		lastQuery = value;
		var url = xmlSrc;
		var pars = 'callMethod=getAutoKeyword&direction=/jsp/autocomplete/autokeywords.jsp&query=' + disassembleHangul2(value, numAcDrt)+'&acGubun='+numAcDrt;
		//var pars = 'callMethod=getAutoKeyword&direction=/jsp/search/autokeywords.jsp&query=' + disassembleHangul2(value)+'&acGubun='+numAcDrt;
		//if(value.charCodeAt(0) < 127) pars += "<or>" + disassembleHangul(assembleHangul(value), numAcDrt);
	    createXMLHttpRequest();
	    
	    xmlHttp.onreadystatechange = function(){
	    								
	    									 if(xmlHttp.readyState == 4) {
	    									    if(xmlHttp.status == 200 || xmlHttp.status == 0) {
	    									    	
										       			 	xml =  xmlHttp.responseXML.getElementsByTagName("autokeyword");
										   	         if( xmlHttp.responseXML && xml.length > 0){
										    		        
										    		        
										    		       
										    		        buildAcWordListXml(listSection,xmlHttp.responseXML, value);
													        
													       	autoSearchDiv.style.display = "";		
																	tmplistSection.style.display = "";
																
																	
																 }else{
																 		
																 	tmplistSection.style.display = "none";
																
																 	autoSearchDiv.style.display = "none";
																 	
																 }
																 
													        }else{
													        
													        	//alert(xmlHttp.status );
													        }
													     }
	    									
	    									};
	    
	    xmlHttp.open("post", url, true);
	    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    xmlHttp.setRequestHeader("Accept","text/xml"); 
	    xmlHttp.send(pars); 
		
		initAcOption();
	},
		
	open: function(e, arg){
		
		//if(numAcUsed != 1) return;
		var query = this.autoKeywordInputId.value;
	
		//if(!Element.visible(this.layerSection) && query.length > 0){
		//	Element.show(this.layerSection);
		//}
		
		//var key = (window.netscape) ? event.which : event.keyCode ;
		var key = e.which || e.keyCode;
		
		switch (key) {
			case 27:
				this.close();
				break;
			case 38:
			case 37:
				if(acListLength > 0 && parseInt(arg) == 1) setPosAcword(-1,this.listSection,this.autoKeywordInputId);
				break;
			case 40:
			case 39:
				
				if(acListLength > 0 && parseInt(arg) == 1) setPosAcword(1,this.listSection,this.autoKeywordInputId);
				break;
			default:
			if( parseInt(arg) == 0){
				this.get(this.autoKeywordInputId.value,this.listSection);
				
				}
				break;
				/*
			case Event.KEY_ESC:
				this.close();
				break;
			case Event.KEY_UP:
			case Event.KEY_LEFT:
				if(acListLength > 0 && parseInt(arg) == 1) setPosAcword(-1);
				break;
			case Event.KEY_DOWN:
			case Event.KEY_RIGHT:
				if(acListLength > 0 && parseInt(arg) == 1) setPosAcword(1);
				break;
				*/
			
				
		}
		
	},
		
	open_abs: function(){
		var query = this.autoKeywordInputId.value;
		if(this.listSection.style.display == "none" ){
			this.listSection.style.display = "";
		}
		//if(!Element.visible(this.layerSection)){
		//	Element.show(this.layerSection);
		//}
		
		if(query.length > 0) this.get(this.autoKeywordInputId.value);
	},
	
	close: function(){
		//if(Element.visible(this.layerSection)){
		//	Element.hide(this.layerSection);
		//}
		if(this.listSection.style.display == "" ){
			this.listSection.style.display = "";
		}
	}	
};


//¿£ÅÍ°Ë»ö - ÆÄÀÌ¾îÆø½º ÃÖÀûÈ­ 
function enterSearch(evt){
        var evCode = (window.netscape) ? evt.which : event.keyCode ;
        if(evCode == 13){
            startSearch();
        }else if(evCode == 10){
       		startSearch();
		}
}



function clearVal(str){
	var inputQr =document.getElementById(str);
	if(inputQr.value=="Enter a Keyword" || inputQr.value=="Enter a Keyword" ){
		inputQr.value="";
		
	}
}



/***************************************************************************************/
/*	°Ë»ö¾î ÀÚµ¿¿Ï¼º Ver 1.0(Pure javascript)																			
/*	Á¦ ÀÛ ÀÏ : 2008/08/27
/*	Á¦	 ÀÛ: ¿¬±¸2ÆÀ ÃÖÁ¦È«
/*	
/***************************************************************************************/

var observeAutoArea=0; // ÀÚµ¿¿Ï¼º°Ë»ö¾î ·¹ÀÌ¾î display »óÅÂ °ªÀ» ÀúÀå
var observeAutoArea2=0; // ÀÚµ¿¿Ï¼º°Ë»ö¾î ·¹ÀÌ¾î display »óÅÂ °ªÀ» ÀúÀå
var autoKeywordInputId = "qt"; // °Ë»ö¹Ú½º id
var autoKeywordDisplayId = "tacList";// ÀÚµ¿¿Ï¼º°Ë»ö¾î display ·¹ÀÌ¾î id
var autoKeywordInputId2 = "qt2"; // °Ë»ö¹Ú½º id2
var autoKeywordDisplayId2 = "tacList2";// ÀÚµ¿¿Ï¼º°Ë»ö¾î display ·¹ÀÌ¾î id2



var G_AC_WORD_LENGTH = 40;
var G_AC_START_HL_TAG = "<font color=#b85c2e>";
var G_AC_END_HL_TAG = "</font>";
var G_AC_BG_COLOR = "#EFEFEF";
//var xmlSrc = '/cyber/jsp/search/autokeywords.jsp';
//var xmlSrc = '/cyber/search/CyberSearchManager.Svlt';
//var xmlSrc = '/cyber/jsp/search/autokeywords.jsp';
var xmlSrc = '/servlets/CyberSearchManagerSvlt';

function addEvent(obj, type, fn)   
{   
    if (obj.addEventListener)   
        obj.addEventListener(type, fn, false);   
    else if (obj.attachEvent)   
    {   	
        obj["e"+type+fn] = fn;   
        obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }   
        obj.attachEvent("on"+type, obj[type+fn]);   
    }   
}  
//target¿¡ ÇØ´çµÇ´Â display¸¦ ´Ý´Â´Ù.
function displayoutLayer(_target, observeAutoAreaValue){
	target = document.getElementById(_target);
	if(target && observeAutoAreaValue == "0")
	{	
		target.style.display = "none";
	}
}


var autoInit =  function(){

	if(document.getElementById(autoKeywordInputId)){
		tac = new TAutoComplete(autoKeywordDisplayId, "autoSearch1", autoKeywordInputId);
		
		var qt = document.getElementById(autoKeywordInputId); // °Ë»ö¾î Input
	 	var dispDiv = document.getElementById(autoKeywordDisplayId); // °Ë»ö¾î display
	 	
	 	qt.AutoComplete = "off";
	 	
	 		if(navigator.userAgent.indexOf("MSIE")!=-1){ // ºê¶ó¿ìÀúº° À§Ä¡¼¼ÆÃ
		 
			}else{
	
	   	 	document.getElementById(autoKeywordDisplayId).style.display = "none";
	   	 	
			}
			
		 displayoutLayer(autoKeywordDisplayId, observeAutoArea);

		 addEvent(qt, 'keydown', function(e){tac.open(e , 1);enterSearch(e);});  
	 	addEvent(qt, 'keyup', function(e){tac.open(e , 0);});  
	 	addEvent(qt, 'blur', function(e){displayoutLayer(autoKeywordDisplayId);});  
	 	addEvent(qt, 'focus', function(e){displayoutLayer(autoKeywordDisplayId2, observeAutoArea2);clearVal(autoKeywordInputId);});  
	 	addEvent(qt, 'focus', function(e){displayoutLayer(autoKeywordDisplayId2, observeAutoArea2);clearVal(autoKeywordInputId);});  
	 	addEvent(dispDiv, 'mouseover', function(e){observeAutoArea=1;});  
	 	addEvent(dispDiv, 'mouseout', function(e){observeAutoArea=0;});  
	 	
	}
	 
	if(document.getElementById(autoKeywordInputId2)){
	tac2 = new TAutoComplete(autoKeywordDisplayId2, "autoSearch2", autoKeywordInputId2);
	 
	 var qt2 = document.getElementById(autoKeywordInputId2); // °Ë»ö¾î Input
	 var dispDiv2 = document.getElementById(autoKeywordDisplayId2); // °Ë»ö¾î display

	
	 qt2.AutoComplete = "off";
	
		if(navigator.userAgent.indexOf("MSIE")!=-1){ // ºê¶ó¿ìÀúº° À§Ä¡¼¼ÆÃ
		 
		}else{

			 document.getElementById(autoKeywordDisplayId2).style.display = "none";
		}
	 
	 displayoutLayer(autoKeywordDisplayId2, observeAutoArea2);
	 addEvent(qt2, 'keydown', function(e){tac2.open(e , 1);enterTopSearch(e);});  
	 addEvent(qt2, 'keyup', function(e){tac2.open(e , 0);});  
	 addEvent(qt2, 'blur', function(e){displayoutLayer(autoKeywordDisplayId2);});  
	 addEvent(qt2, 'focus', function(e){displayoutLayer(autoKeywordDisplayId, observeAutoArea);clearVal(autoKeywordInputId2);});  
	 addEvent(qt2, 'focus', function(e){displayoutLayer(autoKeywordDisplayId, observeAutoArea);clearVal(autoKeywordInputId2);});  
	 addEvent(dispDiv2, 'mouseover', function(e){observeAutoArea2=1;});  
	 addEvent(dispDiv2, 'mouseout', function(e){observeAutoArea2=0;});  
	}
	
}
addEvent(window, 'load', autoInit);  


