<?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" style="border-bottom:0;">
					<div class="search_cate">
						동영상<span class="search_num"><?=number_format($start_row)?>-<?=number_format($end_row)?> / <?=number_format($total_count)?>개</span>
					</div>
					<div class="search_articles">
				<?  foreach ($list as $val) {
                        $title = $val['title'];
                        $content = strip_tags($val['content']);

						$title_txt = mb_strimwidth($title, '0', '60', '..', 'utf-8');
						$content_txt = mb_strimwidth($content, '0', '140', '..', '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'];

                        switch ($val['content_type']) {
                            case '1': $view_url = '/web/news/news_view/'.$val['idx'];	$share_key = 'news_'.$val['idx']; 	$add_title = $val['category_name']; $writer_name = $val['reporter_name']; 	break;
                            case '2': $view_url = '/web/news/column_view/'.$val['idx'];	$share_key = 'column_'.$val['idx']; $add_title = $val['column_name']; 	$writer_name = $val['column_name']; 	break;
                            case '3': $view_url = '/web/life/life_view/'.$val['idx'];	$share_key = 'life_'.$val['idx']; 	$add_title = $val['channel_name'];  $writer_name = $val['channel_name']; 	break;
                        }

				    ?>
                        <div class="search_box" style="margin-bottom: 15px;">
                            <input type="hidden" name="content_life_<?=$val['idx']?>" id="content_life_<?=$val['idx']?>" value="<?=$share_content?>">
							<input type="hidden" name="title_life_<?=$val['idx']?>" id="title_life_<?=$val['idx']?>" value="<?=$share_title?>">
							<input type="hidden" name="copy_url_life_<?=$val['idx']?>" id="copy_url_life_<?=$val['idx']?>" value="<?=WWW_CROSSMAP?><?=$view_url?>">
							<input type="hidden" name="img_url_life_<?=$val['idx']?>" id="img_url_life_<?=$val['idx']?>" value="<?=WWW_CROSSMAP?><?=$main_img?>">

						    <h2 class="search_tit"><a href="<?=$view_url?>"><?=$title_txt?> - <?=$add_title?></a><span class="search_date"> <span class="img_direct"><img src="/img/web/img_direct.gif"  style="cursor: pointer" class="share_btn" strA="<?=$share_key?>"></span></span></h2>
							<div class="search_wrap">
								<div 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 class="play"><a href="<?=$view_url?>"><img src="/img/web/img_play.png"></a></span>
									<span class="playtime"><?=$val['video_playtime']?></span>
								</div>
								<div class="search_txt">
									<div class="search_url"><a href="<?=$view_url?>"><?=WWW_CROSSMAP?><?=$view_url?></a></div>
									<div class="search_info"><?=$display_date_txt?> - 업로더: <?=$writer_name?></div>
									<?=$content_txt?>
								</div>
							</div>
						</div>

                <?  }?>


					</div>
				</div>
				<div class="pagenumber" style="border-top: 1px solid #eaeaea; padding-top: 25px;">
					<?=$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>