<?php
$partner_idx 		=  $result['idx'];
$editor_name 		=  $result['partner_name'];
$editor_main_img 	=  $result['main_img'];
$editor_intro 	    =  $result['partner_intro'];
$partner_img 	    =  $result['partner_img'];
$category_idx 		=  $result['category_idx'];
$category_name 	    =  $result['category_name'];
$channel_idx 		=  $result['channel_idx'];
$channel_name 	    =  $result['channel_name'];
$sns_id1 	    	=  $result['sns_id1'];
$sns_id2 	    	=  $result['sns_id2'];
$sns_id3 	    	=  $result['sns_id3'];
$sns_id4 	    	=  $result['sns_id4'];
$sns_id5 	    	=  $result['sns_id5'];




$content_type = '3';



?>


    <? include_once ('life_header_inc.php');?>

	<div class="channel_cont" style="padding-top:80px;">
		<div class="wrap">
			<div class="channel_top  bgb3">
				<span class="fl art_no">전체글 수 <span class="beachblue"><?=number_format($total_count)?></span></span>
				<span class="fr art_bt">
                    <button type="button" onclick="location.href='/m/life/editor/<?=$partner_idx?>?search_sort=1'" class="btn <? if($search_sort=='1') { echo 'btn-default_bb'; } else { echo 'btn-default';}?> br20" >최신순</button>
					<button type="button" onclick="location.href='/m/life/editor/<?=$partner_idx?>?search_sort=2'" class="btn <? if($search_sort=='2') { echo 'btn-default_bb'; } else { echo 'btn-default';}?> br20">인기순</button>
				</span>
			</div>
        <div id="life_list">
        <?
			$i = 1;
            $row_count = count($list);
			foreach ($list as $val) {
				$head_title = '';
				if($val['head_title'] != '')    $head_title = '<span class="beachblue">['.$val['head_title'].']</span> ';
				$title = $head_title.$val['title'];

				$title_txt = mb_strimwidth($title, '0', '90', '..', 'utf-8');
				

                if($i%4==1) echo '<div class="channel_boxs" style="margin-bottom: 0 !important;">';

		?>
				<div class="channel_con">
                    <a onclick="location.href='/m/life/life_view/<?=$val['idx']?>'" ><img src="<?=$val['main_img']?>"> </a>
					<p class="chtitle" style="height:56px"><a href="/m/life/life_view/<?=$val['idx']?>"><?=$title_txt?></a></p>
				</div>
        <?

                if($i%4==0 || $row_count==$i) echo '</div>';

			    $i++;
			}

			$life_more_btn_style = 'display:none;';
			if($total_count > $row_count) {
				$life_more_btn_style = 'display:inline-block;';
			}
		?>


        </div>
			<p style="text-align:center;"><button type="button"  onclick="editor_list_more();"  class="btn btn-default br20" style="padding:8px 40px; font-size:16px;<?=$life_more_btn_style?>">더보기 <img src="/img/mobile/arr_down.gif" style="vertical-align:middle;"> </button></p>
		</div>


	</div>


<script>
var life_page = 2;
function editor_list_more(){
	var form_data = {
		"sort"					: "<?=$search_sort?>",
		"page"					: life_page,
		"partner_idx"			: "<?=$partner_idx?>"
	};
	$.ajax({
        url: '/m/life/life_list_more',
        async: false,
        type: 'POST',
        dataType: 'HTML',
        data: form_data,
        success: function (rtnHtml) {
        	if(rtnHtml=='') return false;
			var arrHtml = rtnHtml.split("|||||");
			if(arrHtml[0].trim()=='0000') {
				$("#life_list").append(arrHtml[1]);

				if (arrHtml[3] == "N") {
					$("#life_more_btn").hide();
				} else {
					$("#life_more_btn").show();
				}
				life_page++;

			} else {
				alert(arrHtml[1]);
               	return false;
			}
        },
        error: function (rtnHtml) {
            alert('저장에 실패했습니다.');
            return false;
        }
    });
}
</script>
