/*
	created by nhosw@i-swear.com
			     	   crazyidol
		  http://www.i-swear.com
					2007. 09 .28
*/
  document.write('<style type="text/css">#ob { border: #333333 1px solid; width: 155px; padding: 0px; background: #FFFBEE; position: absolute; display: none; }  #ob div { padding: 2px; cursor:pointer; font-size: 12px; }  #ob div.ajax_hover { background: #FFDCB8; }  #ob div span { font-size: 12px; color:#333333; }  #ob div span.match { color: #FF0000; }  #ob div span.unmatch { color: #333333; }</style>');
  var a_new = null;
  var a_old = null;
  var a_timer = null;
  var a_obj = null;
  var a_int = 300;
  var a_type = null;
  var a_search = null;
  var B="block",I="inline",N="none",UD="undefined";
  var UD = "undefine";
  var han_1 =new Array('¤¡','¤¢','¤¤','¤§','¤¨','¤©','¤±','¤²','¤³','¤µ','¤¶','¤·','¤¸','¤¹','¤º','¤»','¤¼','¤½','¤¾');//ÃÊ¼º 19°³ 
  var han_2 =new Array('¤¿','¤À','¤Á','¤Â','¤Ã','¤Ä','¤Å','¤Æ','¤Ç','¤È','¤É','¤Ê','¤Ë','¤Ì','¤Í','¤Î','¤Ï','¤Ð','¤Ñ','¤Ò','¤Ó');//Áß¼º 21°³
  var han_3 =new Array('','¤¡','¤¢','¤£','¤¤','¤¥','¤¦','¤§','¤©','¤ª','¤«','¤¬','¤­','¤®','¤¯','¤°','¤± ','¤²','¤´','¤µ','¤¶','¤·','¤¸','¤º','¤»','¤¼','¤½','¤¾');//Á¾¼º 28°³ 

  // $ ÀÌ Á¸ÀçÇÏ´ÂÁö È®ÀÎ.
  if (typeof($) != "function") { function $(id) { return document.getElementById(id); } }
  // _isIE °¡ Á¸ÀçÇÏ´ÂÁö Ã¼Å©
  if (typeof(_isIE) != "boolean") var _isIE=(navigator.userAgent.match(/Gecko/))?false:true;
  if (!$('ob')) { document.write('<div id="ob"></div>'); }
  // lX °¡ Á¸ÀçÇÏ´ÂÁö Ã¼Å©
  if (typeof(lX) != "function") {	// lX function is created by sota
	function lX(obj, top, absolute) {	var x = 0;	if (!obj) return 0;	if (_isIE) {		do {			if (absolute && obj && obj.style && obj.style.position == 'absolute') break;			x += obj.offsetLeft+obj.clientLeft-obj.scrollLeft;			obj = obj.offsetParent; }		while (obj && obj != top);	}else{		do {			if (absolute && obj && obj.style && obj.style.position == 'absolute') break;			x += obj.offsetLeft-obj.scrollLeft;			obj = obj.offsetParent;		}		while (obj && obj != top);	}	if (obj == document.body || top) x-=document.body.offsetLeft;	return x; }
  }
  // lY °¡ Á¸ÀçÇÏ´ÂÁö Ã¼Å©
  if (typeof(lY) != "function") {	// lY function is created by sota
	function lY(obj, top, absolute) {	var y = 0;	if (!obj) return 0;	if (_isIE) {		do {			if (absolute && obj && obj.style && obj.style.position == 'absolute') break;			y += obj.offsetTop+obj.clientTop-obj.scrollTop;			obj = obj.offsetParent;		}while (obj && obj != top);	}else{		do {			if (absolute && obj && obj.style && obj.style.position == 'absolute') break;			y += obj.offsetTop-obj.scrollTop;			obj = obj.offsetParent;		}while (obj && obj != top);	}	if (obj == document.body || !top) y-=document.body.offsetTop;	return y;}
  }

  function setBox(el, el_type, el_method, event) {
	if (_isIE) var e = window.event;
	else var e = event;
	if (a_obj == el) {
		if (e.keyCode == '40') {	// ¾Æ·¡ È­»ìÇ¥
			if ($("ob").style.display == B || $("ob").style.display == "") {
				var cnt = $("ob").childNodes.length;
				for (var i=0; i<cnt; i++) {
					if ($("ob").childNodes[i].className == "ajax_hover") { 
						if (i < cnt - 1) $("ob").childNodes[i+1].className = "ajax_hover"; 
						if (i < cnt - 1) $("ob").childNodes[i].className = ""; 
						return; 
					}
				}
				$("ob").firstChild.className = "ajax_hover";
			}
			e.returnValue=false;
		}
		else if (e.keyCode == '38') { // À§·Î È­»ìÇ¥
			if ($("ob").style.display == B || $("ob").style.display == "") {
				var cnt = $("ob").childNodes.length;
				for (var i=cnt-1; i>=0; i--) {
					if ($("ob").childNodes[i].className == "ajax_hover" && i > 0) { $("ob").childNodes[i].className = ""; $("ob").childNodes[i-1].className = "ajax_hover"; return false; }
				}
				$("ob").firstChild.className = "ajax_hover";
			}
			e.returnValue=false;
		}
		else if (e.keyCode == '13') { // ¿£ÅÍ
			m_in(el);
//			e.returnValue=false;
		}
		if (a_timer == null) { return; }
	}
	
	el.setAttribute("autocomplete", "off");	// ºê¶ó¿ìÀú ÀÚµ¿¿Ï¼º ²ô±â.

	a_timer = null;
	a_obj = el;
	a_type = el_type;
	$("ob").style.top = lY(el) + 20 + parseInt(document.body.scrollTop);
	$("ob").style.left = lX(el) - 5;


	if (a_type == 'array') {
		try {
		if (typeof(el_method) == 'string') a_search = eval(el_method);
		else a_search = el_method;
		}
		catch (e) { 
			window.alert("ÀÚµ¿¿Ï¼ºÀ» »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
			el.onkeydown = null;
			return;
		}
		textMatch();
	}
  }
  function setBoxDeclare() {
	if (a_timer != null) {
	window.clearTimeout(a_timer);
	a_timer = null;
	if (a_obj == null) return;
	a_new = a_obj.value;
	a_old = a_new;
	a_obj = null;
	}
	$("ob").style.display = N;
  }
  function blur_setBoxDeclare() {
	  window.setTimeout("setBoxDeclare();", 100);
  }
  function m_in(el) {
	if (!el) el = a_obj;
	if ($("ob").style.display == B || $("ob").style.display == "") {
		var cnt = $("ob").childNodes.length;
		for (var i=0; i<cnt; i++) {
			if ($("ob").childNodes[i].className == "ajax_hover") { el.focus(); el.value = $("ob").childNodes[i].getAttribute("text", 1); document.morning_top_search.submit(); }
		}
	setBoxDeclare();
	}			  
  }
  function m_on(el) {
	  var el_p = el.parentNode;
	  var cnt = el_p.childNodes.length;
	  for (var i = 0; i<cnt; i++) { el.className = "ajax_hover"; if (el_p.childNodes[i] == el) continue; if (el_p.childNodes[i].className == 'ajax_hover') el_p.childNodes[i].className = "";  }
  }
  function textMatch() {
	var ma = null, un_ma = null;
	var str = "";
	if (a_obj != null) a_new = a_obj.value;
	var a_new_len = a_new.length;
	var jamo = false;
	var s = "";
	
	if (a_new == "") $("ob").style.display = N; 
	if (a_new != a_old) {
		a_old = a_new;
		for (var i=0; i<a_search.length; i++) {
			ma = ""; un_ma = "";
			if (a_search[i].substring(0, a_new_len) == a_new) { ma = a_new; un_ma = a_search[i].substring(a_new_len); }
			if (ma != "") { 
				str += '<div text="' + ma + un_ma + '" onmouseover="m_on(this);" onclick="m_in();"><span class="match">' + ma + '</span><span class="unmatch">' + un_ma + '</span></div>';
			}
		}
		// ·çÇÁ¸¦ µ¹¾Ò´Âµ¥µµ °á°ú°ªÀÌ ¾ø´Ù¸é..
		if (str == "" && a_new.match(/[^0-9a-zA-Z_\.\/]$/)) {
			if (a_new.match(/.[¤¡-¤¾]$/)) {
				a_new_len--;
				a_new = a_new.substring(0, a_new_len);
			}
			else if (a_new.match(/[a-z0-9A-Z¤¡-¤¾]$/)) {
//				a_new = a_new.substring(a_new_len - 1);
				jamo = true;
				var tmp = getJamoCodes(a_new.substring(a_new_len - 1));
				a_new = a_new.substring(0, a_new_len - 1) + han_1[tmp[0]-1];
			}
			for (var i=0; i<a_search.length; i++) {
				ma = ""; un_ma = "";
				if (jamo == false) { s = a_search[i].substring(0, a_new_len); }
				else { tmp = getJamoCodes(a_search[i].substring(a_new_len - 1, a_new_len)); s = a_search[i].substring(0, a_new_len - 1) + han_1[tmp[0]-1]; }
				if (s == a_new) {
					str += '<div text="' + a_search[i] + '" onmouseover="m_on(this);" onclick="m_in();"><span class="unmatch">' + a_search[i] + '</span></div>';
				}
			}
		}
		if (str != "") {
		if ($("ob").style.display == "" || $("ob").style.display == N) $("ob").style.display = B;
		$("ob").innerHTML = str;
		}
	}

	a_timer = window.setTimeout("textMatch()", a_int);
  }

  // ÃÊ,Áß,Á¾¼ºÀ¸·Î ÇÑ±ÛÀ» Àß¶óÁÜ. ÇÑ±ÛÀÌ ¾Æ´Ò °æ¿ì´Â ¹è¿­·Î (0,0,0) ¸®ÅÏ Created By PHPSCHOOL alee
  function getJamoCodes(t) {
    var c = t.charCodeAt(0), c = c<0x3130?0:c<0x3164?c-0x3130:c<0xac00?0:c<0xd7a5?c+68:0;
    if (c>51) return Array((c-c%588)/588-74,((c-c%28)/28)%21+1,c%28);
    return Array(c<3?c:c<4?0:c<5?c-1:c<7?0:c<10?c-3:c<17?0:c<20?c-10:c<21?0:c<31?c-11:0,c<31?0:c-30,0);
  } 