<?
$SES_MEMBER_ID          = $this->session->userdata('C_Member_Id');
$title = '';
$content = '';
$main_img = '';

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


?>
<?include_once "search_header.php"?>

<? 	if($total_count == 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>


<? 	} ?>


<? if(count($arr_search_keyword_relation) > 0) {?>
	<!-- <div class="relative">
		<span class="r_left"><span class="r_title">연관</span>
			<?	foreach($arr_search_keyword_relation as $val) {?>
				<a href="/m/search/?search_keyword=<?=$val['relation_keyword']?>"><?=$val['relation_keyword']?></a>
			<?	}?>
		</span>
	</div> -->


<?	}?>


<? if(count($arr_life) > 0) {?>
<div class="news_cont2">
	<div class="news_box">
		<div class="news_box_title">
			라이프
		</div>
		<?	$i=1;
		foreach ($arr_life 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');

		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'];

		$life_class = '';
		if($i==count($arr_life)) {
			$life_class=' bb pdb20';
		}



		?>
		<div class="news_box_con search_wrap<?=$life_class?>">
			<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_M?>/life/life_view/<?=$val['idx']?>">
			<input type="hidden" name="img_url_life_<?=$val['idx']?>" id="img_url_life_<?=$val['idx']?>" value="<?=WWW_CROSSMAP_M?><?=$main_img?>">
			<h2><a href="/m/life/life_view/<?=$val['idx']?>"><?=$title_txt?></a></h2>
			<div class="news_box_con_left">
				<div><?=$content_txt?></div>
			</div>
			<div class="news_box_detail" style="padding-top: 35px;">
				<span class="profile"><a href="/m/life/editor/<?=$val['partner_idx']?>"><img style="padding-right:3px; max-width:21px;max-height:21px; vertical-align:middle;" src="<?=$val['partner_img']?>"><?=$val['editor_name']?></a></span>
				<!-- <span><img src="/img/mobile/search_bar.gif"></span> -->
				<span>|</span>
				<span><?=$display_date_txt?></span>
				<span>|</span>
				<span><img src="/img/mobile/img_heart.gif" style="padding:0 3px; vertical-align:middle;"><?=number_format($val['like_count'])?></span>
				<span>|</span>
				<span><img src="/img/mobile/img_comment.gif" style="padding:0 3px; vertical-align:middle;"><?=number_format($val['comment_count'])?></span>
			</div>
			<div class="news_box_con_right">
				<a href="/m/life/life_view/<?=$val['idx']?>"><img src="<?=$main_img?>"></a>
			</div>
		</div>


			<? if($i==count($arr_life)) {?>

				<div class="news_box_more">
					<a href="/m/search/list?search_keyword=<?=$search_keyword?>&content_type=3">더보기 <img src="/img/mobile/arrow_more.gif"></a>
				</div>
			<?	}?>
			</div>
			</div>
			<?		$i++;
		}?>

<?	}?>

	</div>




<? if(count($arr_news) > 0) {?>
	<div class="news_box">
		<div class="news_box_title">
			뉴스

		</div>

	<? 	$i=1;
	foreach ($arr_news as $key=>$val) {
		$news_class = '';
		if($i==count($arr_news)) {
			$news_class='bb pdb20';
		}

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


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

		$press_txt = $val['press_name'];
		if($val['press_homepage']!='') {
			$press_txt = '<a href="'.$val['press_homepage'].'" target="_blank">'.$val['press_name'].'</a>';
		}
		$display_date_txt = gf_article_date_text($val['display_date']);


		?>


		<div class="news_box_con search_wrap <?=$news_class?>">
			<input type="hidden" name="content_news_<?=$val['idx']?>" id="content_news_<?=$val['idx']?>" value="<?=$share_content?>">
			<input type="hidden" name="title_news_<?=$val['idx']?>" id="title_news_<?=$val['idx']?>" value="<?=$share_title?>">
			<input type="hidden" name="copy_url_news_<?=$val['idx']?>" id="copy_url_news_<?=$val['idx']?>" value="<?=WWW_CROSSMAP_M?>/web/news/news_view/<?=$val['idx']?>">
			<input type="hidden" name="img_url_news_<?=$val['idx']?>" id="img_url_news_<?=$val['idx']?>" value="<?=WWW_CROSSMAP_M?><?=$main_img?>">

			<h2><a href="/m/news/news_view/<?=$val['idx']?>"><?=$title_txt?></a></h2>
			<div class="news_box_con_left">
				<div><?=$content_txt?></div>
			</div>
			<div class="news_box_detail2" style="padding-top:5px;">
				<span><?=$press_txt?></span>
				<span>|</span>
				<span><?=$display_date_txt?></span>
				<span>|</span>
				<span><a href="/web/news/news_view/<?=$val['idx']?>">크로스맵뉴스</a></span>
			</div>
			<div class="news_box_con_right">
				<a href="/web/news/news_view/<?=$val['idx']?>"><img src="<?=$val['main_img']?>"></a>
			</div>
			<?
			if(isset($arr_news_relation_article[$val['idx']])==true) {
				if(count($arr_news_relation_article[$val['idx']]) > 0 ) {?>
					<div class="relatednews">
						<? 	$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="relatednews_box">
								<span class="relatednews_tit"><img src="/img/web/search_reply.gif" style="vertical-align:middle;"> <a href="/m/news/news_view/<?=$val1['idx']?>"><?=$relation_title_txt?></a></span>
								<span class="relatednews_info news_box_detail2">
											<span><?=$press_txt?></span>
											<span style="color:#c2c2c2;">|</span>
											<span><?=$display_date_txt?></span>
											<span style="color:#c2c2c2;">|</span>
											<span><a href="/m/news/news_view/<?=$val1['idx']?>">크로스맵뉴스</a></span>
										</span>
							</div>
							<?
							if($i==4)	break;
							$i++;
						}

						?>

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

			}

			?>


		</div>



	</div>







<?$i++;
	}
	?>

		<div class="news_box_more"><a href="/m/search/news?search_keyword=<?=$search_keyword?>&content_type=1">
				더보기 <img src="/img/mobile/arrow_more.gif">
			</a>
		</div>

<?
}?>

<? 	if(count($arr_img) > 0) {?>

	<div class="news_box">
		<div class="news_box_title" style="border-bottom:0;">
			이미지
		</div>
		<div class="news_box_con" style="padding:0; border-bottom:0; border-top:0">
			<div class="container">
				<? foreach ($arr_img as $key=>$val) {
				$title_text = 	$val['title'];
				if($val['category_name']!='')	$title_text.= ' - '.$val['category_name'];



				switch ($val['content_type']) {
					case '1': $img_view_url = '/m/news/news_view/'.$val['idx'];	break;
					case '2': $img_view_url = '/m/news/column_view/'.$val['idx'];	break;
					case '3': $img_view_url = '/m/life/life_view/'.$val['idx'];	break;
				}

				?>
				<div class="item">
<!--					<a href="--><?//=$img_view_url?><!--">-->
					<img src='<?=$val['main_img']?>' title="<?=$title_text?>">
<!--					</a>-->
				</div>

					<?		if($key == 4)	break;
				}?>
			</div>
		</div>
		<div class="news_box_more">
			<a href="/m/search/image?search_keyword=<?=$search_keyword?>">
			더보기 <img src="/img/mobile/arrow_more.gif">
			</a>
		</div>
	</div>
<?}?>
<? 	if(count($arr_video) > 0) {?>
	<div class="news_box">
		<div class="news_box_title">
			동영상
		</div>
		<div class="news_box_con">
			<div class="news_video">
				<div class="swiper-container swiper-02">
					<div class="swiper-wrapper">
						<? 	foreach ($arr_video as $key=>$val) {
						$title_txt = mb_strimwidth($val['title'], '0', '28', '..', 'utf-8');
						switch ($val['content_type']) {
							case '1':	$video_view_url = '/m/news/news_view/'.$val['idx'];
//								$video_category_url = '/m/news/category/'.$val['category_code'];
								break;
							case '2': 	$video_view_url = '/m/news/column_view/'.$val['idx'];
								$video_category_url = '/m/news/columnist/'.$val['partner_idx'];
								break;
							case '3': 	$video_view_url = '/m/life/life_view/'.$val['idx'];
//								$video_category_url = '/m/life/category/'.$val['category_idx'];
								break;
						}

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

						<div class="swiper-slide">
							<div class="channel_con">
								<div class="play_box">
									<a href="<?=$video_view_url?>"><img src="<?=$val['main_img']?>" class="art-img" style="max-height:80px;max-width:150px"></a>
									<span class="play"><a href="<?=$video_view_url?>"><img src="/img/mobile/img_play.png"></a></span>
									<span class="play_time"><?=$val['video_playtime']?></span>
								</div>
								<p class="chtitle"><a href="<?=$video_view_url?>"><span class="beachblue">[<?=$val['category_name']?>]</span> <?=$title_txt?></a></p>
							</div>
						</div>
						<?	}?>
					</div>
					<!-- Add Scrollbar -->
					<div class="swiper-scrollbar"></div>
				</div>
			</div>
		</div>
		<div class="news_box_more"><a href="/m/search/video?search_keyword=<?=$search_keyword?>">
			더보기 <img src="/img/mobile/arrow_more.gif">
			</a>
		</div>
	</div>

<?	}?>



<? if(count($arr_column) > 0) {?>
	<div class="news_box">
		<div class="news_box_title">
			칼럼
		</div>
	<?
	$i=1;
	foreach ($arr_column as $val) {
		$column_class = '';
		if($i==count($arr_column)) {
			$column_class=' bb pdb20';
		}

		$title = '['.$val['column_name'].'] '.$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'];

		?>
		<div class="news_box_con search_wrap<?=$column_class?>">
			<input type="hidden" name="content_column_<?=$val['idx']?>" id="content_column_<?=$val['idx']?>" value="<?=$share_content?>">
			<input type="hidden" name="title_column_<?=$val['idx']?>" id="title_column_<?=$val['idx']?>" value="<?=$share_title?>">
			<input type="hidden" name="copy_url_column_<?=$val['idx']?>" id="copy_url_column_<?=$val['idx']?>" value="<?=WWW_CROSSMAP_M?>/web/news/column_view/<?=$val['idx']?>">
			<input type="hidden" name="img_url_column_<?=$val['idx']?>" id="img_url_column_<?=$val['idx']?>" value="<?=WWW_CROSSMAP_M?><?=$main_img?>">
			<h2><a href=/m/news/column_view/<?=$val['idx']?>""><?=$title_txt?></a><span class="n_date"><?=$display_date_txt?></span></h2>
			<div class="news_box_con_left">
				<div><?=$content_txt?></div>
			</div>
			<div class="news_box_con_right">
				<a href="/m/news/column_view/<?=$val['idx']?>"><img src="<?=$val['main_img']?>"></a>
			</div>
			<div class="news_box_detail">
				<span class="beachblue"><a href="/m/news/column_view/<?=$val['idx']?>"><?=WWW_CROSSMAP_M?>/m/news/column_view/<?=$val['idx']?></a></span>
			</div>
		</div>

		<? if($i==count($arr_column)) {?>

		<div class="news_box_more">
			<a  href="/m/search/list?search_keyword=<?=$search_keyword?>&content_type=2">
			더보기 <img src="/img/mobile/arrow_more.gif">
			</a>
		</div>
		<? }?>
	</div>
		<?		$i++;
	}?>

	<?}?>

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


<?include_once ("search_footer_inc.php")?>
<script>
	var swiper = new Swiper('.swiper-01', {
		spaceBetween: 5,
		slidesPerView: 'auto',
		scrollbar: {
			el: '.swiper-scrollbar',
			hide: true,
		},
	});
	var swiper = new Swiper('.swiper-02', {
		spaceBetween: 5,
		slidesPerView: 'auto',
		scrollbar: {
			el: '.swiper-scrollbar',
			hide: true,
		},
	});
</script>
<script>
	// document.addEventListener('DOMContentLoaded', function () {
	// 	new SmartPhoto(".js-smartPhoto");
	// 	new SmartPhoto(".js-smartPhoto-hide", {
	// 		arrows: false,
	// 		nav: false
	// 	});
	// 	new SmartPhoto(".js-smartPhoto-fit", {
	// 		resizeStyle: 'fit'
	// 	});
	// });
</script>
<script>
	$(document).ready(function() {
		var options = {minMargin: 5, maxMargin: 15, itemSelector: ".item", firstItemClass: "first-item"};
		$(".container").rowGrid(options);
	});

	jQuery(function($){
		'use strict';

		setTimeout(function () {
			var $frame  = $('#basic1');
			var $slidee = $frame.children('ul').eq(0);
			// Call Sly on frame
			$frame.sly({
				horizontal: 1,
				itemNav: 'basic',
				smart: 1,
				activateOn: 'click',
				mouseDragging: 1,
				touchDragging: 1,
				releaseSwing: 1,
				startAt: 0, // 탭설정
				scrollBy: 4,
				activatePageOn: 'click',
				speed: 300,
				elasticBounds: 1,
				easing: 'easeOutExpo',
				dragHandle: 1,
				dynamicHandle: 1,
				clickBar: 1
			});
		}(), 0);

	});
</script>


</div>


