<?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">
                        뉴스<? if($news_type=='relation') { ?><span class="search_nav"><a href="/web/search/?search_keyword=<?=$search_keyword?>" class="current">전체뉴스</a> > 관련뉴스 </span><?}?><span class="search_num"><?=number_format($start_row)?>-<?=number_format($end_row)?> / <?=number_format($total_count)?>건</span>
					</div>
                    <ul class="search_list" style="margin:20px 0">
                    	<li style="padding-left:0 !important"><a href="/web/search/news?search_keyword=<?=$search_keyword?>&content_idx=<?=$content_idx?>&search_sort=1" <? if($search_sort == '1') { echo 'class="current"'; }?>>최신순  </a></li>
						<li style="color:#c2c2c2;">|</li>
						<li><a href="/web/search/news?search_keyword=<?=$search_keyword?>&content_idx=<?=$content_idx?>&search_sort=2" <? if($search_sort == '2') { echo 'class="current"'; }?>>오래된순 </a></li>
					</ul>

					<div class="search_articles">
                <?	$i=1;
					foreach ($list as $key=>$val) {
                        $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');
                        $display_date_txt = gf_article_date_text($val['display_date']);

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



						$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'];
                        $press_txt = $val['press_name'];
                        if($val['press_homepage']!='') {
                            $press_txt = '<a href="'.$val['press_homepage'].'" target="_blank">'.$val['press_name'].'</a>';
                        }
                        $view_url = '/web/news/news_view/'.$val['idx'];
                        $share_id_name ="news_".$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>
							<div class="search_box">
								<h2 class="search_tit"><a href="<?=$view_url?>"><?=$title_txt?></a></h2>
								<div class="search_info">
									<span><?=$press_txt?></span>
									<span style="color:#c2c2c2;">|</span>
									<span><?=$display_date_txt?></span>
									<span style="color:#c2c2c2;">|</span>
									<span><a href="<?=$view_url?>">크로스맵뉴스</a></span>
									<span class="img_direct"><img src="/img/web/img_direct.gif" style="margin-top:0 !important" style="cursor: pointer" class="share_btn" strA="news_<?=$val['idx']?>"></span>
								</div>
								<div class="search_txt">
									<?=$content_txt?>

						<?
							if(isset($arr_news_relation_article[$val['idx']])==true) {
								if(count($arr_news_relation_article[$val['idx']]) > 0 ) {?>
                                <? 	$i=1;
									foreach ($arr_news_relation_article[$val['idx']] as $key1=>$val1) {

                                    $relation_title_txt = mb_strimwidth($val1['title'], '0', '53', '..', 'utf-8');
                                    $press_txt = $val1['press_name'];
                                    if($val1['press_homepage']!='') {
                                        $press_txt = '<a href="'.$val1['press_homepage'].'" target="_blank">'.$val1['press_name'].'</a>';
                                    }

                                    $display_date_txt = gf_article_date_text($val1['display_date']);
                            ?>

                                <div class="search_info">
                                    <span class="s_reply"><img src="/img/web/search_reply.gif"><a href="/web/news/news_view/<?=$val1['idx']?>"><?=$relation_title_txt?></a></span>
                                    <span><?=$press_txt?></span>
                                    <span style="color:#c2c2c2;">|</span>
                                    <span><?=$display_date_txt?></span>
                                    <span style="color:#c2c2c2;">|</span>
                                    <span><a href="/web/news/news_view/<?=$val1['idx']?>">크로스맵뉴스</a></span>
                                </div>
                            <?
										if($i==4)	break;
                                    	$i++;
									}

							?>
									<div class="search_all" style="margin-top: 5px;">
										<a href="/web/search/news?search_keyword=<?=$search_keyword?>&content_idx=<?=$val['idx']?>" style="color:#767676">관련뉴스 <?=count($arr_news_relation_article[$val['idx']])?>건 전체보기&gt;</a>
									</div>

							<?
                                }
							}

                            ?>
								</div>
							</div>
						</div>

                <?  }?>

					</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+120)+'px');
	$('.popup_share').css('top',popH+'px');

	share_key = key;


});
</script>


