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

?>
<? require_once(APPPATH."views/m/search/search_header.php"); ?>


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

<? if(count($list)==0) {?>
	<div class="news_nothing">
		<div class="t_nothing"><span class="beachblue"><?=$search_keyword?></span> 에 대한 검색결과가 없습니다.</div>
		<ul>
			<li>단어의 철자가 정확한지 확인해 보세요.</li>
			<li>한글을 영어로 혹은 영어를 한글로 입력했는지 확인해보세요.</li>
			<li>검색어의 단어 수를 줄이거나, 보다 일반적인 검색어로 다시 검색해보세요.</li>
			<li>두 단어 이상의 검색어인 경우, 띄어쓰기를 확인해 보세요.</li>
			<li>검색 옵션을 변경해서 다시 검색해 보세요.</li>
		</ul>
	</div>

<?	} else {?>
			<div class="news_cont2">
				<div class="news_box">
					<div class="news_box_title">
						동영상 <span class="info"><span><?=number_format($start_row)?>-<?=number_format($end_row)?></span> | <span><?=number_format($total_count)?>건</span></span>
					</div>



					<?  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 = '/m/news/news_view/'.$val['idx'];	$share_key = 'news_'.$val['idx']; 	$add_title = $val['category_name']; $writer_name = $val['reporter_name']; 	$curl = $view_url;break;
						case '2': $view_url = '/m/news/column_view/'.$val['idx'];	$share_key = 'column_'.$val['idx']; $add_title = $val['column_name']; 	$writer_name = $val['column_name']; $curl = '/m/life/channel/'.$val['partner_idx'];	break;
						case '3': $view_url = '/m/life/life_view/'.$val['idx'];	$share_key = 'life_'.$val['idx']; 	$add_title = $val['channel_name'];  $writer_name = $val['channel_name']; 	$curl = '/m/life/channel/'.$val['partner_idx'];break;
					}

					?>
					<div class="news_box_con">
						<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><a  href="<?=$view_url?>"><?=$title_txt?> - <?=$add_title?></a><span class="n_date"><?=$display_date_txt?></span></h2>
						<div class="news_box_con_left">
							<div><?=$content_txt?></div>
							<div class="news_box_detail" style="padding-top: 35px;">
								<span class="profile" ><a href="<?=$curl?>" style="color:#000;"> <?=$writer_name?></a></span>
								<span><img src="/img/mobile/search_bar.gif"></span>
								<span class="beachblue"><a href="<?=$view_url?>"><?=WWW_CROSSMAP_M?><?=$view_url?></a></span>
							</div>
						</div>
						<div class="news_box_con_right">
							<div class="channel_con">
								<div class="play_box">
									<a href=""><img src="<?=$main_img?>" style="max-width:150px;max-height:150px;" class="art-img"></a>
									<span class="play"><a href=""><img src="/img/mobile/img_play2.png"></a></span>
									<span class="play_time"><?=$val['video_playtime']?></span>
								</div>
							</div>
						</div>
					</div>
					<?  }?>

				</div>
				<div class="pagenumber" style="border-top: 1px solid #eaeaea; padding-top: 25px;">
					<?=$pagination?>
				</div>

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



		<?}?>


<?
$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>
