// °Ë»ö¾î ÃßÃµ Å¬·¡½º  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_bCheckFlag = true;			// ÀÏÁ¤½Ã°£¸¶´Ù XML Request °¡ µé¾î°¬´ÂÁö¸¦ Ã¼Å©ÇÒÁö ¿©ºÎ.
	this.m_Require = null;				// XML °´Ã¼ 
	this.m_iFixedWords = 5 ;				// ÇÑÈ­¸é¿¡ Ãâ·ÂµÉ ±ÛÀÚ °¹¼ö (³ª¸ÓÁö´Â ´Ü¾î´Â ½ºÅ©·Ñ¹Ù·Î ¾Æ·¡ÂÊ¿¡ À§Ä¡ÇÔ)
	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_iPrintWordLength = 30;       // ´Ü¾î ±æÀÌ ÃÖ´ë ¹ÙÀÌÆ®  ±×ÀÌ»óÀº Â¥¸§.



	//this.m_strUpArrow = '/img/popular/bullet_t.gif';
	//this.m_strDownArrow = '/img/popular/bullet_b.gif';
	this.m_strUpArrow = '/images/auto_up.gif';
	this.m_strDownArrow = '/images/auto_down.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);

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

				this.m_bMysearchVisible = false;     
				this.m_oPrintZone.style.display = '';
            
				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';
			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_' + index).style.backgroundColor='#EBEBEB';
		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='300' height='145' 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='7' background='/img/popular/bg.gif' style='filter: alpha(opacity=70);' bgcolor='ADCAC5'></td>  <td align='center' valign='top'   ><table width='286' border='0' cellpadding='0' cellspacing='0' >        <tr>           <td width='286' height='21' bgcolor='0082B5'><table width='100%' border='0' cellpadding='0' cellspacing='0'>              <tr>                 <td width='7%'><img src='/img/popular/icon_t.gif' width='14' height='11'></td>                <td width='69%' class='sc'><strong><font color='#FFFFFF' style='font-size:11px'>³»°¡ Ã£Àº               °Ë»ö¾î </font></strong></td>                <td width='24%' align='right' class='sc'> ";
		
		
		tmptable += "<font color='#FFFFFF' onclick=g_Recommend.setUse(true) style='cursor:hand;font-size:11px'> ¾ËÂ¥°Ë»ö¾î</font>";
		
		
		tmptable +="</td>              </tr>            </table></td>        </tr>        <tr>          <td valign='top'><img src='/img/popular/bar01.gif' width='286' height='10'></td>        </tr>        <tr>           <td align='center' valign='top' background='/img/popular/bg_body.gif'>";

		
		tmptable += "<div id=mysearchview class=search_scrollbar cellpadding='0' style=' MARGIN-TOP: 0px; width:" + 270 + "; 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='202' height='18' class='sc'><img src='/img/popular/bullet.gif' width='11' height='6' align='absmiddle'>"+  this.getSearchWord(i).cut(this.m_iPrintWordLength) +"</td> <td width='18' class='sc' onclick=\"g_Recommend.onClickDeleteButton("+ i  +"); return false;\"><img src='/img/popular/x.gif' width='9' height='9' align='absmiddle'></td></tr>";
			
		}

		tmptable += "</table></div><table width='270' 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='/img/popular/btn05.gif' width='65' height='17'></a></td>                <td align='right' valign='bottom' bgcolor='EFF5F5'><a href='javascript:g_Recommend.onClickDownButton()'> <img src='/img/popular/btn_close.gif' border=0 width=26 height=14></a><img src='/img/popular/r.gif' width='14' height='17'></td>              </tr>            </table></td>  </tr>        <tr>           <td valign='top' ><img src='/img/popular/bar02.gif' width='286' height='10'></td>        </tr>      </table>      <table width='286' border='0' cellpadding='0' cellspacing='0'>        <tr><td height='10' style='filter: alpha(opacity=70);' bgcolor='D6EEF5'></td></tr>   </table></td> <td width=7 background='/img/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>";


		*/

		//tmptable += "<table width='340' 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:" + 348+ "; 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='360'  border='0' cellpadding='0' cellspacing='1' bgcolor='#00A5DA' height='72'><tr><td align='left' valign='top' bgcolor='#FFFFFF'>";
		tmptable += "<table width='100%' height='4'  border='0' cellpadding='0' cellspacing='0'><tr><td height='6'></td></tr></table>";
		tmptable += "<div id=mysearchview class=sbody cellpadding='0' style=' MARGIN-TOP: 0px; width:" + 350 + "; overflow:auto; height:72px; '>";
		tmptable += "<table width='100%'  border='0' cellspacing='0' cellpadding='0' height=6' height='72'><tr><td>";
		tmptable += "<table width='100%' height='52'  border='0' cellpadding='0' cellspacing='0'><tr>";
		tmptable += "<td width='10'>&nbsp;</td><td height='18' class='none2'><font style='family:±¼¸²;color:#5e5e5e;size:12px'>ÇöÀç °Ë»ö¾î ÀÚµ¿¿Ï¼º ±â´ÉÀ» »ç¿ëÇÏ°í ÀÖÁö ¾Ê½À´Ï´Ù.</font></td><td width='10'>&nbsp;</td></tr>";
		tmptable += "<td width='10'>&nbsp;</td><Td><a href='javascript:g_Recommend.setUse(true)'><img src='images/auto_use.gif' border='0'></a></td><td width='10'>&nbsp;</td></tr></table>";
		tmptable += "</td></tr></table></div><table width='100%' height='9'  border='0' cellpadding='0' cellspacing='0'><tr><td></td></tr></table><table width='100%' height='22'  border='0' cellpadding='0' cellspacing='0' bgcolor='#ECF2F8'><tr><td width='11'>&nbsp;</td><td>&nbsp;</td>";
		tmptable += "<td width='126' align='right'><a href='javascript:g_Recommend.setUse(true)'><font style='family:µ¸¿ò;size:11px;color:#006DAB;'>±â´ÉÄÑ±â</font></a></td><td width='16'>&nbsp;</td></tr></table></td></tr></table>";

		this.m_strDocumentType = 'MySearch';

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

	this.printResult = function()
	{
    search_clearbg();
    
//		alert('hahaha');
		if( this.m_bEnabled == false ) return;   // »ç¿ë±â´ÉÀÌ ²¨Á® ÀÖÀ¸¸é ÇÁ¸°Æ® ÇÏÁö ¾Ê´Â´Ù.! 
		if( this.m_oInputBox.value == '' ) return;
		try{
			xmlDoc =  req.responseXML.documentElement;
			
			cnt=xmlDoc.getElementsByTagName("index").length;
			//this.m_iElementLength = cnt;
			
			element = xmlDoc.getElementsByTagName("index");
			//word.innerHTML = '';

			//word.style.display='';

			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;

			tmptable+="<table width='360'  height='80' border='0' cellpadding='0' cellspacing='1' bgcolor='#00A5DA'><tr><td align='left' valign='top' bgcolor='#FFFFFF'><table width='100%' height='4'  border='0' cellpadding='0' cellspacing='0'><tr><td height='6'></td></tr></table>";
			//tmptable +="<div id=wordview class=sbody style='width:" + 358 + "; FONT-SIZE: 10pt; overflow:auto; height:100px; background:#FFFFFF; '>";
			tmptable +="<div id=wordview class=sbody style='width:" + 358 + "; FONT-SIZE: 10pt; height:100px; background:#FFFFFF; '>";
			tmptable +="<table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr><td><table width='100%' height='20'  border='0' cellpadding='0' 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 ; 				
				
				
				// ÃÊ°ú ±ÛÀÚ¼ö »èÁ¦
				var cut_text = content_text;
				var cut_url = content_url;
				
				if ( cut_text.length > 12 ) {
					cut_text = cut_text.ktdomcut( 16, '..');
				}

				if ( cut_url.length > 12 ) {
					cut_url = cut_url.ktdomcut(16,'..');
				}				
				
				
								


				if ( content_gubun == "url" ) {      					

            				fwdtmpTable +="<tr id=n_"+arrayi+" onMouseOver=g_Recommend.processSelect("+ arrayi + ") onMouseOut=g_Recommend.processOut("+arrayi+") height='20'>";
            				fwdtmpTable +="<td width='10'>&nbsp;</td>";
            				fwdtmpTable +="<td height='20' id=n_sub_"+arrayi+" width='150' class='none2' 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;'>"+content_url+"</td>";
            				fwdtmpTable +="<td width='10'>&nbsp;</td></tr>";
          				          				          				
					
				} else if ( content_gubun == "product" ) {
															      	
          				
          				fwdtmpTable +="<tr id=n_"+arrayi+" onMouseOver=g_Recommend.processSelect("+ arrayi + ") onMouseOut=g_Recommend.processOut("+arrayi+") height='20'>";
            				fwdtmpTable +="<td width='10'>&nbsp;</td>";
            				fwdtmpTable +="<td height='20' id=n_sub_"+arrayi+" width='150' class='none2' 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='10'>&nbsp;</td></tr>";
										
				} else {					
					
  					
  					fwdtmpTable +="<tr id=n_"+arrayi+" onMouseOver=g_Recommend.processSelect("+ arrayi + ") onMouseOut=g_Recommend.processOut("+arrayi+") height='20'>";
            				fwdtmpTable +="<td width='10'>&nbsp;</td>";
            				fwdtmpTable +="<td height='20' id=n_sub_"+arrayi+" width='150' class='none2' onclick=\"javascript:searchKeyword('"+content_url+"');\"' 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+"');\" style='cursor:hand;' ><span class='green' style='cursor:hand;'>"+content_url+"</span</td>";
            				fwdtmpTable +="<td width='10'>&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='4'><hr width='100%' size='1' style='color:#CCCCCC'></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" ) {

            				bwdtmpTable +="<tr id=n_"+j+" onMouseOver=g_Recommend.processSelect("+ j + ") onMouseOut=g_Recommend.processOut("+j+") height='20' >";
            				bwdtmpTable +="<td width='10'>&nbsp;</td>";
            				bwdtmpTable +="<td height='20' id=n_sub_"+j+" width='150' class='none2' 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;'>"+rcontent_url+"</td>";
            				bwdtmpTable +="<td width='10'>&nbsp;</td></tr>";
          				
          				
          				
					
				} else if ( rcontent_gubun == "product" ) {
          				
          				bwdtmpTable +="<tr id=n_"+j+" onMouseOver=g_Recommend.processSelect("+ j + ") onMouseOut=g_Recommend.processOut("+j+") height='20'>";
            				bwdtmpTable +="<td width='10'>&nbsp;</td>";
            				bwdtmpTable +="<td height='20' id=n_sub_"+j+" width='150' class='none2' 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='10'>&nbsp;</td></tr>";
										
				} else {					
  					
  					bwdtmpTable +="<tr id=n_"+j+" onMouseOver=g_Recommend.processSelect("+ j + ") onMouseOut=g_Recommend.processOut("+j+") height='20' >";
            				bwdtmpTable +="<td width='10'>&nbsp;</td>";
            				bwdtmpTable +="<td height='20' id=n_sub_"+j+" width='150' class='none2' onclick=\"javascript:searchKeyword('"+rcontent_url+"');\"' 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+"');\" style='cursor:hand;' ><span class='green' style='cursor:hand;'>"+rcontent_url+"</span></td>";
            				bwdtmpTable +="<td width='10'>&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='/img/popular/bar02.gif' width='286' height='10'></td>        </tr>      </table>      <table width='286'  border='0' cellpadding='0' cellspacing='0'>        <tr><td height='10' style='filter: alpha(opacity=70);' bgcolor='D6EEF5'></td></tr></table></td>   <td width='7' background='/img/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>";


			tmptable +="</table></td></tr></table></div>";
			//tmptable +="<table width='100%' height='9'  border='0' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
			tmptable +="<table width='100%' height='22'  border='0' cellpadding='0' cellspacing='0' bgcolor='#ECF2F8'>";
			tmptable +="<tr><td width='11'>&nbsp;</td><td><table width='100%' height='20'  border='0' cellpadding='0' cellspacing='0'>";
			tmptable +="<tr><td width='3'><img src='images/icon41.gif' width='3' height='22'></td><td>";
			
			
			if ( lastValuechk > 0 ) {
			
				if ( sm_element == 0 ) {
					tmptable +="<a href='javascript:g_Recommend.setMode(1);'><font style='color:#006DAB;family:µ¸¿ò;size:11px'>³¡´Ü¾î´õº¸±â</font></a>";
				} else {
					tmptable +="<a href='javascript:g_Recommend.setMode(0);'><font style='color:#006DAB;family:µ¸¿ò;size:11px'>Ã¹´Ü¾î´õº¸±â</font></a>";
				}			
			}
			
			
			tmptable +="</td></tr></table></td><td width='126' align='right'><a href='javascript:g_Recommend.setUse(false)'><img src='images/suggest_off.gif' width='43' height='12' border='0'></a></td><td width='16'>&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';
					eval('n_sub_' + index).style.color='#676767';
				}
				else
				{
					//eval('n_' + index).style.backgroundColor='#FFE5DB';
					eval('n_' + index).style.backgroundColor='#EBEBEB';
					eval('n_sub_' + index).style.color='#6F6A68';
				}
		//		alert(i);
				i++;
			}
		}
		catch(e)
		{

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

	}

	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();
			this.loadXMLDoc('/xmldata_mysql_0108.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';

		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';
					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';  // ·¹ÀÌ¾î¸¦ º¸ÀÌÁö ¾Ê°Ô ÇÑ´Ù.

					// 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';
								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';
							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;
	}

	this.onDocumentMouseClick = function()
	{
		g_Recommend.m_bCheckFlag = false;
		g_Recommend.m_oPrintZone.style.display='none';
		g_Recommend.processDeselectAll();
		return false;

	}
}




//////////////////////////////////
// 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));
	}

}



//document.onmouseup = g_Recommend.onDocumentMouseClick;
//////////////////////////////////


//////////////////////////////////

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;
	var newLookFor = "";
	var origText = xmlquery;
	var replaceWith = "<font style='color:#FB726A;size:12px;family:±¼¸²'><B>"+iquery+"</B></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;
}

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;
}



