<?php

$idx		 		= '';
$popup_type_name 	= '';
$title				= '';
$popup_menu_code	= '';
$top_margin			= '';
$left_margin		= '';
$width_size			= '';
$height_size		= '';
$link_url			= '';
$content			= '';
$start_date			= '';
$start_time1		= '';
$start_time2		= '';
$end_date			= '';
$end_time1			= '';
$end_time2			= '';
$is_display			= '';
$prev_img			= '';
if(count($result) > 0) {
	$idx         		= $result['idx'];
	$popup_type_name    = $result['popup_type_name'];
	$title        		= $result['title'];
	$title				= htmlspecialchars($title);
	$popup_menu_code	= $result['menu_code'];
	$top_margin        	= $result['top_margin'];
	$left_margin        = $result['left_margin'];
	$width_size        	= $result['width_size'];
	$height_size        = $result['height_size'];
	$link_url        	= $result['link_url'];
	$content        	= $result['content'];
	$content   			= htmlentities($result['content']);
	$start_date        	= $result['start_date'];
	$end_date        	= $result['end_date'];
	$is_display        	= $result['is_display'];
	$prev_img        	= $result['prev_img'];

	$arr_start_date 	= explode(' ', $start_date);
	$start_date 		= $arr_start_date[0];

	$arr_start_time 	= explode(':', $arr_start_date[1]);
	$start_time1 		= $arr_start_time[0];
	$start_time2 		= $arr_start_time[1];

	$arr_end_date 		= explode(' ', $end_date);
	$end_date 			= $arr_end_date[0];

	$arr_end_time 		= explode(':', $arr_end_date[1]);
	$end_time1 			= $arr_end_time[0];
	$end_time2 			= $arr_end_time[1];


}



?>
<script src="/ckeditor/ckeditor.js"></script>
<link rel="stylesheet" href="<?=DIR_CSS?>/jquery-ui.min.css" />
<script src="<?=DIR_JS?>/jquery-ui.min.js"></script>
<?
	$menu_code = '81';
	require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>



<form name="input_form" id="input_form" action="/admin/design/design_popup_reg_proc" method="post">
<input type="hidden" name="idx" id="idx" value="<?=$idx?>">
<input type="hidden" id="mode" name="mode" value="<?=$mode?>">
<input type="hidden" id="search_type" name="search_type" value="<?=$search_type?>">
<input type="hidden" id="search_keyword" name="search_keyword" value="<?=$search_keyword?>">
<input type="hidden" id="search_menu_code" name="search_menu_code" value="<?=$search_menu_code?>">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="img_path" name="img_path" value="<?=$prev_img?>">

<div class="common_table news">
	<table>
	<tr>
		<th>구분</th>
		<td class="tl">
			<input type="text" name="popup_type_name" id="popup_type_name" class="type02" value="<?=$popup_type_name?>">
		</td>
	</tr>
	<tr>
		<th>제목</th>
		<td class="tl">
			<input type="text" name="title" id="title" value="<?=$title?>">
		</td>
	</tr>
	<tr>
		<th>노출경로</th>
		<td class="tl">
			<select name="menu_code" class="type01">
				<option value="">선택</option>
				<option value="1" <? if($popup_menu_code=='1') { echo 'selected';}?>>홈(PC)</option>
				<option value="2" <? if($popup_menu_code=='2') { echo 'selected';}?>>은혜(모바일)</option>
				<option value="3" <? if($popup_menu_code=='3') { echo 'selected';}?>>라이프</option>
				<option value="4" <? if($popup_menu_code=='4') { echo 'selected';}?>>뉴스</option>
			</select>
		</td>
	</tr>
	</table>
	
	
	<h2 class="subtitle">노출위치</h2>
	<table>
	<tr>
		<th>위쪽여백</th>
		<td class="tl">
			<input type="text" name="top_margin" id="top_margin" class="type03" value="<?=$top_margin?>"> px
		</td>
	</tr>
	<tr>
		<th>왼쪽여백</th>
		<td class="tl">
			<input type="text" name="left_margin" id="left_margin" class="type03" value="<?=$left_margin?>"> px
		</td>
	</tr>
	</table>


	<h2 class="subtitle">팝업사이즈</h2>
	<table>
	<tr>
		<th>가로</th>
		<td class="tl">
			<input type="text" name="width_size" id="width_size" class="type03" value="<?=$width_size?>"> px
		</td>
	</tr>
	<tr>
		<th>세로</th>
		<td class="tl">
			<input type="text" name="height_size" id="height_size" class="type03" value="<?=$height_size?>"> px
		</td>
	</tr>

	<tr>
		<th>링크</th>
		<td class="tl">
			<input type="text" name="link_url" id="link_url" value="<?=$link_url?>">
		</td>
	</tr>
	<tr>
		<th>내용</th>
		<td>
			<!-- <textarea id="content" name="content"><?=$content?></textarea> -->
			<textarea name="content" id="ir1" style="width:100%; height:500px;" /><?=$content?></textarea>
		</td>
	</tr>

	</table>


	<h2 class="subtitle">송출관리</h2>
	<table>
	<tr>
		<th>출력기간</th>
		<td class="tl">
			<input type="text" name="start_date" id="start_date" class="type02" value="<?=$start_date?>" /> <input type="text" name="start_time1" id="start_time1" class="type03" value="<?=$start_time1?>" />:<input type="text" name="start_time2" id="start_time2" class="type03" value="<?=$start_time2?>" />
			~ <input type="text" name="end_date" id="end_date" class="type02" value="<?=$end_date?>" /> <input type="text" name="end_time1" id="end_time1" class="type03" value="<?=$end_time1?>" />:<input type="text" name="end_time2" id="end_time2" class="type03" value="<?=$end_time2?>" />
		</td>
	</tr>
	<tr>
		<th>출력상태</th>
		<td class="tl">
			<input type="radio" name="is_display" value="Y" <? if($is_display=='Y' || $is_display=='') { echo 'checked';}?>> ON&nbsp;&nbsp;
			<input type="radio" name="is_display" value="N" <? if($is_display=='N') { echo 'checked';}?>> OFF
		</td>
	</tr>
	</table>
</div>
<div class="write_btn tc">
	<a href="javascript:popup_reg_proc();">저장하기</a>
	<a href="/admin/design/design_popup_list/8/<?=$page?>?search_type=<?=$search_type?>&search_keyword=<?=$search_keyword?>">목록으로</a>
</div>

</form>






<script type="text/javascript">
var oEditors = [];
var oEditors2 = [];

$(function(){
      nhn.husky.EZCreator.createInIFrame({
          oAppRef: oEditors,
          elPlaceHolder: "ir1",
          sSkinURI: "/smarteditor/SmartEditor2Skin.html",  
          htParams : {
              bUseToolbar : true,             
              bUseVerticalResizer : true,     
              bUseModeChanger : true,         
              fOnBeforeUnload : function(){
              }
          }, 
          fOnAppLoad : function(){
          },
          fCreator: "createSEditor2"
      });
      
      nhn.husky.EZCreator.createInIFrame({
          oAppRef: oEditors2,
          elPlaceHolder: "ir2", 
          sSkinURI: "/smarteditor/SmartEditor2Skin.html",  
          htParams : {
              bUseToolbar : true,             
              bUseVerticalResizer : true,     
              bUseModeChanger : true,         
              fOnBeforeUnload : function(){
              }
          }, 
          fOnAppLoad : function(){
          },
          fCreator: "createSEditor2"
      });

});
</script>

<script type="text/javascript">
$(document).ready(function() {
    /*CKEDITOR.replace('content');*/
});

function popup_reg_proc(){
	//CKEDITOR.instances.content.updateElement();
	oEditors.getById["ir1"].exec("UPDATE_CONTENTS_FIELD", []);
	//oEditors2.getById["ir2"].exec("UPDATE_CONTENTS_FIELD", []);

	if($("#popup_type_name").val()=='') {
		alert("구분을 입력해주세요.");
		return false;
	}
	if($("#title").val()=='') {
		alert("제목을 입력해주세요.");
		return false;
	}
	if($("#menu_code").val()=='') {
		alert("노출경로를 입력해주세요.");
		return false;
	}
	if($("#top_margin").val()=='') {
		alert("위쪽여백을 입력해주세요.");
		return false;
	}
	if(checkNumber($("#top_margin").val())==false) {
		alert("위쪽여백을 확인해주세요.");
		return false;
	}
	if($("#left_margin").val()=='') {
		alert("왼쪽여백을 입력해주세요.");
		return false;
	}
	if(checkNumber($("#left_margin").val())==false) {
		alert("왼쪽여백을 확인해주세요.");
		return false;
	}
	if($("#width_size").val()=='') {
		alert("가로사이즈를 입력해주세요.");
		return false;
	}
	if(checkNumber($("#width_size").val())==false) {
		alert("가로사이즈를 확인해주세요.");
		return false;
	}
	if($("#height_size").val()=='') {
		alert("세로사이즈를 입력해주세요.");
		return false;
	}
    if(checkNumber($("#height_size").val())==false) {
		alert("세로사이즈를 확인해주세요.");
		return false;
	}
	/*
	if($("#content").val()=='') {
		alert("내용을 입력해주세요.");
		return false;
	}
	*/
	if($("#ir1").val()=='' || $("#ir1").val()=='null' || $("#ir1").val()=='&nbsp;' || $("#ir1").val()=='<p>&nbsp;</p>') {
		alert("내용을 입력해주세요.");
		oEditors.getById["ir1"].exec("focus");
		return false;
	}

	if($("#start_date").val()=='') {
		alert("노출기간을 입력해주세요.");
		return false;
	}
	if($("#end_date").val()=='') {
		alert("노출기간을 입력해주세요.");
		return false;
	}

	$("#input_form").submit();

}


// jquery datepicker
$("#start_date").datepicker({
	inline: true,
	dateFormat: 'yy-mm-dd',
	buttonImage:"/img/btn_date.png",
	showOn: "both",
	buttonImageOnly: true

});
$("#end_date").datepicker({
	inline: true,
	dateFormat: 'yy-mm-dd',
	buttonImage:"/img/btn_date.png",
	showOn: "both",
	buttonImageOnly: true
});
</script>