<?php
$i = 1;
$list1 = array();
$list2 = array();
$list3 = array();
foreach($list as $val) {
	if($i%3 == 1) $list1[] = array('idx'=> $val['idx'], 'main_img' => $val['main_img'], 'sub_title'=>  $val['sub_title'], 'title'=> $val['title'], 'hit_count'=> $val['hit_count'], 'comment_count'=> $val['comment_count']);
	if($i%3 == 2) $list2[] = array('idx'=> $val['idx'], 'main_img' => $val['main_img'], 'sub_title'=>  $val['sub_title'], 'title'=> $val['title'], 'hit_count'=> $val['hit_count'], 'comment_count'=> $val['comment_count']);
	if($i%3 == 0) $list3[] = array('idx'=> $val['idx'], 'main_img' => $val['main_img'], 'sub_title'=>  $val['sub_title'], 'title'=> $val['title'], 'hit_count'=> $val['hit_count'], 'comment_count'=> $val['comment_count']);

	$i++;
}

?>

<link rel="stylesheet" href="<?=DIR_CSS?>/web/jquery-ui.custom.css" />
<script src="<?=DIR_JS?>/jquery-ui.min.js"></script>
<script src="<?=DIR_JS?>/jquery-ui.multidatespicker.js"></script>


<div class="contents">
		<div class="wrap" style="background:0 !important">
			<div class="life_left">
				<div class="life_header">
					<form name="input_form" id="input_form" method="post" action="/web/life/">
					<input type="hidden" name="search_sort" id="search_sort" value="<?=$search_sort?>">
					<input type="hidden" name="search_date" id="search_date" value="<?=$search_date?>">
					<input type="hidden" name="search_popular" id="search_popular" value="<?=$search_popular?>">
					<span class="life_date"><a href="javascript:life_search('search_date', '<?=$prev_date?>')"><img src="/img/web/ico_date_prev.gif"></a>&nbsp;&nbsp;&nbsp;<?=$month_txt?>&nbsp;&nbsp;&nbsp;<a href="javascript:life_search('search_date', '<?=$next_date?>')"><img src="/img/web/ico_date_next.gif"></a></span>
					<span style="display:none;" class="life_story">라이프 스토리 </span>
                    <span class="btn btn-default br15" style="font-size:12px; background-color:#fff"><a href="javascript:life_search('search_date', '');">최근</a></span>

					<span class="fr">
						<ul class="life_click2">
							<li><a href="javascript:life_search('search_sort', '1');" <? if($search_sort=='1') { echo 'class="current"';}?>>최신순</a></li>
							<li><a href="javascript:life_search('search_sort', '2');" <? if($search_sort=='2') { echo 'class="current"';}?>>인기순</a></li>
						</ul>
					</span>

					</form>
				</div>
        <? 	if(count($list) == 0) {
				echo '<div style="height:100px;width:100%; margin-top:100px;text-align: center">등록된 글이 없습니다.</div>';

			} else {
		?>

				<div class="item_story" id="life_list">
					<ul class="list_story item_1" id="item_list1">
			<?
				if(count($list1) > 0) {
					$i = 1;
					foreach($list1 as $val) {
						$style = '';
						if($i > 3) {
							$style = 'style="display:none;"';
						}
			?>
						<li class="life_box item1_1" id="item_1_<?=$i?>" <?=$style?>>
							<a href="/web/life/life_view/<?=$val['idx']?>"><img src="<?=$val['main_img']?>" width="226"></a>
							<p class="life_info"><a href="/web/life/life_view/<?=$val['idx']?>"><?=$val['sub_title']?></a></p>
							<p class="life_title"><a href="/web/life/life_view/<?=$val['idx']?>"><?=$val['title']?></a></p>
							<p class="life_click"><span>조회 <?=number_format($val['hit_count'])?></span>   <span>댓글수 <?=number_format($val['comment_count'])?></span></p>
						</li>
			<?			$i++;
					}
				}
			?>

					</ul>
					<ul class="list_story2 item_2" id="item_list2">

			<?
				if(count($list2) > 0) {
					$i = 1;
					foreach($list2 as $val) {
						$style = '';
						if($i > 4) {
							$style = 'style="display:none;"';
						}

			?>
						<li class="life_box2 item2_1" id="item_2_<?=$i?>" <?=$style?>>
							<a href="/web/life/life_view/<?=$val['idx']?>"><img src="<?=$val['main_img']?>" width="226"></a>
							<p class="life_info"><a href="/web/life/life_view/<?=$val['idx']?>"><?=$val['sub_title']?></a></p>
							<p class="life_title"><a href="/web/life/life_view/<?=$val['idx']?>"><?=$val['title']?></a></p>
							<p class="life_click"><span>조회 <?=number_format($val['hit_count'])?></span>   <span>댓글수 <?=number_format($val['comment_count'])?></span></p>
						</li>
			<?
						$i++;
					}
				}
			?>

					</ul>
					<ul class="list_story3 item_3" id="item_list3">
			<?
				if(count($list3) > 0) {
					$i = 1;
					foreach($list3 as $val) {
						$style = '';
						if($i > 3) {
							$style = 'style="display:none;"';
						}
			?>
						<li class="life_box3 item3_1" id="item_3_<?=$i?>" <?=$style?>>
							<a href="/web/life/life_view/<?=$val['idx']?>"><img src="<?=$val['main_img']?>" width="226"></a>
							<p class="life_info"><a href="/web/life/life_view/<?=$val['idx']?>"><?=$val['sub_title']?></a></p>
							<p class="life_title"><a href="/web/life/life_view/<?=$val['idx']?>"><?=$val['title']?></a></p>
							<p class="life_click"><span>조회 <?=number_format($val['hit_count'])?></span>   <span>댓글수 <?=number_format($val['comment_count'])?></span></p>
						</li>

			<?
						$i++;
					}
				}
			?>

					</ul>


				</div >
				<a href="javascript:life_list_more();">
                <div id="more_btn" class="btn btn-default btn_life">
					<span>더보기 <img src="/img/web/img_replyopen.gif"></span>
                </div></a>
            <?  }?>
			</div>

			<div class="life_right">
				<div class="lifestory">
					<!--<div class="lifestory_title">
						라이프 STORY
					</div>-->
					<ul class="life_tab">
						<li <? if($search_popular == '1') { echo 'class="current"';}?>><a href="/web/life/?search_date=<?=$search_date?>&search_sort=<?=$search_sort?>&search_popular=1">채널</a></li>
						<li <? if($search_popular == '2') { echo 'class="current"';}?>><a href="/web/life/?search_date=<?=$search_date?>&search_sort=<?=$search_sort?>&search_popular=2">에디터</a></li>
					</ul>
					<ul class="lifestory_list">
			<? foreach ($arr_popular as $val) {
					if($search_popular == 1) {
						$list_idx	= $val['idx'];
						$list_icon	= $val['channel_icon'];
						$list_title = $val['channel_name'];
						$list_intro = $val['channel_intro'];
						$view_url	= '/web/life/channel/'.$list_idx;
					} else {
						$list_idx	= $val['idx'];
						$list_icon	= $val['partner_img'];
						$list_title = $val['partner_name'];
						$list_intro = $val['partner_intro'];
						$view_url	= '/web/life/editor/'.$list_idx;

					}
			?>
						<li>
							<a href="<?=$view_url?>"><img src="<?=$list_icon?>"></a>
							<p class="life_cate"><a href="<?=$view_url?>"><?=$list_title?></a></p>
							<p class="life_tit"><a href="<?=$view_url?>"><?=$list_intro?></a></p>
						</li>
			<? }?>

					</ul>
					<div class="pagenumber">
						<?=$pagination?>
					</div>
				</div>

				<div class="banner">
					<a href="http://www.cplace.co.kr/" target="http://www.cplace.co.kr/"><img src="/img/web/banner_250.jpg"></a>
<!-- PC_라이프_우측하단 
<ins class="adsbygoogle"
     style="display:inline-block;width:250px;height:250px"
     data-ad-client="ca-pub-7071495522658800"
     data-ad-slot="1272145884"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> -->
				</div>

				<div style="height:50px"></div>

			</div>
		</div>
	</div>


<script>
$(document).ready(function() {
	//var list_height = $(".item_1").outerHeight(true);
	//$('.item_story').css('height', list_height);

});

function life_search(id, val) {
	$("#"+id).val(val);
	$("#input_form").submit();
}


var page	= 2;
function life_list_more() {
	var calc_count = parseInt("<?=$total_count?>") - (page * 10);
	var form_data = {
		"sort"					: "<?=$search_sort?>",
		"page"					: page,
		"start_date"			: "<?=$start_date?>",
		"end_date"				: "<?=$end_date?>",
		"type"					: "main"
	};
	$.ajax({
        url: '/web/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') {
				$("#item_list1").append(arrHtml[1]);
				$("#item_list2").append(arrHtml[2]);
				$("#item_list3").append(arrHtml[3]);

				$(".item1_"+page).show();
				$(".item2_"+page).show();
				$(".item3_"+page).show();
				if (arrHtml[5] == "N") {
					$("#more_btn").hide();
                    /*
					var list_height 	= $(".item_1").outerHeight(true);
					var list_height2 	= $(".item_2").outerHeight(true);
					var list_height3 	= $(".item_3").outerHeight(true);
					if(list_height < list_height2)	list_height = list_height2;
					if(list_height < list_height3)	list_height = list_height3;

					list_height = list_height + 200;
                    */
				} else {
					$("#more_btn").show();
					//var list_height = $(".item_1").outerHeight(true);
				}
				//$('.item_story').css('height', list_height);

				page++;

			} else {
				alert(arrHtml[1]);
               	return false;
			}
        },
        error: function (rtnHtml) {
            console.log(rtnHtml);
            return false;
        }
    });
	

}



</script>
<script type="text/javascript" src="//wcs.naver.net/wcslog.js"></script>
<script type="text/javascript">
if(!wcs_add) var wcs_add = {};
wcs_add["wa"] = "2ee4bea3106352";
wcs_do();
</script>