<?
$ci=& get_instance();

# 오늘의 말씀
$now_date = date("Y-m-d");
$ci->load->model('web/m_today_word');
$arr_today_word = $ci->m_today_word->today_word_where_display_date_select($now_date);
$today_word 		= '하나님이 세상을 이처럼 사랑하사 </br>독생자를 주셨으니 이는 그를 믿는 자마다 </br>멸망하지 않고 영생을 얻게 하려 하심이라';
$today_word_title 	= '요한복음 3장 16절';
if(count($arr_today_word)>0) {
	$today_word 		= $arr_today_word['word'];
	$today_word_title 	= $arr_today_word['title'];
}


# 추천앱
$req_data = array();
$req_data['offset']         = 0;
$req_data['limit']          = 15;

# model - list
$ci->load->model('web/m_recommend_app');
$arr_recommend_app         = $ci->m_recommend_app->recommend_app_list($req_data);


$SES_MEMBER_ID              = $this->session->userdata('C_Member_Id');
$SES_MEMBER_NICNAME         = $this->session->userdata('C_Member_Nicname');
$SES_MEMBER_PROFILE         = $this->session->userdata('C_Member_Profile');
$SES_MEMBER_GROUPNAME       = $this->session->userdata('C_Member_Group_Name');
if($SES_MEMBER_PROFILE=='')	$SES_MEMBER_PROFILE = '/img/web/life_profile.png';

?>

 <!-- side_menu -->
 <div id="side_menu_layer" style="display:none;top:0px;right:0px;position: absolute;z-index: 9998">
 	<div class="life_menu">
<? 	if($SES_MEMBER_ID=='') {?>
		<div class="life_menu_top">
			<h1 class="logo"><img src="/img/web/life_logo.png"></h1>
			<div class="trc" style="padding:30px 20px 10px; font-size:12px; line-height:20px;">
				<span><i><?=$today_word?></i></span>
				<p class="grey" style="font-size:12px; padding-top:10px;"><i>-<?=$today_word_title?>-</i></p></div>
			<div class="life_menu_btn">
				<button type="button" class="btn btn-default br20" style="width:100px;color:#a7a7a7" onclick="change_toggle('login_layer');">로그인</button>
			</div>
		</div>

<?	} else {?>
		<div class="life_menu_top">
			<h1 class="logo"><img src="/img/web/life_logo.png"></h1>
			<div class="profile"><a href="javascript:commonLayerOpen('passwd_check_layer')"><img src="<?=$SES_MEMBER_PROFILE?>" width="73" height="73"></a></div>
			<p class="beachblue ft16 trc"><a href="javascript:commonLayerOpen('passwd_check_layer')"><?=$SES_MEMBER_NICNAME?></a></p>
			<div class="trc" style="padding-top:10px"> <span class="grey"></span> <a href="javascript:commonLayerOpen('passwd_check_layer')"><?=$SES_MEMBER_GROUPNAME?></a></div>
			<div class="life_menu_btn"></div>
			<ul class="life_cate">
				<li><img src="/img/web/life_icon2.png"><a href="javascript:user_comment('<?=$SES_MEMBER_ID?>', '<?=$SES_MEMBER_NICNAME?>');change_toggle('side_menu_layer')">내댓글보기</a></li>
				<li><img src="/img/web/life_bar.gif"></li>
				<li><img src="/img/web/life_icon3.png"> <a href="/web/mypage/bookmark">북마크</a></li>
				<li><img src="/img/web/life_bar.gif"></li>
				<li><img src="/img/web/life_icon1.png"><a href="javascript:change_toggle('delivery_layer');change_toggle('side_menu_layer')">배달함</a></li>
			</ul>
		</div>
<?	}?>

		<ul class="life_list_top">
			<li><a href="/">홈</a></li>
			<li><a href="/web/life/" class="current">라이프</a></li>
			<li><a href="/web/news/">뉴스</a></li>

		</ul>
		<div class="life_app">
			<h4>추천앱</h4>
			<ul>
				<span class="btn_left"><a href="javascript:change_recommend_app_page(-1)"><img src="/img/web/img_aleft_on.gif"></a></span>
			<?
				$i=1;
				$recommend_app_count = count($arr_recommend_app);
				$recommend_app_page 	= ceil($recommend_app_count/3);
				foreach ($arr_recommend_app as $val) {
					$display_style = 'block';
					if($i > 3)	$display_style = 'none';

					$curr_page = ceil($i/3);

			?>

				<li class="recommend_app_page<?=$curr_page?>" style="display:<?=$display_style?>"><a href="<?=$val['market_url']?>" target="_blank"><img src="<?=$val['icon_img']?>" width="66" height="66"></a><a href="<?=$val['market_url']?>" class="app_txt" target="_blank"><?=$val['app_name']?></a></li>

			<?
					$i++;
				}?>

				<span class="btn_right"><a href="javascript:change_recommend_app_page(1)"><img src="/img/web/img_aright.gif"></a></span>
			</ul>
		</div>
		<ul class="life_list_bottom">
			<li><a href="/web/cs/notice">공지사항</a> <span class="new">N</span></li>
			<li><a href="/web/cs/faq">FAQ</a></li>
			<? 	if($SES_MEMBER_ID!='') {?><li><a href="/web/mypage/qna">1:1 문의</a></li><? }?>
		</ul>
		<div class="life_menu_btn">
<? 	if($SES_MEMBER_ID=='') {?>
		<button type="button" class="btn btn-default br20" style="width:100px;color:#a7a7a7" onclick="change_toggle('login_layer');">로그인</button>
<?	} else {?>
		<button type="button" class="btn btn-default br20" style="width:100px;color:#a7a7a7" onclick="location.href='/web/member/logout_proc'">로그아웃</button>

<?	}?>
		</div>
		<div class="life_menu_btn" style="margin-bottom:80px;">
			<button type="button" class="btn btn-default br20" style="width:100px;" onClick="window.open('/m/')">모바일 화면</button>
		</div>
	</div>
 </div>
 <!--// side_menu -->


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

var recommend_app_curr_page = 1;
function change_recommend_app_page(page){
	var total_page = "<?=$recommend_app_page?>";
	var move_page = recommend_app_curr_page + page;
	if(move_page > 0 && total_page >= move_page) {
		$(".recommend_app_page"+move_page).show();
		$(".recommend_app_page"+recommend_app_curr_page).hide();
		recommend_app_curr_page = move_page;
	}
}

</script>


