<?php
$arr_search_keyword = array();
if($search_keyword!=''){
	$arr_search_keyword = explode(" ", $search_keyword);
}

?>
	<div class="contents">
		<div class="wrap">

<? if(count($list)==0) {?>
			<div class="list_left">
				<div id="search" style="border-bottom: 0;">
					<div class="search_articles">
						<div id="notfound" class="noresult_type3">
							<div class="not_found02">
								<p><em>'<?=$search_keyword?>'</em>에 대한 검색결과가 없습니다.</p>
								<ul>
									<li>단어의 철자가 정확한지 확인해 보세요.</li> <li>한글을 영어로 혹은 영어를 한글로 입력했는지 확인해 보세요.</li>
									<li>검색어의 단어 수를 줄이거나, 보다 일반적인 검색어로 다시 검색해 보세요.</li>
									<li>두 단어 이상의 검색어인 경우, 띄어쓰기를 확인해 보세요.</li>
									<li>검색 옵션을 변경해서 다시 검색해 보세요.</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
<?	} else {?>

			<div class="list_left">
				<div id="search">
					<div class="search_cate">
						<?=$page_title?><span class="search_num"><?=number_format($start_row)?>-<?=number_format($end_row)?> / <?=number_format($total_count)?>건</span>
					</div>
					<div class="search_articles">
                <?	$i=1;
					foreach ($list as $key=>$val) {
					    if($content_type == '2') {
					        $title = '['.$val['column_name'].'] '.$val['title'];
                        } else {
                            $title = $val['title'];
                        }
						$content 	= strip_tags($val['content']);

						$title_txt = mb_strimwidth($title, '0', '60', '..', 'utf-8');
						$content_txt = mb_strimwidth($content, '0', '180', '..', 'utf-8');

						foreach($arr_search_keyword as $val3) {
							$title_txt 		= str_replace($val3, '<b>'.$val3.'</b>', $title_txt);
							$content_txt	= str_replace($val3, '<b>'.$val3.'</b>', $content_txt);
						}

						$display_date_txt = gf_article_date_text($val['display_date']);

						$share_title 	= str_replace("'", "\\'", $val['title']);
						$share_title  	= str_replace('"', '\\"', $share_title);
						$share_content  = mb_strimwidth($content, '0', '250', '..', 'utf-8');
						$share_content  = htmlspecialchars($share_content);
						$share_content  = str_replace("'", "\\'", $share_content);
						$share_content  = str_replace('”', '"', $share_content);

						$main_img = $val['main_img'];
                        if($content_type == '2') {
                            $view_url = '/web/news/column_view/'.$val['idx'];
                            $share_id_name ="column_".$val['idx'];
                        } else if($content_type == '3') {
                            $view_url = '/web/life/life_view/'.$val['idx'];
                            $share_id_name ="life_".$val['idx'];
                        }

				?>



                        <div class="search_wrap">
                            <input type="hidden" name="content_<?=$share_id_name?>" id="content_<?=$share_id_name?>" value="<?=$share_content?>">
							<input type="hidden" name="title_<?=$share_id_name?>" id="title_<?=$share_id_name?>" value="<?=$share_title?>">
							<input type="hidden" name="copy_url_<?=$share_id_name?>" id="copy_url_<?=$share_id_name?>" value="<?=WWW_CROSSMAP?><?=$view_url?>">
							<input type="hidden" name="img_url_l<?=$share_id_name?>" id="img_url_<?=$share_id_name?>" value="<?=WWW_CROSSMAP?><?=$main_img?>">
							<span class="search_img" onclick="location.href='<?=$view_url?>'" style="cursor:pointer;width:137px;height:94px;background:url('<?=$val['main_img']?>') no-repeat center; background-size:cover;"></span>
							<h2 class="search_tit"><a href="<?=$view_url?>"><?=$title_txt?></a><? if($content_type!='1') { ?><span class="search_date"><?=$display_date_txt?><span class="img_direct"><img src="/img/web/img_direct.gif"  style="cursor: pointer" class="share_btn" strA="<?=$share_id_name?>"></span></span><?}?></h2>
                        <? if($content_type == '2') {?>
                            <div class="search_txt">
                                <?=$content_txt?>
                                <div class="search_info profile">
									<span class="search_url"><a href="/web/news/column_view/<?=$val['idx']?>"><?=WWW_CROSSMAP?>/web/news/column_view/<?=$val['idx']?></a></span>
								</div>
                            </div>
                        <? } else if($content_type == '3') {?>
                             <div class="search_txt">
                                <?=$content_txt?>
								<div class="search_info">
                                    <span class="profile"><a href="/web/life/editor/<?=$val['partner_idx']?>"><div style="float:left;border-radius: 21px;cursor:pointer;width:21px;height:21px;background:url('<?=$val['partner_img']?>') no-repeat center; background-size:cover;"></div>&nbsp;&nbsp;<?=$val['editor_name']?></a></span>
									<span><img src="/img/web/search_bar.gif"></span>
									<span><img src="/img/web/img_heart.gif"><?=number_format($val['like_count'])?></span>
									<span><img src="/img/web/search_bar.gif"></span>
									<span><img src="/img/web/img_comment.gif"><?=number_format($val['comment_count'])?></span>
								</div>
                             </div>
                        <?  } ?>
							</div>


                <?		$i++;
					}?>


					</div>
				</div>


				<div class="pagenumber">
					<?=$pagination?>
				</div>


				<? require_once(APPPATH."views/web/search/search_footer_inc.php"); ?>
			</div>

		<?}?>

			<? require_once (APPPATH.'views/web/news/news_right_inc.php');?>

		</div>
	</div>


<?
$title = ''; $content = ''; $main_img = '';
require_once(APPPATH."views/web/comm/share_box_inc.php"); ?>
<script>
var share_key = '';
$('.share_btn').click(function(e) {
	$("#share_box").toggle();
	var key = $(this).attr('strA');

	$("#share_content").val($("#content_"+key).val());
	$("#share_title").val($("#title_"+key).val());
	$("#share_copy_url").val($("#copy_url_"+key).val());
	$("#share_img_url").val($("#img_url_"+key).val());
	$("#copy_url").val($("#copy_url_"+key).val());

    var popH = $(this).offset().top;
	var popL = $(this).offset().left;

    $('.popup_share').css('left',(popL+130)+'px');
	$('.popup_share').css('top',popH+'px');

	share_key = key;


});
</script>


