var AKCSearchReq = false;
var AKCSearchLast = "";
var AKCUse = true;
	
var isIE = false;
var sQuery="";
var eQuery="";
var is_suf=2;
var is_suf_last=2;

var t = null;
var count=0;

var frm;

// on !IE we only have to initialize it once
if (window.XMLHttpRequest)
{
	try
	{
		AKCSearchReq = new XMLHttpRequest();		
	}
	catch (e)
	{
		try
		{			
			AKCSearchReq = new ActiveXObject('Msxml2.XMLHTTP')
		}
		catch (e)
		{
			AKCSearchReq = new ActiveXObject('Microsoft.XMLHTTP')
		}
	}
}

//////////////////////////
function log(msg) 
{
	return;
	var msgArea = document.getElementById('msgArea');

	msgArea.value = msgArea.value + count +":"+ msg + '\n';
	count++;
}
/////////////////////////


function AKCSearchInit(v_frm)
{
log("AKCSearchInit");
	AKCChangeArrow(0);
	
	if(AKCUse==true)//ÄíÅ°°ªÀ» ÀÐ¾î ¿À´Â ·çÆ¾ »ðÀÔ
	{
		if (navigator.userAgent.indexOf("Safari") > 0)
		{
			document.getElementById('AKCSearch').addEventListener("keydown", AKCSearchKeyPress,false);
//			document.getElementById('AKCSearch').addEventListener("blur", AKCSearchHide,false);
		}
		else if(navigator.product == "Gecko")
			{
				document.getElementById('AKCSearch').addEventListener("keypress", AKCSearchKeyPress,false);
//				document.getElementById('AKCSearch').addEventListener("blur", AKCSearchHideDelayed,false);
		
			}
			else
			{
				document.getElementById('AKCSearch').attachEvent("onkeydown", AKCSearchKeyPress);
//				document.getElementById('AKCSearch').attachEvent("onblur", AKCSearchHide,false);
				document.getElementById('AKCSearch').attachEvent("onmousedown", AKCSearchKeyPress);
				isIE = true;
			}

		frm = v_frm;
		document.getElementById('AKCSearch').setAttribute("autocomplete","off");
	}

}

function AKCSearchHideDelayed()
{
log("AKCSearchHideDelayed");	
	window.setTimeout("AKCSearchHide()",400);

}

function AKCChangeArrow(flag)
{
log("AKCChangeArrow");
	if(flag==0)
		document.getElementById("AKCResult").style.display = "none";
		//document.getElementById("AKCResult").style.display = "";
	else
		document.getElementById("AKCResult").style.display = "none";
		//document.getElementById("AKCResult").style.display = "";
	var  Lt = AKCLayerTopId('AKCArrow'); 
	Lt.innerHTML = AKCMakeArrow(flag);

	return;
}
	
function AKCSearchHide()
{
log("AKCSearchHide");
	if(AKCSearchLast!=document.SearchForm.kwd.value)
	{
		AKCSearchLast=document.SearchForm.kwd.value;
		sQuery=document.SearchForm.kwd.value;
	}					

	AKCChangeArrow(0);

//	document.getElementById("AKCResult").style.display = "none";
	var highlight = document.getElementById("AKCHighlight");
	if (highlight)
	{
		highlight.removeAttribute("id");
	}

}

function AKCMouseOutMove(id)
{
log("AKCMouseOutMove");
	highlight = document.getElementById(id);
	highlight.removeAttribute("id");

}

function AKCMouseOverMove(obj) 
{
log("AKCMouseOverMove");	
	highlight = document.getElementById("AKCHighlight");

	if (highlight) {
		
		highlight.removeAttribute("id");
	}

	if (obj) {
		obj.setAttribute("id","AKCHighlight");
	}

}

function AKCSearchKeyPress(event)
{
log("AKCSearchKeyPress");


	var keyup="";
	if(document.getElementById("AKCResult").style.display=="none")
	{

		AKCSearchStart();
		return;
	}
	
	if (event.keyCode == 40 )//KEY DOWN
	{

		highlight = document.getElementById("AKCHighlight");

		if (!highlight)
		{
			highlight = document.getElementById("AKCShadow").firstChild.firstChild;

			if (highlight.getAttribute('value')!='0')
			{
				highlight.setAttribute("id","AKCHighlight");
				AKCSearchLast = highlight.getAttribute('value');
				document.SearchForm.kwd.value = highlight.getAttribute('value');

			}
		}
		else
		{
			highlight.removeAttribute("id");
			highlight = highlight.nextSibling;
			if (highlight)
			{
				highlight.setAttribute("id","AKCHighlight");
				AKCSearchLast = highlight.getAttribute('value');
				document.SearchForm.kwd.value = highlight.getAttribute('value');
			}
			else
			{
				highlight = document.getElementById("AKCShadow").firstChild.lastChild;
				highlight.setAttribute("id","AKCHighlight");
				AKCSearchLast = document.getElementById("AKCHighlight").getAttribute('value');
				document.SearchForm.kwd.value = document.getElementById("AKCHighlight").getAttribute('value');
			}
		}
		 
		if (!isIE)
		{
			event.preventDefault();
		}
	} 
	else if (event.keyCode == 38 )//KEY UP
		{
			keyup="";
			highlight = document.getElementById("AKCHighlight");
			if (!highlight)
			{
				highlight = document.getElementById("AKCShadow").firstChild.lastChild;
				keyup="up";

			} 
			else
			{
				highlight.removeAttribute("id");
				highlight = highlight.previousSibling;

			}
		
			if (highlight)
			{
				if(keyup=="up")
				{
					highlight.removeAttribute("id");
					highlight = highlight.previousSibling;

				AKCChangeArrow(0);
				}
				else
				{
					highlight.setAttribute("id","AKCHighlight");
					AKCSearchLast = document.getElementById("AKCHighlight").getAttribute('value');
					document.SearchForm.kwd.value = document.getElementById("AKCHighlight").getAttribute('value');

				}

			}
			else
			{
				AKCChangeArrow(0);
			}
			
			if (!isIE)
			{
				event.preventDefault();
			}
		} 
		else if (event.keyCode == 27)//ESC
			{
				highlight = document.getElementById("AKCHighlight");
				if (highlight)
				{
					highlight.removeAttribute("id");

				}
//				document.getElementById("AKCResult").style.display = "none";
				AKCChangeArrow(0);
			}

	
}


function AKCUpDown(event)
{
log("AKCUpDown");

	if (event.keyCode == 40 )//KEY DOWN
	{
		
		if(document.getElementById("AKCResult").style.display=="none")
		
			return true;
		else
			return false;
		
	} 
	else if (event.keyCode == 38 )//KEY UP
		{
			
			return false;
		} 
	else if (event.keyCode == 27)//ESC
		{
			return false;
		}

	return true;
}


function AKCSearchStart()
{
log("AKCSearchStart");
log(AKCUse);
	
	if(AKCUse==true)//ÄíÅ°°ªÀ» ÀÐ¾î ¿À´Â ·çÆ¾ »ðÀÔ
	{

		sQuery=document.SearchForm.kwd.value;

		if(t)
		{
			window.clearTimeout(t);
		}
	
		if(AKCUpDown(event)==true)
			t = window.setTimeout("AKCSearchDoSearch()",200);
	}

}

function AKCSearchDoSearch()
{
log("AKCSearchDoSearch");
	
	if(document.SearchForm.kwd.value!=AKCSearchLast)
	{
		is_suf_last=is_suf;
		is_suf=2;//°Ë»ö ÃÊ±âÈ­
	}
	
	if (typeof AKCSearchRoot == "undefined") {
		AKCSearchRoot = "";
	}
	
	if (typeof AKCSearchRootSubDir == "undefined") {
		AKCSearchRootSubDir = "";
	}
	
	if (typeof AKCSearchParams == "undefined") {
		AKCSearchParams2 = "";
	}
	else
	{
		AKCSearchParams2 = "&" + AKCSearchParams;
	}

	if ((AKCSearchLast != document.SearchForm.kwd.value)
	||  (is_suf_last!=is_suf))
	{
		if (AKCSearchReq && AKCSearchReq.readyState < 4)
		{
			AKCSearchReq.abort();
		}
		if ( document.SearchForm.kwd.value == "")
		{
			AKCSearchHide();
			return false;
		}
	
		if (window.XMLHttpRequest)
		{
		// branch for IE/Windows ActiveX version
		}
		else if (window.ActiveXObject)
			{
				AKCSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
		
		var searchStr = escape(document.SearchForm.kwd.value);
		searchStr = searchStr.replace("'","||");
	
		AKCSearchReq.onreadystatechange= AKCSearchProcessReqChange;
		
		// !!¼öÁ¤ÇØ¾ßÇÒ ºÎºÐ!!
		AKCSearchReq.open("GET", AKCSearchRoot + "/common/lib/search/akc_KS.asp" + "?q=" + searchStr + "&s=" + is_suf);

		AKCSearchLast = document.SearchForm.kwd.value;

		AKCSearchReq.send(null);
	}
	else
	{
		AKCChangeArrow(1);
		
	}

}

function AKCSearchProcessReqChange()
{
log("AKCSearchProcessReqChange");
	if (AKCSearchReq.readyState == 4) 
	{
		var  res = document.getElementById("AKCResult");
		var  hd = document.getElementById("AKCControl");
		var  sh = document.getElementById("AKCShadow");
		var  control = AKCMakeHeader();
		var  body = "";
		var  header="<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
		     + "<ul class=\"AKCRes\">";
		var  footer="</ul>";
		var  comment="";
		var  AKCSearchInputBox = document.getElementById("AKCSearch");
		
		AKCChangeArrow(1);
				
		res.style.display = "block";
	
		//JSONÀ» ÅëÇØ  myJSONObjectHead, myJSONObjectTail ¿ÀºêÁ§Æ®¸¦ ¹Þ´Â´Ù
		eval(AKCSearchReq.responseText);
		
		//eQuery¸¦ ¹Þ´Â´Ù.

		//Çì´õ ÀÛ¼º
		body = header;

		//bodyÀÇ ³»¿ëÀ» Ã¤¿î´Ù
		body =  body + ACKMakeBody(myJSONObject);//Head, myJSONObjectTail);
		
		//³¡
		body = body + footer;
		
		AKCResult.style.top = eval(getElementY(AKCSearchInputBox) + AKCSearchInputBox.offsetHeight) + "px";
		AKCResult.style.left = getElementX(AKCSearchInputBox) + "px";

		hd.innerHTML = control;
		
		sh.innerHTML = body;
	}

}


function AKCHeadHighlight(KeywordList, Query) 
{ 
log("AKCHeadHighlight");	
	var HighLightKeywordList=""; 
	var s1=KeywordList.replace(/ /g, ""); 
	var t1=Query.replace(/ /g, ""); 

	t1=t1.toLowerCase(); 

	if (t1==s1.substring(0, t1.length)) 
	{ 
		HighLightKeywordList="<em>"; 
		for (var i=0,j=0; j<t1.length; i++) 
		{ 
	
			if (KeywordList.substring(i, i+1)!=" ") 
				j++; 
			HighLightKeywordList+=KeywordList.substring(i, i+1); 
		} 
		
		HighLightKeywordList+="</em>"+KeywordList.substring(i, KeywordList.length); 
	} 

	return HighLightKeywordList; 
} 

function AKCTailHighlight(KeywordList, Query) 
{ 
log("AKCTailHighlight");
	var HighLightKeywordList="";
	var s1=KeywordList.replace(/ /g, ""); 
	var t1=Query.replace(/ /g, ""); 
	t1=t1.toLowerCase(); 
	if (t1==s1.substring(s1.length-t1.length)) 
	{ 
		for (var i=0,j=0; j<s1.length-t1.length; i++) 
		{ 
			if (KeywordList.substring(i, i+1)!=" ") 
				j++; 
			HighLightKeywordList+=KeywordList.substring(i, i+1); 
		} 
		
		HighLightKeywordList+="<em>"; 
		for (var k=i,l=0; l<t1.length; k++) 
		{ 
			if (KeywordList.substring(k, k+1)!=" ") 
				l++; 
			HighLightKeywordList+=KeywordList.substring(k, k+1); 
		} 
		
		HighLightKeywordList+="</em>"; 
	} 

	return HighLightKeywordList; 
} 

function AKCHighlight(KeywordList, Query, is_suf) 
{ 
log("AKCHighlight");
	var ret=""; 

	if (is_suf==0) 
	{ 
		ret=AKCHeadHighlight(KeywordList, Query);
		if(ret==""&&eQuery!="")
			ret=AKCHeadHighlight(KeywordList, eQuery);
	} 
	else if(is_suf==1)
	{ 
		ret=AKCTailHighlight(KeywordList, Query);
		if(ret==""&&eQuery!="")
			ret=AKCTailHighlight(KeywordList, eQuery);
	} 
	else if(is_suf==2)
	{
		ret=AKCHeadHighlight(KeywordList, Query);

		
		if(ret==""&&eQuery!="")
			ret=AKCHeadHighlight(KeywordList, eQuery);
	
		if(ret=="")
			ret=AKCTailHighlight(KeywordList, Query);
		
		if(ret==""&&eQuery!="")
			ret=AKCTailHighlight(KeywordList, eQuery);
				
	}
	
	document.SearchForm.kwd.focus();
	
	if (ret=="") 
		return KeywordList;
	else 
		return ret; 
} 


function AKCIsSuf(btn)
{
log("AKCIsSuf");
	if(AKCUse==true)
	{
		if (btn=="ipf_btn") 
		{ 
			//Ã¹´Ü¾î~ ¾ÆÀÌÄÜ ÇÏÀÌ¶óÀÌÆÃ
			AKCLayerId('ipf').src = "/common/lib/search/images/AutoSch_btn_sortF_On.gif"; 
			AKCLayerId('isf').src = "/common/lib/search/images/AutoSch_btn_sortE.gif"; 
			is_suf_last=is_suf;
			is_suf=0;
		} 
		else
		{ 
			//~³¡´Ü¾î ¾ÆÀÌÄÜ ÇÏÀÌ¶óÀÌÆÃ
			AKCLayerId('ipf').src = "/common/lib/search/images/AutoSch_btn_sortF.gif"; 
			AKCLayerId('isf').src = "/common/lib/search/images/AutoSch_btn_sortE_On.gif"; 
			is_suf_last=is_suf;
			is_suf=1;
		} 

		AKCSearchStart();
	}
}


function AKCLayerId(id) 
{
log("AKCLayerId"); 
	var _return;
	if(document.all) 
	{
		_return=document.all[id];
	} 
	else if (document.getElementById) 
		{
			_return=document.getElementById(id);
		} 
		return _return; 
} 


function AKCLayerTopId(id) 
{ 
log("AKCLayerTopId");
	var _return;
	if(document.all) 
	{
		_return=document.all[id];
	} 
	else if (document.getElementById) 
	{
		_return=document.getElementById(id);
	} 
	
	return _return; 
} 



function ACKMakeBody(myJSONObject)//Head, myJSONObjectTail) 
{
log("ACKMakeBody");
	var  body="";
	var  comment="";
	
	sQuery=document.SearchForm.kwd.value;
	 
	if(is_suf==0)
	{
		if(myJSONObject.LIST.length==0)
		{
			comment = AKCNoResultMessage("pre");
			body = body + "<li class=\"AKCRow\"";
			body = body + "><a href='#'>&nbsp;"
			body = body + comment;
			body = body + "</a></li>"
		}
		else
		{
			for(var i=0;i<myJSONObject.LIST.length;i++)
			{
				
				body = body + "<li class=\"AKCRow\" onMouseOver='AKCMouseOverMove(this)' value='";
				body = body + myJSONObject.LIST[i].KEYWORD;
//				body = body + "'><a href=\"javascript:totalsearch('" + myJSONObject.LIST[i].KEYWORD + "');\">&nbsp;"
				body = body + "'><a href=# onclick=\"document.SearchForm.kwd.value='" + myJSONObject.LIST[i].KEYWORD + "';totalsearch();return false\">&nbsp;"
				body = body + AKCHighlight(myJSONObject.LIST[i].KEYWORD, sQuery, is_suf);
				body = body + "</a></li>"
			}
		}
	}
	else
	{
		if(myJSONObject.LIST.length==0)
		{
			comment = AKCNoResultMessage("suf");
			body = body + "<li class=\"AKCRow\"";
			body = body + "><a href='#'>&nbsp;"
			body = body + comment;
			body = body + "</a></li>"
		}
		else
		{
			for(var i=0;i<myJSONObject.LIST.length;i++)
			{
	
				body = body + "<li class=\"AKCRow\" onMouseOver='AKCMouseOverMove(this)' value='";
				body = body + myJSONObject.LIST[i].KEYWORD;
//				body = body + "'><a href=/?kwd=" + myJSONObject.LIST[i].KEYWORD + ">&nbsp;"
				body = body + "'><a href=# onclick=\"document.SearchForm.kwd.value='" + myJSONObject.LIST[i].KEYWORD + "';totalsearch();return false\">&nbsp;"
				body = body + AKCHighlight(myJSONObject.LIST[i].KEYWORD, sQuery, is_suf);
				body = body + "</a></li>"
			}
		}
	}

	return body;
}


function AKCMakeHeader()
{
log("AKCMakeHeader");
		
	var  contents = 
  	  "<table class=AKCResultContents width=\"182\" cellspacing=\"0\" cellpadding=\"0\" bgcolor='#ffffff'>"
	+ "<tr>"
	+ "<th class=AKCResultContents>"
	+ "<div style=\"float:left;margin:5px 0 0 0;\">&nbsp;°Ë»ö¾î ÀÚµ¿¿Ï¼º</div>"
	+ "<div style=\"float:right;margin:3px 5px 0 0;\">"
//	+ "<a href=\"#\" onclick=\"AKCIsSuf('ipf_btn');\">";
	+ "<span onclick=\"AKCIsSuf('ipf_btn');\">";
	
//	if(is_suf==0)
//	contents+= "<img id=ipf src=images/AutoSch_btn_sortF_On.gif width=47 height=16 alt=\"Ã¹´Ü¾î°¡ ÀÏÄ¡µÇ´Â ¹®ÀåÀ¸·Î\" border=0 style=\"cursor:pointer; margin:0 0 0 100px\">";
//	else
//	contents+= "<img id=ipf src=images/AutoSch_btn_sortF.gif width=47 height=16 alt=\"Ã¹´Ü¾î°¡ ÀÏÄ¡µÇ´Â ¹®ÀåÀ¸·Î\" border=0 style=\"cursor:pointer; margin:0 0 0 100px\">";
	
	contents+= "</span>"
	+ "&nbsp;"
//	+ "<a href=\"#\" onclick=\"AKCIsSuf('isf_btn');\">";
	+ "<span onclick=\"AKCIsSuf('isf_btn');\">";
	
//	if(is_suf==1)
//	contents+= "<img id=isf src=images/AutoSch_btn_sortE_On.gif width=47 height=16 alt=\"³¡´Ü¾î°¡ ÀÏÄ¡µÇ´Â ¹®ÀåÀ¸·Î\" border=0 style=\"cursor:pointer\">";
//	else
//	contents+= "<img id=isf src=images/AutoSch_btn_sortE.gif width=47 height=16 alt=\"³¡´Ü¾î°¡ ÀÏÄ¡µÇ´Â ¹®ÀåÀ¸·Î\" border=0 style=\"cursor:pointer\">";
	
	contents+= "</span>"
	+ "&nbsp;"
	+ "<img src=/common/lib/search/images/AutoSch_bar.gif width=2 height=16 alt=\"\" border=0>"
	+ "&nbsp;"
//	+ "<a href=\"#\" onclick=\"window.open();\">"
	+ "<span onclick=\"window.open();\">"
//	+ "<img src=images/AutoSch_btn_Q.gif width=14 height=14 alt=\"µµ¿ò¸»\" border=0 target=_blank style=\"cursor:pointer; margin:0 0 1px 0;\">"
	+ "</span>"
	+ "&nbsp;"
//	+ "<a href=\"#\" onclick=\"AKCHUseSwitch();\">";
	+ "<span onclick=\"AKCHUseSwitch();\">";
	
	if(AKCUse == true)
		contents += "<img id=iakc src=/common/lib/search/images/AutoSch_btn_Quit_Off.gif width=14 height=14 alt=\"°Ë»ö¾î ÀÚµ¿ ¿Ï¼º ±â´É²ô±â\" border=0 style=\"cursor:pointer; margin:0 0 1px 0;\">";
	else
		contents += "<img id=iakc src=/common/lib/search/images/AutoSch_btn_Quit_On.gif width=14 height=14 alt=\"°Ë»ö¾î ÀÚµ¿ ¿Ï¼º ±â´ÉÄÑ±â\" border=0 style=\"cursor:pointer; margin:0 0 1px 0;\">";
	
	contents += "</span>"
	+ "&nbsp;"
	+ "</div>"
	+ "</th>"
	+ "</tr>"
	+ "</table>";
	
	return contents;			
}


function AKCNoResultMessage(flag)
{
log("AKCNoResultMessage");
	var comment="";


	if(flag=="pre")
	{
		comment =  "<table width=100%>";
		comment += "<tr>";
		comment += "<td class=\"AKCMessage\">&nbsp;ÇØ´ç ´Ü¾î·Î ½ÃÀÛÇÏ´Â ÃßÃµ¾î°¡ ¾ø½À´Ï´Ù.</td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCMessage\">&nbsp;</td>";
		comment += "</tr>";
		comment += "</table>";	
	}
	else
	{	
		comment =  "<table width=100%>";
		comment += "<tr>";
		comment += "<td class=\"AKCMessage\">&nbsp;ÇØ´ç ´Ü¾î·Î ³¡³ª´Â ÃßÃµ¾î°¡ ¾ø½À´Ï´Ù.</td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCMessage\">&nbsp;</td>";
		comment += "</tr>";
		comment += "</table>";		
	}

	return comment;
}


function AKCMakeArrow(flag) 
{ 
log("AKCMakeArrow");
	var  AKCSearchInputBox = document.getElementById("AKCSearch");
	var  s="";

	AKCArrow.style.top = eval(getElementY(AKCSearchInputBox) + AKCSearchInputBox.offsetHeight - 17) + "px";
//	AKCArrow.style.left = eval(getElementX(AKCSearchInputBox) + 365) + "px";
	AKCArrow.style.left = eval(parseInt(getElementX(AKCSearchInputBox)) + parseInt(AKCSearchInputBox.style.width) - 20 ) + "px";
	
	if(!flag)
		s = "<span onclick=\"AKCVUseSwitch('view');\"><img id=iarw src=\"/common/lib/search/images/v6_search_arrow_down.gif\" alt=\"º¸ÀÌ±â\" border=0 style='cursor:pointer; margin:0 3 0 3'></span>"; 
	else
		s = "<span onclick=\"AKCVUseSwitch('hidden');\"><img id=iarw src=\"/common/lib/search/images/v6_search_arrow_up.gif\"  alt=\"°¨Ãß±â\" border=0 style='cursor:pointer; margin:0 3 0 3'></span>"; 
	
	return s ; 
} 

function AKCSearchSubmit()
{
log("AKCSearchSubmit");
	var highlight = document.getElementById("AKCHighlight");
	if (highlight && highlight.firstChild)
	{
		window.location = AKCSearchRoot + AKCSearchRootSubDir + highlight.firstChild.nextSibling.getAttribute("href");
		return false;
	} 
	else
	{
		return true;
	}
}

function AKCSearchHover() 
{
log("AKCSearchHover");
	highlight = document.getElementById("AKCHighlight");
	if (highlight) 
	{
		highlight.removeAttribute("id");
	}
	el.setAttribute("id","AKCHighlight");
}

function AKCSearchClicked() 
{
log("AKCSearchClicked");
	highlight = document.getElementById("AKCHighlight");
	if (highlight) 
	{
		highlight.removeAttribute("id");
	}
	el.setAttribute("id","AKCHighlight");
	return liveSearchSubmit();
}
/*
function AKCResultOpen() 
{
    document.getElementById("AKCResult").style.display = "block";
}

function AKCResultClose() 
{
    document.getElementById("AKCResult").style.display = "none";
}
*/
///////////////////////////////////////////////////////////////////////
//Çì´õ : °Ë»ö¾î ÀÚµ¿ ¿Ï¼º on, off Á¦¾î
function AKCHUseSwitch() 
{
log("AKCHUseSwitch");
	var comment="";

	if(AKCUse == true)
	{
		AKCLayerId('iakc').src = "/common/lib/search/images/AutoSch_btn_Quit_On.gif"; 
		AKCLayerId('iakc').alt = "°Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´É ÄÑ±â"; 

		//AKCLayerId('ipf').src = "/common/lib/search/images/AutoSch_btn_sortF.gif"; 
		//AKCLayerId('isf').src = "/common/lib/search/images/AutoSch_btn_sortE.gif"; 
		is_suf_last=is_suf;
		is_suf=2;

		AKCSearchHide();
		AKCUse=false;
	}
	else
	{
		comment = AKCSwitchInfoService(!AKCUse);
		
		AKCLayerId('iakc').src = "/common/lib/search/images/AutoSch_btn_Quit_Off.gif";
		AKCLayerId('iakc').alt = "°Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´É ²ô±â";  

		AKCUse=true;
		
		if(document.SearchForm.kwd.value=="")
			AKCHBodyUseSwitch(comment);
		else
		{
			AKCSearchLast = "";
			AKCSearchStart();
		}
		
	}
	return;
}

function AKCHBodyUseSwitch(comment)
{
log("AKCHBodyUseSwitch");
	var  sh = document.getElementById("AKCShadow");
	var  body = "";
	var  header="<?xml version=\"1.0\" encoding=\"euc-kr\" ?>"
	     + "<ul class=\"AKCRes\">";
	var  footer="</ul>";
		
	body = header;
	
	body = body + "<li class=\"AKCRow\">";
	body = body + "&nbsp;"
	body = body + comment;
	body = body + "</li>"	
	
	body = body + footer;

	sh.innerHTML = body;
}
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
//°Ë»ö¾î ÀÚµ¿ ¿Ï¼ºÃ¢ view/hidden Á¦¾î
function AKCVUseSwitch(flag) 
{
log("AKCVUseSwitch");

	if(flag=='view')
	{
		var  comment="";
		AKCChangeArrow(1);
		if(AKCUse == true)
		{
			if(document.SearchForm.kwd.value=="")
			{
				comment = AKCSwitchInfoService(AKCUse);
				AKCVUseSwitchView(comment);

			}
			else
			{
				var  res = document.getElementById("AKCResult");
				res.style.display = "block";

			}
		}
		else
		{
			comment = AKCSwitchInfoService(AKCUse);
			AKCVUseSwitchView(comment);

		}
		document.SearchForm.kwd.focus();
	}
	else
	{
		AKCChangeArrow(0);
//		var  res = document.getElementById("AKCResult");
//		res.style.display = "none";

		document.SearchForm.kwd.focus();
	}

}

function AKCVUseSwitchView(comment)
{
log("AKCVUseSwitchView");
	var  res = document.getElementById("AKCResult");
	var  sh = document.getElementById("AKCShadow");
	var  hd = document.getElementById("AKCControl");

	var  body = "";
	var  control = AKCMakeHeader();
	var  header="<?xml version=\"1.0\" encoding=\"euc-kr\" ?>"
	     + "<ul class=\"AKCRes\">";
	var  footer="</ul>";
	var  AKCSearchInputBox = document.getElementById("AKCSearch");
		
	res.style.display = "block";
	
	body = header;
	
	body = body + "<li class=\"AKCRow\">";
	body = body + "&nbsp;"
	body = body + comment;
	body = body + "</li>"	
	
	body = body + footer;
	AKCResult.style.top = eval(getElementY(AKCSearchInputBox) + AKCSearchInputBox.offsetHeight) + "px";
	AKCResult.style.left = getElementX(AKCSearchInputBox) + "px";

	hd.innerHTML = control;
	sh.innerHTML = body;
} 

function AKCSwitchInfoService(flag)
{
log("AKCSwitchInfoService");
	var comment="";
	
	if(flag==true)
	{
		comment =  "<table border='0' width=100% bgcolor='#ffffff'>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;°Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´ÉÀÌ »ç¿ëÁß ÀÔ´Ï´Ù.</td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;°Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´ÉÀÇ ÁßÁö¸¦ ¿øÇÏ½Ã¸é '<image src=\"/common/lib/search/images/AutoSch_btn_Quit_Off.gif\">'¸¦ </td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;Å¬¸¯ÇØ ÁÖ½Ê½Ã¿À.</td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;</td>";
		comment += "</tr>";
		comment += "</table>";	
	}
	else
	{	
		comment =  "<table border='0' width=100% bgcolor='#ffffff'>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;°Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´É ÁßÁö µÇ¾ú½À´Ï´Ù.</td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;°Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´ÉÀÇ »ç¿ëÀ» ¿øÇÏ½Ã¸é '<image src=\"/common/lib/search/images/AutoSch_btn_Quit_On.gif\">'À» </td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;Å¬¸¯ÇØ ÁÖ½Ê½Ã¿À.</td>";
		comment += "</tr>";
		comment += "<tr>";
		comment += "<td class=\"AKCInfo\" style=font-size:11px;font-family:µ¸¿ò; letter-spacing:-1;>&nbsp;</td>";
		comment += "</tr>";
		comment += "</table>";		
	}
	return comment;
}
//////////////////////////////////////////////////////////////////////////

function AKCClearView()
{
log("AKCClearView");
//	var  sh = document.getElementById("AKCShadow");
	var  sh = document.getElementById("AKCResult");
	sh.innerHTML = "";
}


function AKCSetInputBox(flag)
{
log("AKCSetInputBox");
	var textbox = document.SearchForm.kwd; 
	var _event; 
	
	switch ( AKCGetNavigatorType() )
	{
	case 1 : // IE
		_event = window.event;
		nodeName = _event.srcElement.nodeName;
		break;
	case 2 : // Netscape
		_event = event;
		nodeName = _event.target.nodeName;
		break;
	default :
		nodeName = "None"; 
		break;
	}
	key = _event.keyCode;
	textbox.style.backgroundImage="";
	if ( keystatus == 1 && flag && key != 13) {
		textbox.value = "";
		keystatus = 2;
	}
}


function AKCGetNavigatorType()
{
log("AKCGetNavigatorType");
	if ( navigator.appName == "Microsoft Internet Explorer" )
		return 1;  
	else if ( navigator.appName == "Netscape" )
		return 2;	
	else 
		return 0;
}

function getElementY(element)
{
log("getElementY");

	var targetTop = 0;
	if (element.offsetParent)
	{
		while (element.offsetParent)
		{
			targetTop += element.offsetTop;
            		element = element.offsetParent;
		}
	}
	else if(element.y)
		{
			targetTop += element.y;
    		}
	
	return targetTop;
}

function getElementX(element)
{
log("getElementX");

	var targetTop = 0;
	if (element.offsetParent)
	{
		while (element.offsetParent)
		{
			targetTop += element.offsetLeft;
            		element = element.offsetParent;
		}
	} 
	else if(element.x)
		{
			targetTop += element.x;
		}
	
	return targetTop;
}

