<?
	if($stx) $q	= $stx;
	else	$q		= $confg[cf_title];

	$cnt	= 5;
	if($search_code == "encyclopedia") 	$cnt	= 10;

	$url	= "http://openapi.naver.com/search?key=".$api_naver_encyclopedia."&query=".$q."&target=encyc&start=1&display=".$cnt;
	$text	= zm_away_fopen($url);
	echo $text; exit;
	$dom = new DOMDocument;
	$dom->loadXML($text);
	$items = $dom->getElementsByTagName('item');
	$records = array();

	foreach($items as $item) {
		$record = array();

		if($item->childNodes->length) {
			foreach($item->childNodes as $i) {
				$record[$i->nodeName] = $i->nodeValue;
			}
		}

		$records[] = $record;
	}
?>
<style>
.non_search		{ text-align:center; padding:50px; }
.search_encyclopedia_list		{ clear:both; line-height:130%; margin-bottom:15px; }
.search_encyclopedia_list .subject a	{ color:#1122CC; font-size:13px; text-decoration:none; padding-bottom:2px; border-bottom:1px solid #1122CC; } /* 제목 */
.search_encyclopedia_list .subject a:visited	{ color:#808000; }
.search_encyclopedia_list .summary		{ margin-top:4px; }	/* 내용 */
.search_encyclopedia_list .search_info	{ margin-top:3px; }
.search_encyclopedia_list .search_info span.board_name	a { color:#A1BD86; padding-right:10px; }
.search_encyclopedia_list .search_info span.date		{ color:#C7C7C7; font-family:Arial; font-size:11px; margin-right:20px; }

.search_key_css		{ font-weight:bold; }
</style>

<? if(count($records)  <= 0) : ?>
	<div class="non_search"><span style="color:#808000;">"<?=$stx?>"</span>에 대한 지식백과 검색 결과가 없습니다.</div>
<? else: //-- 검색 된 목록
        for ($i = 0; $i < count($records); $i++)  :
			$records[$i][title] = str_replace(array("&lt;b&gt;", "&lt;/b&gt;"), "", $records[$i][title]);
			$records[$i][description] = str_replace(array("&lt;b&gt;", "&lt;/b&gt;"), "", $records[$i][description]);
			$records[$i][description] = keyword_css("$q", "search_key_css", $records[$i][description]);
			$records[$i][title] = keyword_css("$q", "search_key_css", $records[$i][title]);
			$records[$i][description] = keyword_css("$q", "search_key_css", $records[$i][description]);
?>
			<div class="search_encyclopedia_list">
				<div class="subject"><a href="<?=$records[$i][link]?>" target="_blank"><?=$records[$i][title]?></a></div>
				<div class="summary"><?=$records[$i][description]?></div>
				<div class="search_info">
				</div>
			</div>	<!-- end search_encyclopedia_list -->
<?		endfor; ?>
<? endif; ?>

<div style="margin:20px 0 20px 0;"><div class="line"></div></div>