// °Ë»ö¾î ÃßÃµ Å¬·¡½º  BY CJS (2005.07.14)
tempcounter = 0;
othercounter = 0;



g_Recommend	= new CRecommend();   // Àü¿ª ¿ÀºêÁ§Æ® »ý¼º.
g_Cookie = new CCookie();		  // ÄíÅ° °ü·Ã Àü¿ª ¿ÀºêÁ§Æ® »ý¼º.

g_Recommend.initUseRecommend();   // ÄíÅ° °ªÀ» ÀÐ¾î¿Í¼­ »ç¿ë¿©ºÎ »óÅÂ¸¦ ¼ÂÆÃÇÑ´Ù.

String.prototype.cut = function(len) {
                var str = this;
                var l = 0;
                for (var i=0; i<str.length; i++) {
                        l += (str.charCodeAt(i) > 128) ? 2 : 1;
                        if (l > len) return str.substring(0,i) + "...";
                }
                return str;
        }
//document.domain='ktdom.com';
function CRecommend()
{
// private:
	this.m_iCurFocusIndex = -1;			// ÇöÀç ¼±ÅÃµÈ ´Ü¾îÀÇ À§Ä¡
	this.m_iSearchMode = 0;				// ´Ü¾î~    ~´Ü¾î  ÀÇ ¼±ÅÃ ¿©ºÎ 0ÀÌ ±âº» '´Ü¾î~' ¸ðµå
	this.m_iSearchStep = 0;				// More¸¦ ´©¸¦ °æ¿ì ´ÙÀ½ ½ºÅÛÀ¸·Î 1¾¿ Áõ°¡
	this.m_iElementLength = 0;			// °Ë»ö °á°ú °³¼ö
	this.m_bEnabled = true;				// ÃßÃµ ±â´ÉÀÇ »ç¿ë ¿©ºÎ 
	this.m_bPrevStatus = true;			// ÃßÃµ ±â´É »ç¿ë¿©ºÎ ÀÓ½Ã ÀúÀå Àå¼Ò 
	this.m_bHasFocus = false;			// ÀÎÇ² ¹Ú½ºÀÇ Æ÷Ä¿½º ¼ÒÀ¯ ¿©ºÎ
	this.m_strLastWord = '';			// ¸¶Áö¸·À¸·Î Ä£ ´Ü¾î
	this.m_arrRecommendWords = Array(); // ÃßÃµ´Ü¾î°¡ ÀúÀåµÇ´Â ¹è¿­
	this.m_arrRecommendURLs = Array(); // ÃßÃµURL ÀúÀåµÇ´Â ¹è¿­ 2008.02.11
	this.m_arrRecommendGUBUNs = Array(); // gubun°ª ÀúÀåµÇ´Â ¹è¿­ 2008.02.18
	
	this.m_arrRecommendRevWords = Array(); // ÃßÃµ´Ü¾î°¡ ÀúÀåµÇ´Â ¹è¿­ (¿ª¼ø) 2008.02.27
	this.m_arrRecommendRevURLs = Array(); // ÃßÃµURL ÀúÀåµÇ´Â ¹è¿­ (¿ª¼ø) 2008.02.27
	this.m_arrRecommendRevGUBUNs = Array(); // gubun°ª ÀúÀåµÇ´Â ¹è¿­ (¿ª¼ø) 2008.02.27
	
	this.m_bCheckFlag = false;			// ÀÏÁ¤½Ã°£¸¶´Ù XML Request °¡ µé¾î°¬´ÂÁö¸¦ Ã¼Å©ÇÒÁö ¿©ºÎ.
	this.m_Require = null;				// XML °´Ã¼ 
	//this.m_iFixedWords = 5;				// ÇÑÈ­¸é¿¡ Ãâ·ÂµÉ ±ÛÀÚ °¹¼ö (³ª¸ÓÁö´Â ´Ü¾î´Â ½ºÅ©·Ñ¹Ù·Î ¾Æ·¡ÂÊ¿¡ À§Ä¡ÇÔ)
	this.m_iFixedWords = 12;				// ÇÑÈ­¸é¿¡ Ãâ·ÂµÉ ±ÛÀÚ °¹¼ö (³ª¸ÓÁö´Â ´Ü¾î´Â ½ºÅ©·Ñ¹Ù·Î ¾Æ·¡ÂÊ¿¡ À§Ä¡ÇÔ)
	this.m_iCurrentScrollPos = 0;		// ÇöÀç ½ºÅ©·Ñ À§Ä¡
	this.m_iWordsHeight = 21;			// ÇÑ´Ü¾î´ç Â÷ÁöÇÏ´Â ³ôÀÌ (px)
	this.m_oInputBox = null;			// ÀÔ·Â¹ÞÀ» ÀÎÇ² ¹Ú½º
	this.m_oPrintZone = null;			// Ãâ·ÂÇÒ Àå¼Ò (div, spanµî)
	this.m_oArrowImage = null;
	this.m_strLastSearchValue = '';     // ¸¶Áö¸·À¸·Î °Ë»öµÈ ´Ü¾î
	//this.m_iMaxSearchWordCount = 10;    // ³»°¡ Ã£Àº ´Ü¾î ÃÖ´ë °¹¼ö
	this.m_iMaxSearchWordCount = 20;    // ³»°¡ Ã£Àº ´Ü¾î ÃÖ´ë °¹¼ö

	this.m_iPrintWordLength = 23;       // ´Ü¾î ±æÀÌ ÃÖ´ë ¹ÙÀÌÆ®  ±×ÀÌ»óÀº Â¥¸§.  	54-> 24


	this.m_strUpArrow = '/images/popular/bullet_t.gif';
	this.m_strDownArrow = '/images/popular/bullet_b.gif';
	this.m_bMysearchVisible = false;    // ³»°¡ Ã£Àº °Ë»ö¾îÀÇ È°¼º À¯¹«
	

	this.m_strDocumentType = "";
// public:
	this.getDocumentType = function()
	{

		if( this.m_strDocumentType == 'MySearch' )
		{
			return 1; // ³»°¡ Ã£Àº °Ë»ö¾î°¡ ³»¿ëÀ¸·Î Á¸ÀçÇÏ´Â °æ¿ì
		}
		else return 0; // ±×·¸Áö ¾ÊÀº °æ¿ì 0 ¸®ÅÏ

	}
	this.setUse = function(mode)
	{
		var strExpireDate;
		strExpireDate = this.getExpireDate();

		if( mode == true )
		{
			g_Cookie.SetCookie('UseRecommend',1,strExpireDate,'/','.ktdom.com');
			this.m_bEnabled = true;
			this.m_bPrevStatus = true;
			

			
			this.m_bMysearchVisible = false;
//			this.m_oPrintZone.style.display = 'none';
			if( this.m_oInputBox.value == '' )
			{
				this.m_oPrintZone.style.display = 'none';
			}
			this.m_oArrowImage.src = this.m_strDownArrow;

			this.loadDocument(this.m_oInputBox.value);
		}
		else
		{
			g_Cookie.SetCookie('UseRecommend',0,strExpireDate , '/','.ktdom.com');
			this.m_bEnabled = false;
			this.m_oPrintZone.style.display = 'none';
		}
	}
	this.getUse = function()
	{
		var tmpCookie;
		tmpCookie = g_Cookie.GetCookie('UseRecommend');

		if( tmpCookie == 0 )
		{
			return false;
		}
		else return true;
	}
	
	this.initUseRecommend = function()
	{
		var cookiedata;
		cookiedata = g_Cookie.GetCookie('UseRecommend');

		if( cookiedata != null )
		{
			if( cookiedata == 1 )
			{
				this.m_bEnabled = true;	
			}
			else
			{
				this.m_bEnabled = false;
			}
		}
		else
		{
			this.m_bEnabled = true;
		}
	}

	this.loadXMLDoc = function(url)
	{

		 
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = this.processReqChange;
			req.open("GET", url, true);
			req.send(null);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			isIE = true;
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = this.processReqChange;
				req.open("GET", url, true);
				req.send();
			}
			
		}
		

	}
	/////////////////////////////////////////////////
	//  ³»°¡ °Ë»öÇÑ °Ë»ö¾î °ü·Ã
	/////////////////////////////////////////////////
	this.getSearchWordCount = function ()  // ÇöÀç ÀúÀåµÇ¾îÀÖ´Â °Ë»ö¾îÀÇ °¹¼ö¸¦ ¾Ë¾Æ¿È
	{
		var i = 0;
		for( i = 0 ; i < this.m_iMaxSearchWordCount; i ++ )
		{
			tmpCookie = g_Cookie.GetCookie('SearchWord_'+ i );
			if( tmpCookie == null || tmpCookie == '' )
			{
				break;
			}
		}
		return i;
	}

	this.addSearchWord = function(word)
	{
		
		var j = 0;
		var iCookieCount;
		var strExpireDate;
		
		
		iCookieCount = this.getSearchWordCount();// °Ë»ö¾î ÃÑ °¹¼ö¸¦ ±¸ÇÑ´Ù
		
		// ÇöÀç ÀÖ´Â °Ë»ö¾îµéÀ» ÇÏ³ª ¾¿ µÚ·Î ¹Î´Ù (Que ±¸Á¶ FIFO)
		strExpireDate = this.getExpireDate();
		
		if( iCookieCount != 0 )
		{
			for( j = (iCookieCount -1) ; j >= 0 ; j -- )
			{
				tmpCookie = g_Cookie.GetCookie('SearchWord_'+j);
				g_Cookie.SetCookie(  'SearchWord_'+(j+1) , tmpCookie,  strExpireDate , '/','.ktdom.com' );
			}
		}
		
		
		g_Cookie.SetCookie('SearchWord_0', word, strExpireDate , '/','.ktdom.com');
	}

	// ¹«¾ð°¡ »èÁ¦¸¦ ÇÑ°æ¿ì´Â ÇØ´ç À§Ä¡ ÀÌÈÄ¿¡ ÀÖ´Â ³ðµéÀ» ¾ÕÀ¸·Î ²ø¾î ¿Ã¸°´Ù.
	this.deleteSearchWord = function(index)
	{
		var iCookieCount = this.getSearchWordCount();
		var tmpCookie;
		var i = 0;
		var strExpireDate;

		strExpireDate = this.getExpireDate();

		for( i = index ; i < (iCookieCount - 1) ; i ++ )
		{
			tmpCookie = g_Cookie.GetCookie('SearchWord_' + (i+1));
			g_Cookie.SetCookie('SearchWord_' + i , tmpCookie, strExpireDate , '/','.ktdom.com');
		}
		//alert( i );
		g_Cookie.SetCookie('SearchWord_' + i , '', strExpireDate , '/','.ktdom.com');

	}

	this.deleteSearchWordAll = function()
	{
		var strExpireDate;

		strExpireDate = this.getExpireDate();
		for( i = 0 ; i < this.m_iMaxSearchWordCount ; i ++ )
		{
			g_Cookie.SetCookie('SearchWord_' + i , '',  strExpireDate , '/','.ktdom.com');
		}
	}
	this.getExpireDate = function()
	{
		expireDate = new Date;
		expireDate.setMonth(expireDate.getMonth()+10);
		return expireDate;
	}

	// ´Ü¼øÈ÷ ÄíÅ°°ª ¸®ÅÏ
	this.getSearchWord = function(index)
	{
		return g_Cookie.GetCookie('SearchWord_' + index);
	}
	
	this.onClickDeleteButton = function(index)
	{
		this.deleteSearchWord(index);
		this.printMySearch();
	}
	this.onClickDeleteAllButton = function()
	{
		this.deleteSearchWordAll();
		this.printMySearch();
	}

	this.onClickDownButton = function()
	{
		
		//°Ë»ö¾î ÀÖÀ»¶§ ¾øÀ»¶§ ±¸ºÐ 		
		
		if ( this.m_oInputBox.value =='' ) {

			if( this.m_bMysearchVisible == false)
			{
				this.m_bMysearchVisible = true;
				this.m_oPrintZone.style.display = '';
				this.m_oArrowImage.src = this.m_strUpArrow;
				this.printMySearch();
                	
				this.m_bPrevStatus = this.m_bEnabled;
				this.m_bEnabled = false;
				// setUse(true);
			}
			else
			{
			
				this.m_bMysearchVisible = false;
				this.m_oPrintZone.style.display = 'none';
				selectbox_visible();
				this.m_oArrowImage.src = this.m_strDownArrow;
                	
				this.m_bEnabled = this.m_bPrevStatus;
			}

		
				
		} else {
			if( this.m_bMysearchVisible == false)
			{

				this.m_bMysearchVisible = true;     
				this.m_oPrintZone.style.display='none';  // ·¹ÀÌ¾î¸¦ º¸ÀÌÁö ¾Ê°Ô ÇÑ´Ù.
				selectbox_visible();				
				
				this.m_oArrowImage.src = this.m_strDownArrow;
                	                                             
				this.m_bEnabled = false;  
				// setUse(true);				
				
			}
			else
			{

				this.m_bMysearchVisible = false;     
				this.m_oPrintZone.style.display = '';
				selectbox_visible();                 
				this.m_oArrowImage.src = this.m_strUpArrow;
                	                                             
				this.m_bEnabled = this.m_bPrevStatus;                                                                 							
				
			}                                        
			                                         
			                                         
		}                                                
		
		/*	
		if( this.m_bMysearchVisible == false)
		{
			this.m_bMysearchVisible = true;
			this.m_oArrowImage.src = this.m_strUpArrow;
			this.printMySearch();

			this.m_bPrevStatus = this.m_bEnabled;
			this.m_bEnabled = false;
			// setUse(true);
		}
		else
		{
		
			this.m_bMysearchVisible = false;
			this.m_oPrintZone.style.display = 'none';
			selectbox_visible();
			this.m_oArrowImage.src = this.m_strDownArrow;

			this.m_bEnabled = this.m_bPrevStatus;
		}
		*/
		
	}
	this.processSearchWordSelect = function(index)
	{
		i = 0;
		eval('mysearch_' + index).style.backgroundColor='#FFF4EF';
		eval('mysearch_sub_' + index).style.color='#6F6A68';
		//eval('mysearch_sub_' + index).style.color='#FFFFFF';
	}
	this.processSearchWordOut = function(index)
	{
		eval('mysearch_' + index).style.backgroundColor='#FFFFFF';
		eval('mysearch_sub_' + index).style.color='#4F6973';
//		eval('mysearch_sub_' + index).style.color='#FFFFFF';
	}
	this.printMySearch = function()
	{
		var iCount = this.getSearchWordCount();
		if( iCount > this.m_iMaxSearchWordCount  )
		{
			iCount = this.m_iMaxSearchWordCount;
		}

		var i = 0;
		tmptable = '';

		
		tmptable += "<table width='338' height=24 border='0' cellpadding='0' cellspacing='1' bgcolor='#d2d2d2'><tr><td align='left' valign='top' bgcolor='#FFFFFF'><table width='100%' height='4'  border='0' cellpadding='0' cellspacing='0'><tr><td height='4'></td></tr></table>";
		tmptable += "<div id=wordview class=search_scrollbar style='width:" + 338+ "; FONT-SIZE: 10pt; overflow:auto; height:24; background:#FFFFFF; scrollbar-face-color:#F5F5F5; scrollbar-highlight-color:#FFFFFF; scrollbar-shadow-color:#CCCCCC; scrollbar-3dlight-color:#CCCCCC; scrollbar-arrow-color:#8D8D8D; scrollbar-track-color:#F5F5F5; scrollbar-darkshadow-color:#FFFFFF; scrollbar-base-color:#F5F5F5;'><table width='100%' border='0' cellpadding='0' height='24' cellspacing='0'>";
		tmptable +="<tr height='0'><td width='12'></td><td colspan='2'>ÇöÀç ÀÚµ¿¿Ï¼º ±â´ÉÀ» »ç¿ëÇÏ°í ÀÖ½À´Ï´Ù.</td><td width='17'></td></tr>";
		tmptable += "</table></div><table width='100%' height='24'  border='0' cellpadding='0' cellspacing='0'><tr bgcolor='#f2f2f2'><td width='12'>&nbsp;</td><td height='18'>";
		tmptable +="&nbsp;</td><td align='right'><a href='javascript:g_Recommend.setUse(false)'>´Ý±â</a></td><td width='17'>&nbsp;</td></tr></table></td></tr></table>";
		
		/*
		tmptable += "<table width='486' border='0' cellpadding='0' cellspacing='0'><tr><td colspan=5 bgcolor='ADCAC5' height=1> </td></tr>    <tr>   <td width='1' bgcolor='ADCAC5'></td>  <td width='12' background='/images/popular/bg.gif' style='filter: alpha(opacity=70);' bgcolor='ADCAC5'></td> <td align='center' valign='top'><table width='461' border='0' cellpadding='0' cellspacing='0'>        <tr>           <td height='24' bgcolor='4AAACE'><table width='100%' border='0' cellpadding='0' cellspacing='0'>              <tr>                 <td width='4%'><img src='/images/popular/icon_t.gif' width='14' height='11'></td>                <td width='72%' class='sc'><strong><font color='#FFFFFF'>³»°¡ Ã£Àº               °Ë»ö¾î </font></strong></td>                <td width='24%' align='right' class='sc'> ";
		
		//if( this.getUse() == false )
		
		tmptable += "<font color='#FFFFFF' onclick=g_Recommend.setUse(true) style='cursor:hand;'> ¾ËÂ¥°Ë»ö¾î</font>";
		
		
		tmptable +="</td>              </tr>            </table></td>        </tr>        <tr>          <td ><img src='/images/popular/bar03.gif' width='461' height='10'></td>        </tr>        <tr>           <td align='center' valign='top' background='/images/popular/bg_body2.gif'>";

		
		tmptable += "<div id=mysearchview class=search_scrollbar cellpadding='0' style=' MARGIN-TOP: 0px; width:" + 440 + "; overflow:auto; height:92px; scrollbar-face-color:#F5F5F5; scrollbar-highlight-color:#FFFFFF; scrollbar-shadow-color:#CCCCCC; scrollbar-3dlight-color:#CCCCCC; scrollbar-arrow-color:#8D8D8D; scrollbar-track-color:#F5F5F5; scrollbar-darkshadow-color:#FFFFFF; scrollbar-base-color:#F5F5F5;'>";
		tmptable+= "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";

		for( i = 0 ; i < iCount ; i ++ )
		{
			
			tmptable += "<tr style='cursor:hand;' id=mysearch_"+i+" onmouseover=g_Recommend.processSearchWordSelect("+i+") onMouseOut=g_Recommend.processSearchWordOut("+i+") onclick='g_Recommend.processClick(\""+ this.getSearchWord(i) +"\"); '> <td id=mysearch_sub_"+i+" width='416' height='18' class='sc'><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+ this.getSearchWord(i).cut(this.m_iPrintWordLength) +"</td> <td width='24' class='sc' onclick=\"g_Recommend.onClickDeleteButton("+ i  +"); return false;\"><img src='/images/popular/x.gif' width='9' height='9' align='absmiddle'></td></tr>";
			
		}

		tmptable += "</table></div><table width='440' border='0' cellpadding='0' cellspacing='0'>              <tr>                <td height='5' colspan='2' valign='bottom'></td>              </tr>              <tr>                 <td height='17' valign='bottom' bgcolor='EFF5F5'><a href='javascript:g_Recommend.onClickDeleteAllButton();'><img border=0 src='/images/popular/btn05.gif' width='65' height='17'></a></td>                <td align='right' valign='bottom' bgcolor='EFF5F5'><a href='javascript:g_Recommend.onClickDownButton()'> <img src='/images/popular/btn_close.gif' border=0 width=26 height=14></a><img src='/images/popular/r.gif' width='14' height='17'></td>              </tr>            </table></td>  </tr>        <tr>           <td><img src='/images/popular/bar04.gif' width='461' height='10'></td>        </tr>      </table>      <table width='461' border='0' cellpadding='0' cellspacing='0'>        <tr><td height='10' style='filter: alpha(opacity=70);' bgcolor='D0ECF5'></td></tr>      </table></td>  <td width='11' background='/images/popular/bg.gif' style='filter: alpha(opacity=70);' bgcolor='ADCAC5'></td><td width='1' bgcolor='ADCAC5'></td> </tr><tr><td colspan=5 bgcolor='ADCAC5' height=1> </td> </tr></table>";
		*/
		
		this.m_strDocumentType = 'MySearch';

		this.m_oPrintZone.innerHTML = tmptable;
		
		this.m_oPrintZone.style.display = ''; 

		
	}
	//////////////////////////////////////////////////////////

	this.printResult = function()
	{

		if( this.m_bEnabled == false ) return;   // »ç¿ë±â´ÉÀÌ ²¨Á® ÀÖÀ¸¸é ÇÁ¸°Æ® ÇÏÁö ¾Ê´Â´Ù.! 
		if( this.m_oInputBox.value == '' ) return;
		try{
			xmlDoc =  req.responseXML.documentElement;
			
			cnt=xmlDoc.getElementsByTagName("index").length;
			realcnt = cnt ; 
			//this.m_iElementLength = cnt;
			
			element = xmlDoc.getElementsByTagName("index");
						
			// Add XML element : URL 2008.02.11 by Chang Moon

			//ucnt=xmlDoc.getElementsByTagName("iurl").length;
			//this.m_iElementLength = ucnt;
			
			u_element = xmlDoc.getElementsByTagName("iurl");
			
			g_element = xmlDoc.getElementsByTagName("gubun");
			
			
			// Reverse xml Parsing 2008.02.27 
			rcnt=xmlDoc.getElementsByTagName("rindex").length;
			realrcnt = rcnt ;
			rev_element = xmlDoc.getElementsByTagName("rindex");
			rev_u_element = xmlDoc.getElementsByTagName("riurl");
			rev_g_element = xmlDoc.getElementsByTagName("rgubun");
			
			lastValuechk = 0 ;
			
			//°Ë»ö¹æÇâ Á¶È¸
			sm_element = xmlDoc.childNodes.item((rcnt*3)+(cnt*3)).getAttribute("smval");

			tmptable ='';
			var revi = 0;
			var j = 0 ;
			var arrayi = 0;
			
			var fwdtmpTable = '';
			var bwdtmpTable = '';
			var lineTable = '';
			
			
			
			
			//Ãâ·Â°¹¼ö Á¦ÇÑ ( Á¤¹æÇâ ¿ª¹æÇâ ) 			
			if ( sm_element == 0 ) {
					 	
				 lastValuechk = rcnt ; 				 
			} else {
			 	
				 lastValuechk = cnt ;	
				 arrayi = rcnt  ; 
			}
			
			
			// Á¤Á¶È¸ , ¿ªÁ¶È¸ °á°ú°¹¼ö ÇÕ 									
			this.m_iElementLength = rcnt + cnt;
			
			//word.innerHTML = '';

			//word.style.display='';

			
			
						
			/*tmptable += '<Table  border=0 style="width:' + this.m_oInputBox.style.width + '; FONT-SIZE: 8pt;" bgcolor=#F5F5F5>';
			tmptable += "<tr bgcolor=#DDDDDD height=18 valign=center><td valign=center><b><font color=#434343>°Ë»ö¾î ÃßÃµ</font></b>&nbsp;<a href='javascript:g_Recommend.setMode(0);'>´Ü¾î~</a> &nbsp;&nbsp; <a href='javascript:g_Recommend.setMode(1);' >~´Ü¾î</a> &nbsp;<a href='javascript:g_Recommend.doMore();'>more</a> <a href='javascript:g_Recommend.setUse(false)'>X </a></td></tr><table>";*/
			

			//////////////////////////////  ¹Ù·Î Àü°Í
			/*tmptable+="<table width='" + this.m_oInputBox.style.width + "' height='140' border='0' cellpadding='2' cellspacing='1' bgcolor='ADCAC5'>  <tr>    <td align='center' valign='top' background='/images/popular/bg.gif'><table width='233' border='0' cellpadding='0' cellspacing='0'>        <tr>           <td height='20' bgcolor='249AC0'><table width='100%' border='0' cellpadding='0' cellspacing='0'>              <tr>                 <td width='9%'><img src='/images/popular/icon_t.gif' width='14' height='11'></td>                <td width='52%' class='sc'><strong><font color='#FFFFFF'>¾ËÂ¥°Ë»ö¾î</font></strong></td>                <td width='23%'><img src='/images/popular/btn01.gif' width='44' height='15'></td>                <td width='16%'><img src='/images/popular/btn02.gif' width='44' height='15'></td>              </tr>            </table></td>        </tr>        <tr>           <td height='107' align='center' valign='top' background='/images/popular/bg_body.gif'> ";*/ 
				////////////////////// ¹Ù·Î Àü°Í ³¡.

			//tmptable+= "<table width='486' border='0' cellpadding='0' cellspacing='0' ><tr><td colspan=5 bgcolor='ADCAC5' height=1> </td>  <tr>    <td width='1' bgcolor='ADCAC5'></td>  <td width='12' background='/images/popular/bg.gif' style='filter: alpha(opacity=70);' bgcolor='ADCAC5'></td> <td align='center' valign='top' ><table width='461' border='0' cellpadding='0' cellspacing='0'>        <tr>           <td height='24' bgcolor='4AAACE'><table width='100%' border='0' cellpadding='0' cellspacing='0'>              <tr>                 <td width='20'><img src='/images/popular/icon_t.gif' width='14' height='11'></td>                <td width='67' valign='bottom' class='sc'><strong><font color='#FFFFFF'>¾ËÂ¥°Ë»ö¾î</font></strong></td>                <td width='50' valign='bottom'><a href='javascript:g_Recommend.setMode(0);'><img border=0 src='/images/popular/btn01.gif' width='44' height='15'></a></td>                <td width='55' valign='bottom'><a href='javascript:g_Recommend.setMode(1);'><img border=0 src='/images/popular/btn02.gif' width='44' height='15'></a></td>                <td width='20' class='sc'><a href='javascript:g_Recommend.doLess();'><img src='/images/popular/btn_b.gif' width='12' height='12' border='0'></a></td>                <td><a href='javascript:g_Recommend.doMore();'><img src='/images/popular/btn_f.gif' width='12' height='12' border='0' align='absmiddle'></a></td>                <td align='right' valign='bottom' width=62 class='sc'><font color='#FFFFFF' onclick=g_Recommend.setUse(false) style='cursor:hand;'>»ç¿ë¾ÈÇÏ±â</font></td>             </tr>            </table></td>        </tr>        <tr>           <td><img src='/images/popular/bar03.gif' width='461' height='19'></td>        </tr>        <tr>          <td align='center' valign='top' background='/images/popular/bg_body2.gif'>";
			
			var suggestBoxHeight=0;
			
			
			suggestBoxHeight = (cnt * 18) + (rcnt * 18) + 1;
			if ( cnt > 0  && rcnt > 0 ) {
				suggestBoxHeight = suggestBoxHeight + 20 ;
			}	
			
				
			
			
			tmptable+= "<table width='338' height="+suggestBoxHeight+" border='0' cellpadding='0' cellspacing='1' bgcolor='#d2d2d2'><tr><td align='left' valign='top' bgcolor='#FFFFFF'><table width='100%' height='4'  border='0' cellpadding='0' cellspacing='0'><tr><td height='4'></td></tr></table>";





			//tmptable += "<div id=wordview class=search_scrollbar style='width:" + 440 + "; FONT-SIZE: 10pt; overflow:auto; height:92px; background:#FFFFFF; scrollbar-face-color:#F5F5F5; scrollbar-highlight-color:#FFFFFF; scrollbar-shadow-color:#CCCCCC; scrollbar-3dlight-color:#CCCCCC; scrollbar-arrow-color:#8D8D8D; scrollbar-track-color:#F5F5F5; scrollbar-darkshadow-color:#FFFFFF; scrollbar-base-color:#F5F5F5;'><table width='100%' border='0' cellpadding='0' cellspacing='0'>";
			//tmptable += "<div id=wordview class=search_scrollbar style='width:" + 348+ "; FONT-SIZE: 10pt; overflow:auto; height:92px; background:#FFFFFF; scrollbar-face-color:#F5F5F5; scrollbar-highlight-color:#FFFFFF; scrollbar-shadow-color:#CCCCCC; scrollbar-3dlight-color:#CCCCCC; scrollbar-arrow-color:#8D8D8D; scrollbar-track-color:#F5F5F5; scrollbar-darkshadow-color:#FFFFFF; scrollbar-base-color:#F5F5F5;'><table width='100%' border='0' cellpadding='0' height='"+suggestBoxHeight+"' cellspacing='0'>";
			
			
			//tmptable += "<div id=wordview class=search_scrollbar style='width:" + 348+ "; FONT-SIZE: 10pt; overflow:auto; height:"+suggestBoxHeight+"; background:#FFFFFF; scrollbar-face-color:#F5F5F5; scrollbar-highlight-color:#FFFFFF; scrollbar-shadow-color:#CCCCCC; scrollbar-3dlight-color:#CCCCCC; scrollbar-arrow-color:#8D8D8D; scrollbar-track-color:#F5F5F5; scrollbar-darkshadow-color:#FFFFFF; scrollbar-base-color:#F5F5F5;'><table width='100%' border='0' cellpadding='0' height='"+suggestBoxHeight+"' cellspacing='0'>";
			tmptable += "<div id=wordview class=sbody style='width:" + 338+ "; FONT-SIZE: 10pt; overflow:auto; height:"+suggestBoxHeight+"; background:#FFFFFF; '><table width='100%' border='0' cellpadding='0' height='"+suggestBoxHeight+"' cellspacing='0'>";
			// Á¤Á¶È¸ °á°ú
			
			
			
			
			
			for( i = 0 ; i < cnt ; i ++ )
			{
				content_text =xmlDoc.childNodes.item(i).getAttribute("text");
				this.m_arrRecommendWords[arrayi] = content_text;
				
				content_url =xmlDoc.childNodes.item(i+cnt).getAttribute("url");	
				this.m_arrRecommendURLs[arrayi] = content_url ; 
				
				content_gubun =xmlDoc.childNodes.item(i+(cnt*2)).getAttribute("val");	
				this.m_arrRecommendGUBUNs[arrayi] = content_gubun ; 
				
				/*tmptable += "<div id=n_" + i + " align=Left height=" + this.m_iWordsHeight +" onMouseOver=g_Recommend.processSelect("+ i + ") onMouseOut=\"this.style.backgroundColor=''\" onclick='g_Recommend.processClick(\""+ content_text +"\"); '  style=\"FONT-SIZE: 10pt;cursor:hand;background:#FFFFFF;\"  >";
		//		tmptable += "<tr id=n_" + i + " align=Left height=20 onclick='processClick(\""+ temp +"\"); '><td>";
				tmptable += '<font color=#222222>';
				tmptable += '¡¤ ';
				tmptable += content_text;
				tmptable += '</font>';
				tmptable += '</div>';*/
		
				
				// gubun °ª¿¡ µû¶ó ¸µÅ© ¿¬°á À§Ä¡ ¹Ý¿µ
				// url : »õÃ¢ / sangho : °Ë»ö°á°ú
				// 2008.2.18 by Chang moon


				
				if ( content_gubun == "url" ) {					
      					
      					fwdtmpTable +="<tr id=n_"+arrayi+" onMouseOver=g_Recommend.processSelect("+ arrayi + ") onMouseOut=g_Recommend.processOut("+arrayi+") >";
          				fwdtmpTable +="<td width='12'>&nbsp;</td>";
          				fwdtmpTable +="<td id=n_sub_"+arrayi+" width='150' height='18'  onclick='g_Recommend.processClick(\""+ content_text +"\"); ' style='cursor:hand;' >"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td>";
          				fwdtmpTable +="<td align='right' class='green' onclick=\"javascript:hanurlWindow('http://"+content_url+"');\" style='cursor:hand;' ><span class='green'>"+content_url+"</span></td>";
          				fwdtmpTable +-"<td width='17'>&nbsp;</td></tr>";
					
				} else if ( content_gubun == "product" ) {
					//tmptable +="<tr id=n_"+i+" onMouseOver=g_Recommend.processSelect("+ i + ") onMouseOut=g_Recommend.processOut("+i+") style='cursor:hand;' ><td id=n_sub_"+i+" height='19' class='sc'  onclick='g_Recommend.processClick(\""+ content_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right >&nbsp;</td><td>&nbsp;&nbsp;</td></tr>";
										
      					fwdtmpTable +="<tr id=n_"+arrayi+" onmouseover=g_Recommend.processSelect("+ arrayi + ") onmouseout=g_Recommend.processOut("+arrayi+") >";
          				fwdtmpTable +="<td width='12'>&nbsp;</td>";
          				fwdtmpTable +="<td id=n_sub_"+arrayi+" width='150' height='18' onclick='g_Recommend.processClick(\""+ content_text +"\"); '  style='cursor:hand;'  >"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td>";
          				fwdtmpTable +="<td align='right' class='green' >&nbsp;</td> ";
          				fwdtmpTable +-"<td width='17'>&nbsp;</td></tr>";
										
				} else {					
					//tmptable +="<tr id=n_"+i+" onMouseOver=g_Recommend.processSelect("+ i + ") onMouseOut=g_Recommend.processOut("+i+") style='cursor:hand;' ><td id=n_sub_"+i+" height='19' class='sc'  onclick='g_Recommend.processClick(\""+ content_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right onclick=\"javascript:alert(i);\"><font color='#27a118'>"+content_url+"</font></td><td>&nbsp;&nbsp;</td></tr>";
					
					//tmptable +="<tr id=n_"+i+" onMouseOver=g_Recommend.processSelect("+ i + ") onMouseOut=g_Recommend.processOut("+i+") style='cursor:hand;' ><td id=n_sub_"+i+" height='19' class='sc'  onclick='g_Recommend.processClick(\""+ content_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right onclick=\"javascript:searchKeyword('"+content_url+"');\"><font color='#27a118'>"+content_url+"</font></td><td>&nbsp;&nbsp;</td></tr>";
					
      					fwdtmpTable +="<tr id=n_"+arrayi+" onmouseover=g_Recommend.processSelect("+ arrayi + ") onmouseout=g_Recommend.processOut("+arrayi+") >";
          				fwdtmpTable +="<td width='12'>&nbsp;</td>";
          				fwdtmpTable +="<td id=n_sub_"+arrayi+" width='150' height='18' onclick='g_Recommend.processClick(\""+ content_text +"\"); '  style='cursor:hand;' >"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td>";
          				fwdtmpTable +="<td align='right' class='green' onclick=\"javascript:searchKeyword('"+content_url+"');\" ><span class='green' style='cursor:hand;'>"+content_url+"</span></td>";
          				fwdtmpTable +-"<td width='17'>&nbsp;</td></tr>";
				}
				
			
				revi = i+(cnt*2) ; 
				j = i+1 ; 
				arrayi++;	
			}
			
			// ±¸ºÐ°ª¶óÀÎ Á¸Àç¿©ºÎ  2008.2.27 by Chang Moon									
			if ( lastValuechk > 0 ) {				
				lineTable +="<tr height='18' ><td width='12'>&nbsp;</td><td colspan='2'><hr width='100%' size='1' style='color:#DADFE3'></td><td width='17'>&nbsp;</td></tr>";
			} else {
				lineTable +="<tr height='0'><td width='12'></td><td colspan='2'></td><td width='17'></td></tr>";
			}
			
			
			if ( sm_element == 1 ) {			
				j = 0;
			}
			
			// ¿ª¹æÇâ Á¶È¸ 
			for( i = 0 ; i < rcnt ; i ++ )
			{
				if ( revi > 0 ) {
					revplusone = revi +1 ;
				} else {
					revplusone = revi  ;
				}
				
				rcontent_text =xmlDoc.childNodes.item(revplusone).getAttribute("rtext");				
				this.m_arrRecommendWords[j] = rcontent_text;
				
				rcontent_url =xmlDoc.childNodes.item(revplusone+rcnt).getAttribute("rurl");	
				this.m_arrRecommendURLs[j] = rcontent_url; 
				
				rcontent_gubun =xmlDoc.childNodes.item(revplusone+(rcnt*2)).getAttribute("rval");	
				this.m_arrRecommendGUBUNs[j] = rcontent_gubun; 
				
				
					
				// gubun °ª¿¡ µû¶ó ¸µÅ© ¿¬°á À§Ä¡ ¹Ý¿µ
				// url : »õÃ¢ / sangho : °Ë»ö°á°ú
				// 2008.2.18 by Chang moon


				if ( rcontent_gubun == "url" ) {
					//tmptable +="<tr id=n_"+j+" onMouseOver=g_Recommend.processSelect("+ j + ") onMouseOut=g_Recommend.processOut("+j+") style='cursor:hand;' ><td id=n_sub_"+j+" height='19' class='sc' onclick='g_Recommend.processClick(\""+ rcontent_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,rcontent_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right onclick=\"javascript:hanurlWindow('http://"+rcontent_url+"');\"><font color='#27a118'>"+rcontent_url+"</font></td><td>&nbsp;&nbsp;</td></tr>";
      					
      					bwdtmpTable +="<tr id=n_"+j+" onmouseover=g_Recommend.processSelect("+ j + ") onmouseout=g_Recommend.processOut("+j+") >";
          				bwdtmpTable +="<td width='12'>&nbsp;</td>";
          				bwdtmpTable +="<td id=n_sub_"+j+" width='150' height='18' onclick='g_Recommend.processClick(\""+ rcontent_text +"\"); '  style='cursor:hand;' >"+replaceQuery(this.m_strLastSearchValue,rcontent_text.cut(this.m_iPrintWordLength ) )+"</td>";
          				bwdtmpTable +="<td align='right' class='green' onclick=\"javascript:hanurlWindow('http://"+rcontent_url+"');\" style='cursor:hand;' ><span class='green'>"+rcontent_url+"</span></td>";
          				bwdtmpTable +-"<td width='17'>&nbsp;</td></tr>";				
        					
				} else if ( rcontent_gubun == "product" ) {
					//tmptable +="<tr id=n_"+j+" onMouseOver=g_Recommend.processSelect("+ j + ") onMouseOut=g_Recommend.processOut("+j+") style='cursor:hand;' ><td id=n_sub_"+j+" height='19' class='sc'  onclick='g_Recommend.processClick(\""+ rcontent_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,rcontent_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right >&nbsp;</td><td>&nbsp;&nbsp;</td></tr>";
										
      					bwdtmpTable +="<tr id=n_"+j+" onmouseover=g_Recommend.processSelect("+ j + ") onmouseout=g_Recommend.processOut("+j+") >";
          				bwdtmpTable +="<td width='12'>&nbsp;</td>";
          				bwdtmpTable +="<td id=n_sub_"+j+" width='150' height='18' onclick='g_Recommend.processClick(\""+ rcontent_text +"\"); '  style='cursor:hand;' >"+replaceQuery(this.m_strLastSearchValue,rcontent_text.cut(this.m_iPrintWordLength ) )+"</td>";
          				bwdtmpTable +="<td align='right' class='green' >&nbsp;</td>";
          				bwdtmpTable +-"<td width='17'>&nbsp;</td></tr>";					
				} else {					
					//tmptable +="<tr id=n_"+i+" onMouseOver=g_Recommend.processSelect("+ i + ") onMouseOut=g_Recommend.processOut("+i+") style='cursor:hand;' ><td id=n_sub_"+i+" height='19' class='sc'  onclick='g_Recommend.processClick(\""+ content_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,content_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right onclick=\"javascript:alert(i);\"><font color='#27a118'>"+content_url+"</font></td><td>&nbsp;&nbsp;</td></tr>";
					//tmptable +="<tr id=n_"+j+" onMouseOver=g_Recommend.processSelect("+ j + ") onMouseOut=g_Recommend.processOut("+j+") style='cursor:hand;' ><td id=n_sub_"+j+" height='19' class='sc'  onclick='g_Recommend.processClick(\""+ rcontent_text +"\"); ' ><img src='/images/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+replaceQuery(this.m_strLastSearchValue,rcontent_text.cut(this.m_iPrintWordLength ) )+"</td><td align=right onclick=\"javascript:searchKeyword('"+rcontent_url+"');\"><font color='#27a118'>"+rcontent_url+"</font></td><td>&nbsp;&nbsp;</td></tr>";

      					bwdtmpTable +="<tr id=n_"+j+"  onmouseover=g_Recommend.processSelect("+ j + ") onmouseout=g_Recommend.processOut("+j+") >";
          				bwdtmpTable +="<td width='12'>&nbsp;</td>";
          				bwdtmpTable +="<td id=n_sub_"+j+" width='150' height='18' onclick='g_Recommend.processClick(\""+ rcontent_text +"\"); '  style='cursor:hand;' >"+replaceQuery(this.m_strLastSearchValue,rcontent_text.cut(this.m_iPrintWordLength ) )+"</td>";
          				bwdtmpTable +="<td align='right' class='green' onclick=\"javascript:searchKeyword('"+rcontent_url+"');\" ><span class='green' style='cursor:hand;' >"+rcontent_url+"</span></td>";
          				bwdtmpTable +-"<td width='17'>&nbsp;</td></tr>";					
					
				}				
 
 			
				revi++;
				j++;
					
			}
			
			if ( sm_element == 0 ) {	//Á¤¹æÇâ Á¶È¸
				tmptable += fwdtmpTable +""+ lineTable +""+ bwdtmpTable ; 
			
			} else {		//¿ª¹æÇâ Á¶È¸
				tmptable += bwdtmpTable +""+ lineTable +""+ fwdtmpTable ; 
			}
		
				



			//tmptable += '</table></div>';

			//tmptable += "</td>        </tr>        <tr>          <td><img src='/images/popular/bar04.gif' width='461' height='12'></td>        </tr>      </table>      <table width='461'  border='0' cellpadding='0' cellspacing='0'>        <tr><td height='10' style='filter: alpha(opacity=70);' bgcolor='D0ECF5'></td></tr></table></td> <td width='11' background='/images/popular/bg.gif' style='filter: alpha(opacity=70);' bgcolor='ADCAC5'></td><td width='1' bgcolor='ADCAC5'></td> </tr><tr><td colspan=5 bgcolor='ADCAC5' height=1> </td> </tr></table></body>";

			tmptable += "</table></div><table width='100%' height='24'  border='0' cellpadding='0' cellspacing='0'><tr bgcolor='#f2f2f2'><td width='12'>&nbsp;</td><td height='18'>";
			
			if ( lastValuechk > 0 ) {
			
				if ( sm_element == 0 ) {
					tmptable +="<a href='javascript:g_Recommend.setMode(1);'>³¡´Ü¾î´õº¸±â</a>";
				} else {
					tmptable +="<a href='javascript:g_Recommend.setMode(0);'>Ã¹´Ü¾î´õº¸±â</a>";
				}
			} else {
				tmptable += "&nbsp;";	
			}
			
			
			tmptable +="</td><td align='right'><a href='javascript:g_Recommend.setUse(false)'>´Ý±â</a></td><td width='17'>&nbsp;</td></tr></table></td></tr></table>";

			// ¹Ù·Î Àü°Í
			/*tmptable += ' </td>        </tr>      </table></td>  </tr></table></body></html>';*/
			// ¹Ù·Î Àü°Í ³¡ 
			this.m_strDocumentType = 'Alzza';
			if( cnt == 0 ) tmptable = '';
			this.m_oPrintZone.style.display = '';
		}
		catch(e)
		{
			return;
		}
		
		this.m_oPrintZone.innerHTML = tmptable;
		
	}
	
	this.processReqChange = function()
	{
		
		// only if req shows "loaded"
		if (req.readyState == 4) 
		{
			// only if "OK"
			if (req.status == 200) 
			{
					g_Recommend.printResult();
			}
			else 
			{
					//alert("There was a problem retrieving the XML data:\n" + req.statusText);
			}
		}
	}
	
	this.processDeselectAll = function()
	{
		i = 0;
		try {
			while( eval('n_' + i ) )
			{
				eval('n_' + i).style.backgroundColor=''; 	
				i++;
			}
		}
		catch(e)
		{

		}
		this.m_iCurFocusIndex=-1;
	}
	
	this.processSelect = function(index)
	{
		i = 0;
		this.m_iCurFocusIndex=index;
		try {

			while( eval('n_' + i ) )
			{
				if( i != index ) 
				{
					eval('n_' + i).style.backgroundColor=''; 	
					eval('n_sub_' + index).style.color='#4F6973';
				}
				else
				{
					//eval('n_' + index).style.backgroundColor='#FFE5DB';
					eval('n_' + index).style.backgroundColor='#F5F5F5';
					eval('n_sub_' + index).style.color='#6F6A68';
				}
		//		alert(i);
				i++;
			}
		}
		catch(e)
		{

		}
	}
	/*this.processSelect = function(index)
	{
		eval('n_' + index).style.backgroundColor='#FFE5DB'; 
		eval('n_sub_' + index).style.color='#6F6A68';
	}*/
	this.processOut = function(index)
	{
		eval('n_' + index).style.backgroundColor='#FFFFFF'; 
		eval('n_sub_' + index).style.color='#4F6973';

	}

	this.doMore = function()
	{

		this.m_iSearchStep++;
		
		//searchword = this.m_oInputBox.value;
		searchword = this.m_strLastSearchValue
		this.loadDocument(searchword);
	}
	this.doLess = function()
	{
		if( this.m_iSearchStep > 0 )
		{
			this.m_iSearchStep--;
//			searchword = this.m_oInputBox.value;
			searchword = this.m_strLastSearchValue
			this.loadDocument(searchword);

		}

	}

	this.setMode = function(value)
	{
		this.m_iSearchStep = 0;
		this.m_iSearchMode = value;
		searchword = this.m_oInputBox.value;
		this.loadDocument(searchword);
		this.m_iSearchMode = 0;  // ÇÑ¹ø¸¸ °¡´ÉÇÏ°Ô!! (³Ê¹« ºÎÇÏ°¡ Å©´Ù)
	}

	this.loadDocument = function(searchword)
	{
		
		if( this.m_bEnabled == false ) return;   // »ç¿ë±â´ÉÀÌ ²¨Á® ÀÖÀ¸¸é xml request¸¦ ´øÁöÁö ¾Ê´Â´Ù.
		if( searchword != '' )
		{
			
			splitword = spl(searchword);  // ±ÛÀÚ¸¦ Ä¡¸é ¸Å¹ø ÃÊ¼ºÁß¼ºÁ¾¼ºÀ¸·Î ÂÉ°·
			
			reverseword = rspl(searchword);
			splitword = splitword.toLowerCase();
			reverseword = reverseword.toLowerCase();
			
//			alert('xmldata3.xml?step='+ this.m_iSearchStep + '&sm='+this.m_iSearchMode +'&name='+splitword +'&rname=' + reverseword );
			this.loadXMLDoc('/xmldata_mysql_0227.php?step='+ this.m_iSearchStep + '&sm='+this.m_iSearchMode +'&name='+splitword +'&rname=' + reverseword );   // xmlµ¥ÀÌÅÍ ºÒ·¯¿È
			//this.loadXMLDoc('/xmldata_oracle_0211.php?step='+ this.m_iSearchStep + '&sm='+this.m_iSearchMode +'&name='+splitword +'&rname=' + reverseword );   // xmlµ¥ÀÌÅÍ ºÒ·¯¿È
			
		}
	}

	this.processClick = function(query)
	{
		//searchtable.focus();
		this.m_bEnabled = false;
		this.m_bCheckFlag = false;
		this.m_oInputBox.value = query;
		this.m_oPrintZone.style.display='none';
		selectbox_visible();

		this.onSubmit();    // ³ªÁß¿¡ ¿À¹ö¶óÀÌµå ÇØ¾ßÇÔ
	}

	this.onSubmit = function()	// ³ªÁß¿¡ ¿À¹ö¶óÀÌµå ÇØ¾ßÇÔ
	{
		
	}

	this.reverseStatus = function()
	{


		if( this.m_bEnabled )
		{
			if( this.getDocumentType() == 0 )
			{
			if( this.m_oPrintZone )
			{
				if( this.m_oPrintZone.style.display=='none' )
				{ 
					
						if( this.m_oInputBox )
						{
							if( this.m_oInputBox.value != '' )
							{
								
								this.m_oPrintZone.style.display='';
								if( this.m_oPrintZone.innerHTML == '' )
								{
									this.loadDocument(this.m_oInputBox.value);									
								}
							}
						}

				}
				else
				{
					this.m_bCheckFlag = false;
					this.m_oPrintZone.style.display='none';
					selectbox_visible();
					this.processDeselectAll();
				}
			}
			}
		}
		return true;
	}

	
	this.processSearch =  function()
	{	
		// È­»ìÇ¥ ¾Æ·¡:40 À§:38   ¡¤
		this.m_iSearchStep = 0;

//		othercounter++;
		//document.getElementById('testjin2').innerHTML = 'Typed Count:' + othercounter + 'KeyCode:'+ event.keyCode;
//		document.getElementById('testjin2').innerHTML += event.keyCode + ':';
		if( event.keyCode == 40 || event.keyCode == 38 || event.keyCode == 13 || event.keyCode ==229)
		{
			return true;
		}
		else // È­»ìÇ¥µîÀÌ ¾Æ´Ñ Á¤»óÀûÀÎ Å° ÀÔ·ÂÀÎ°æ¿ì 
		{
			
				
	

			if( this.m_bEnabled == true )
			{
				this.m_bCheckFlag = true;  // ½Ç½Ã°£ Ã¼Å© ±â´ÉÀ» µ¿ÀÛÇÏµµ·Ï ÇÑ´Ù.
				if( this.m_oInputBox.value == '' ) // ÀÎÇ² ¹Ú½º¿¡ ¾Æ¹« ±ÛÀÚµµ ¾ø´Â °æ¿ì 
				{
					this.m_oPrintZone.style.display='none';  // ·¹ÀÌ¾î¸¦ º¸ÀÌÁö ¾Ê°Ô ÇÑ´Ù.
					selectbox_visible();
					
					// Add arrow down image 2008.03.03 
					this.m_oArrowImage.src = this.m_strDownArrow;
					
					return true; // jin test
				}



				
				//this.m_oPrintZone.style.display='';
				if( this.m_oInputBox.value != '' )
				{
					
					// Add arrow up image 2008.03.03 
					this.m_oArrowImage.src = this.m_strUpArrow;
					
					if( this.m_strLastSearchValue != this.m_oInputBox.value )
					{
						this.loadDocument(this.m_oInputBox.value);
						this.m_strLastSearchValue = this.m_oInputBox.value;
					}
				}
				else
				{
					this.m_oPrintZone.innerHTML = '';
				}
			}
		}
		return true; // jin test
	}

	this.CheckHandler = function ()
	{
		
		
		if( this.m_bCheckFlag == true )
		{
			g_Recommend.CheckHandlerReal();	
		}
		
		window.setTimeout("g_Recommend.CheckHandler()",200);
		
	}

	this.CheckHandlerReal = function ()
	{

		//tempcounter = tempcounter +1;
		/*document.getElementById('testjin').innerHTML = '23:'+tempcounter + ':' +this.m_bCheckFlag
			+ ':' + this.m_oPrintZone.style.display + ':' + this.m_oInputBox.value + ':¹öÆ°:';*/

		if( this.m_strLastSearchValue != this.m_oInputBox.value )
		{
			this.loadDocument(this.m_oInputBox.value);
			this.m_strLastSearchValue = this.m_oInputBox.value;
		}

		//2005-07-22 Á¤Áø¼®ÀÓ½Ã
/*		if( this.m_oInputBox.value == '' )
		{
			this.m_oPrintZone.innerHTML = '';
		}*/
		

	}

	this.scrollWordView = function(iPos)
	{
		wordview.scrollTop = iPos * (this.m_iWordsHeight - 3);
	}
	this.KeyHandler = function()
	{
		// ÀÌº¥Æ® ÇÚµé·¯¿¡¼­ È£Ãâ µÈ°æ¿ì´Â ½ÇÁ¦·Î this. °¡ ÀÚ±âÀÚ½ÅÀ» ÂüÁ¶ÇÏ°í ÀÖÁö ¾Ê´Ù.
		return g_Recommend.KeyHandlerReal();
	}
	
	this.KeyHandlerReal = function()
	{
//		othercounter++;
//		document.getElementById('testjin2').innerHTML = 'Typed Count_from Body:' + othercounter;
//		document.getElementById('testjin2').innerHTML += event.keyCode + ':';
		if( this.m_bEnabled )
		{
			if( this.m_iElementLength > 0) 
			{
				
				if( event.keyCode == 40)  // È­»ìÇ¥ ¾Æ·¡ÂÊ
				{
					
					if( this.m_oInputBox.value == '' ) return ;					
					if( this.m_bHasFocus == true )
					{
						
						this.m_bCheckFlag=false;
						this.m_oInputBox.blur();
						this.m_strLastWord = this.m_oInputBox.value;
						this.m_oPrintZone.style.display='';
						this.processSelect(0);
						this.m_iCurFocusIndex = 0;

						// Ã³À½ ¾Æ·¡·Î ³»¸®±â ¶§¹®¿¡ ·¹ÀÌ¾îÀÇ ½ºÅ©·Ñ¹Ù¸¦ °¡Àå À§·Î ¿Ã¸°´Ù.
						wordview.scrollTop = 0;
						this.m_iCurrentScrollPos = 0;
						// ½ºÅ©·Ñ Ã³¸® ³¡ 
						
						this.m_oInputBox.value = this.m_arrRecommendWords[this.m_iCurFocusIndex]; 
						
						return false;
						
					}
					else
					{
						if( this.m_oPrintZone.style.display == 'none' ) return true;   // ·¹ÀÌ¾î°¡ ¼û¾îÀÖ´Â °æ¿ì È­»ìÇ¥¾Æ·¡°¡ Å¬¸¯ÇÏ¸é ¹«½Ã 

						if( this.m_iCurFocusIndex != -1 )
						{
							if( this.m_iElementLength > this.m_iCurFocusIndex + 1 )
							{
								this.processSelect( this.m_iCurFocusIndex + 1 );
								this.m_oInputBox.value =this.m_arrRecommendWords[this.m_iCurFocusIndex]; 



								// ½ºÅ©·Ñ Ã³¸® ½ÃÀÛ
								if( this.m_iFixedWords <=
								(this.m_iCurFocusIndex - this.m_iCurrentScrollPos ) )
								{
									this.m_iCurrentScrollPos++;
									this.scrollWordView(this.m_iCurrentScrollPos);
								}
								// ½ºÅ©·Ñ Ã³¸® ³¡
			
							}
							return false;
						}
						else
						{
							return true;
						//	document.getElementById('new_search').value = arrQuery[curFocusIndex]; 
						}
						
					}

				}
				else if( event.keyCode == 38 ) // È­»ìÇ¥ À§ÂÊ
				{
					if( this.m_bHasFocus == true )
					{
						return false;
					}
					else
					{
						if( this.m_oPrintZone.style.display == 'none' ) return true;   // ·¹ÀÌ¾î°¡ ¼û¾îÀÖ´Â °æ¿ì È­»ìÇ¥¾Æ·¡°¡ Å¬¸¯ÇÏ¸é ¹«½Ã 

						if( this.m_iCurFocusIndex != -1 )
						{
							if( 0 <= this.m_iCurFocusIndex - 1 )
							{
								this.processSelect( this.m_iCurFocusIndex - 1 );
								this.m_oInputBox.value = this.m_arrRecommendWords[this.m_iCurFocusIndex]; 

								// ½ºÅ©·Ñ Ã³¸® ½ÃÀÛ
								if( 0 >
								(this.m_iCurFocusIndex - this.m_iCurrentScrollPos ) )
								{
									this.m_iCurrentScrollPos--;
									this.scrollWordView(this.m_iCurrentScrollPos);
									
								}
								// ½ºÅ©·Ñ Ã³¸® ³¡
			
								return false;
							}
							else
							{
								this.m_oPrintZone.style.display='none';
								selectbox_visible();
								this.m_oInputBox.value = this.m_strLastWord;
								this.m_oInputBox.focus();
								this.m_bCheckFlag=true;
								// À§·Î¿Ã¸®¸é¼­ °Ë»ö¾î ÀÔ·Â¹Ú½º·Î Æ÷Ä¿½º°¡±â ¶§¹®¿¡ ½ºÅ©·ÑÀº 0À¸·Î ¼ÂÆÃ (È®ÀÎ»ç»ì)
								wordview.scrollTop = 0;
								this.m_iCurrentScrollPos = 0;
								return false;
								// ½ºÅ©·Ñ Ã³¸® ³¡ 
							}
						}
						
					}
				}
				else if( event.keyCode == 13 ) // ¿£ÅÍ¸¦ Ä£°æ¿ì 
				{

					if( this.m_bHasFocus == false )
					{
						
						if(  this.m_iCurFocusIndex != -1 )   
						{
							this.m_bEnabled = false;
							this.m_bCheckFlag = false;
							this.m_oInputBox.value = this.m_arrRecommendWords[this.m_iCurFocusIndex]; 
							this.m_oPrintZone.style.display='none';
							selectbox_visible();
							this.m_oInputBox.focus();
							this.m_bEnabled = false;
							this.m_bCheckFlag = false;

							//return false;
							
						}
					}
				}
			}
		} // if( this.m_bEnabled ) 
		return true;
	} 

	this.onSearchFocus = function()
	{
		//this.m_bCheckFlag=true;
		this.m_bHasFocus=true;
		return true;
	}

	this.onSearchBlur = function()
	{
		//this.m_bCheckFlag=false;
		this.m_bHasFocus=false;
		return true;
	}
}




//////////////////////////////////
// GetCookie(ÄíÅ°ÀÌ¸§);
function CCookie()
{
	this.GetCookie = function(name) {  
			var arg = name + "=";  
			var alen = arg.length;  
			var clen = document.cookie.length;  
			var i = 0;  
			while (i < clen) {    
			var j = i + alen;    
			if (document.cookie.substring(i, j) == arg)      
					return this.getCookieVal (j);    
					i = document.cookie.indexOf(" ", i) + 1;    
					if (i == 0) break;   
			}  
			return null;
	}

	// ÄíÅ°¸¦ ±Á´Â ÇÔ¼öÀÔ´Ï´Ù.
	// php ÀÇ setcookie() ÇÔ¼ö¿Í µ¿ÀÏÇÏ°Ô »ç¿ëÇÏ¸é µË´Ï´Ù.
	// SetCookie (ÄíÅ°ÀÌ¸§,°ª,º¸°ü½Ã°£,µð·ºÅä¸®,µµ¸ÞÀÎ,....);


	this.SetCookie = function(name, value) {  
			var argv = this.SetCookie.arguments;  
			var argc = this.SetCookie.arguments.length;  
			var expires = (argc > 2) ? argv[2] : null;  
			var path = (argc > 3) ? argv[3] : null;  
			var domain = (argc > 4) ? argv[4] : null;  
			var secure = (argc > 5) ? argv[5] : false;  
			document.cookie = name + "=" + escape (value) + 
			((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
			((path == null) ? "" : ("; path=" + path)) +  
			((domain == null) ? "" : ("; domain=" + domain)) +    
			((secure == true) ? "; secure" : "");
	}


	// ÄíÅ°¸¦ Áö¿ì´Â ÇÔ¼ö ÀÔ´Ï´Ù.
	// DeleteCookie (ÄíÅ°ÀÌ¸§);
	this.DeleteCookie = function  (name) {  
			var exp = new Date();  
			exp.setTime (exp.getTime() - 1);  
			// This cookie is history  
			var cval = GetCookie (name);  
			document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}

	//GetCookie() ¿¡¼­ »ç¿ëÇÏ´Â ÇÔ¼ö µû·Î ¾µÀÏÀº ¾ø½À´Ï´Ù.:)
	this.getCookieVal = function(offset) {  
			var endstr = document.cookie.indexOf (";", offset);  
			if (endstr == -1)    
					endstr = document.cookie.length;  
					return unescape(document.cookie.substring(offset, endstr));
	}

}

function selectbox_hidden(layer_id) 
    { 
        var ly = eval(layer_id); 

        // ·¹ÀÌ¾î ÁÂÇ¥ 
        var ly_left  = ly.offsetLeft; 
        var ly_top    = ly.offsetTop; 
        var ly_right  = ly.offsetLeft + ly.offsetWidth; 
        var ly_bottom = ly.offsetTop + ly.offsetHeight; 

        // ¼¿·ºÆ®¹Ú½ºÀÇ ÁÂÇ¥ 
        var el; 

        for (i=0; i<document.forms.length; i++) { 
            for (k=0; k<document.forms[i].length; k++) { 
                el = document.forms[i].elements[k];    
                if (el.type == "select-one") { 
                    var el_left = el_top = 0; 
                    var obj = el; 
                    if (obj.offsetParent) { 
                        while (obj.offsetParent) { 
                            el_left += obj.offsetLeft; 
                            el_top  += obj.offsetTop; 
                            obj = obj.offsetParent; 
                        } 
                    } 
                    el_left  += el.clientLeft; 
                    el_top    += el.clientTop; 
                    el_right  = el_left + el.clientWidth; 
                    el_bottom = el_top + el.clientHeight; 

                    // ÁÂÇ¥¸¦ µûÁ® ·¹ÀÌ¾î°¡ ¼¿·ºÆ® ¹Ú½º¸¦ Ä§¹üÇßÀ¸¸é ¼¿·ºÆ® ¹Ú½º¸¦ hidden ½ÃÅ´
                    if ( (el_left >= ly_left && el_top >= ly_top && el_left <= ly_right && el_top <= ly_bottom) || 
                        (el_right >= ly_left && el_right <= ly_right && el_top >= ly_top && el_top <= ly_bottom) || 
                        (el_left >= ly_left && el_bottom >= ly_top && el_right <= ly_right && el_bottom <= ly_bottom) || 
                        (el_left >= ly_left && el_left <= ly_right && el_bottom >= ly_top && el_bottom <= ly_bottom) ) 
                        el.style.visibility = 'hidden'; 
                } 
            } 
        } 
    } 

    // °¨Ãß¾îÁø ¼¿·ºÆ® ¹Ú½º¸¦ ¸ðµÎ º¸ÀÌ°Ô ÇÔ 
    function selectbox_visible() 
    { 
		
        for (i=0; i<document.forms.length; i++) { 
            for (k=0; k<document.forms[i].length; k++) { 
                el = document.forms[i].elements[k];    
                if (el.type == "select-one" && el.style.visibility == 'hidden') 
                    el.style.visibility = 'visible'; 
            } 
        } 
    } 
//////////////////////////////////

xspecialChar = new Array('[',']','(',')');
function specialChar(charIs){
	for (var i=0; i<xspecialChar.length;i++) {
      		if(charIs==xspecialChar[i]) {
      			return true;
      		}
    	}
	return false;
}


function replaceQuery(iquery,xmlquery){
	var look4 = iquery.toLowerCase();
	var newLookFor = "";
	var origText = xmlquery;
	var replaceWith = "<font color='red'>"+iquery+"</font>";
	var delim =  "/g" ;
	var resultIs = "";


   	for (var i=0;i<look4.length;i++) {
     		var speChar = specialChar(look4.charAt(i))
         	var charToReplace = look4.charAt(i)
         	
         	if(speChar){
         		newLookFor += "" + charToReplace
         	}else{
         		newLookFor += charToReplace
         	}
   	}

	var myString = new String(newLookFor);
	var mySeparator = ',';
	var arrayName = myString.split(mySeparator)

	for (var i=0;i<arrayName.length;i++) {
   		if(i==0)
  			resultIs = origText.replace(eval("/"+arrayName[i]+delim), replaceWith);
  		if(i!==0)
  			resultIs = resultIs.replace(eval("/"+arrayName[i]+delim), replaceWith);
  	}
	
	return resultIs.toLowerCase();
}




function searchKeyword(skeywork){
	g_Recommend.processClick(skeywork);
}

String.prototype.ktdomcut = function(len, tail) 
{
    var str = this;
    var l = 0;
    for (var i=0; i<str.length; i++) 
    {
        l += (str.charCodeAt(i) > 128) ? 2 : 1;
        if (l > len) return str.substring(0,i) + tail;
    }
    return str;
}

