<?php
$method =  $this->uri->segment(3);

$content_type = '3';
# session
$SES_MEMBER_ID              = $this->session->userdata('C_Member_Id');

$logo_url = '/';
if($method=='editor' || $method=='channel') {
	$logo_url = '/m/life/channel_recommend';
}
else if($bookmark_count > 0) {
	$bookmark_img = '/img/web/star_on.png';
	$bookmark_color = '#fdbb00';
}
$content_type = '3';

?>

<div class="mypage_top mypage_top_fixed bgb3">
	<div class="mypage_logo"><a href="/"><img src="/img/mobile/logo_cm.jpg" alt="logo"></a>
	</div>
	<div class="mypage_title" style="width: 100%;">
		<? 	if($method=='channel') {?>
			<a href="/m/life/channel/<?=$channel_idx?>"><span class="header_tit"><?=$channel_name?></span></a>
		<?	} else {?>
			<span class="channel_title"><a href="/m/life/editor/<?=$partner_idx?>"><?=$editor_name?></a></span>
		<?	}?>

	</div>
	<div class="mypage_search" style="width: 150px; text-align: right;">
		<form name="search_form" id="search_form" method="get" action="/m/search/">
				<span><input type="text" class="inputer" id="search_keyword" name="search_keyword" value=""
							 onkeyup="onkeyup_search_keyword(this.value);"><a href="javascript:search_form.submit();"><img
							src="/img/mobile/mypage_serch_icon.gif" alt="검색하기"></a></span>
		</form>
	</div>
	<div class="mypage_menu"><a href=""><img src="/img/mobile/menu_list.gif" alt="menu"></a>
	</div>
</div>



<div class="channel_header channel_header_fixed">
	<div class="wrap_cover">

		<?if($method!='editor' && $method !='channel') {?>
		<a href="#" class="bookmark" onclick="bookmark();" id="bookmark_img" style="color:<?=@$bookmark_color;?>;<?=($method=='life_comment') ? "display:none":""?>;z-index:99999">★</a>
		<?}?>
		<?
		$imgs = ($method=='editor') ?  $editor_main_img : $channel_main_img;
		?>
		<div class="cover_image2" style="background:url(<?=$imgs?>)">
		</div>
		<div class="cover_inner">
		</div>
	</div>
	<div class="wrap_channel">
		<? if($method=='channel') {
		$channel_delivery_btn = '/img/web/bt_delivery_off_white.png';
		if($channel_delivery_count > 0) {
			$channel_delivery_btn = '/img/web/bt_delivery_on_white.png';
		}

		?>


				<div class="cover_cell">
					<p class="chcate" style="margin-bottom:15px;"><span><a href="/m/life/category/<?=$category_idx?>"><?=$category_name?></a></span></p>
					<p><span class="chdate icon_home" style="padding-left:25px"><?=number_format($total_count)?> Stories</span></p>
					<div class="titlewrap">
						<span class="chtit"><a><img src="<?=$channel_icon?>" style="width:39px;height:39px;"><?=$channel_name?></a></span>
					</div>
					<p class="cheditor2"><a><?=$channel_intro?> </a></p>
					<p class="chtxt2"><?=number_format($channel_delivery_total_count)?>명에게 배달중</p>
				</div>



			<div class="wrap_btn" style="position:absolute;right:0;bottom:-20px;right:10px">
				<a href="javascript:channel_delivery();"><img src="<?=$channel_delivery_btn?>" id="channel_delivery_btn"></a>
			</div>


		<?	} else if ($method=='editor'){?>
		<div class="cover_cell">
			<p class="chcate" style="margin-bottom:15px;"><span><a href="/m/life/category/<?=$category_idx?>"><?=$category_name?></a> <img src="/img/mobile/bg5.gif" style="padding: 2px 5px 0 5px;"> <a href="/m/life/channel/<?=$channel_idx?>"><?=$channel_name?></a></span></p>
			<p><span class="chdate icon_home" style="padding-left:25px"><?=number_format($total_count)?>  Stories</span></p>
			<div class="titlewrap">
				<span class="chtit"><a href="/m/life/editor/<?=$partner_idx?>"><?=$editor_name?></a></span>
			</div>
			<p class="cheditor2"><a ><?=$editor_intro?></a></p>
		</div>
			<div class="cover_profile">
				<a><img src="<?=$partner_img?>" style="width:50px;height:50px;"></a>
			</div>
			<div class="cover_social" style="border-bottom:1px solid #ebeef3; padding-bottom:10px; padding-top: 15px;">

				<a href="/m/life/editor/<?=$partner_idx?>"><img src="/img/web/f_icon1.png" alt="" title=""></a>
				<? if($sns_id1!='') { ?><a href="https://www.facebook.com/<?=$sns_id1?>" target="_blank"><img src="/img/web/f_icon3.png"></a><? }?>
				<? if($sns_id2!='') { ?><a href="https://instagram.com/<?=$sns_id2?>" target="_blank"><img src="/img/web/f_icon2.png"></a><? }?>
				<? if($sns_id3!='') { ?><a href="https://band.us/band/<?=$sns_id3?>" target="_blank"><img src="/img/web/f_icon8.png"></a><? }?>
				<? if($sns_id4!='') { ?><a href="https://story.kakao.com/ch/<?=$sns_id4?>" target="_blank"><img src="/img/web/f_icon6.png"></a><? }?>
				<? if($sns_id5!='') { ?><a href="https://story.kakao.com/<?=$sns_id5?>" target="_blank"><img src="/img/web/f_icon7.png"></a><? }?>


			</div>

		<?	} else {?>
		<div class="cover_cell">
			<p class="chcate" style="margin-bottom:15px;"><span><a href=""><a href="/m/life/category/<?=$category_idx?>"><?=$category_name?></a></a> <img src="/img/mobile/bg5.gif" style="padding: 2px 5px 0 5px;">
					<a href="/m/life/channel/<?=$channel_idx?>"><?=$channel_name?></a></span></p>
			<div class="titlewrap">
				<span class="chtit"><?=@$title?></span>
			</div>

				<? if(@$sub_title != '') {
					echo '<p class="chdate">';
					echo $sub_title.' <span style="padding:0 10px;">|</span>';
					echo '</p>';

				} ?>
			<p class="chdate">조회  <?=@number_format($hit_count)?><span style="padding:0 10px;">|</span><?=substr(@$display_date, 0, 10)?> </p>
			<p class="cheditor" style="margin-top:10px;"><a onclick="location.href='/m/life/editor/<?=$partner_idx?>'" style="cursor:pointer"><?=$editor_name?></a></p>
		</div>
		<div class="cover_profile" style="margin-top:5px;">
			<a  href="/m/life/editor/<?=$partner_idx?>"><img src="<?=$partner_img?>"></a>
		</div>
		<?	}?>
	</div>
</div>




<script>
// 레이어 이외의 공간 클릭시 close
$(document).mouseup(function (e){
    var container = $("#life_search2");
    if( container.has(e.target).length === 0)   container.hide();
	$("#life_search1").show();
});



$('.side_menu_btn').click(function(e) {
	var element = $(".channel_header");
	var doc_width = element.width();

	$("#side_menu_layer").toggle();
    var popH = $(this).offset().top;
    $("#side_menu_layer").css('top','0px');
	$("#side_menu_layer").css('left',doc_width+'px');

});


function search(){
	$("#search_form").submit();
}

function search_show(){
	$("#life_search1").hide();
	$("#life_search2").show();
	$("#search_keyword").focus();
}

function channel_delivery(){
	if("<?=$SES_MEMBER_ID?>"=="") {
        alert("로그인 후에 이용가능합니다.");
        return;
    }
	var form_data = {
		"main_idx"			: <?=$channel_idx?>,
		"content_type"		: <?=$content_type?>
	};
	$.ajax({
        url: '/web/comm/delivery_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
				$("#channel_delivery_btn").attr("src","/img/web/bt_delivery_"+rtnJson.data+"_white.png");

            } else {
                alert("저장에 실패했습니다.");
                return false;
            }
        },
        error: function (rtnJson) {
            alert('저장에 실패했습니다.');
            return false;
        }
    });

}





</script>
