<style>
.tbl_box	{ border:1px solid #E3E3E3; border-top:2px solid #CFCFCF; }
.tbl_box tr td.col1	{ font:bold 12px '맑은 고딕'; padding:4px; border-bottom:1px solid #E3E3E3; width:120px; }
.tbl_box tr td.col2	{ font:normal 12px '맑은 고딕'; padding:4px; border-bottom:1px solid #E3E3E3; }
.tbl_box tr:last-child td	{ border-bottom:0; }
td input	{ border:1px solid #CFCFCF; border-radius:3px; padding:5px; }
td textarea	{ border:1px solid #CFCFCF; border-radius:3px; padding:5px; }
input.pagecode	{ background:#FBFBFB; }
div.bttn_box	{ text-align:center; padding:5px; }
div.bttn_box input[type=submit]	{ cursor:pointer; border:1px solid #FF4040; color:#FF4040; background:#FFF4F4; padding:5px 10px 7px 10px; border-radius:3px; }
div.bttn_box input[type=submit]:hover	{ border:1px solid #FF4040; background:#FF4040; color:#ffffff; }
div.bttn_box input[type=button]	{ cursor:pointer; border:1px solid #696969; color:#696969; background:#FBFBFB; padding:5px 10px 7px 10px; border-radius:3px; }
div.bttn_box input[type=button]:hover	{ border:1px solid #696969; background:#696969; color:#ffffff; }
</style>
<?
$mode_val	= "save";
//-- 글쓰기 일 때 페이지 코드 자동 생성
if($mode == "write"){
	$pagecode	= zm_table_encode(time()) . rand(1000, 9999);
	$mode_val	= "save";
}elseif($mode == "edit"){
	$rd	= sql_fetch("select * from zm_page_editor where db_recno='$id'");
	$pagecode	= $rd[db_page_code];
	$mode_val	= "update";
}
?>
<form method="post" name="fwrite" onsubmit="return senddata(this);">
<input type="hidden" name="mode" value="<?=$mode_val?>">
<input type="hidden" name="recno" value="<?=$rd[db_recno]?>">
<input type="hidden" name="pageno" value="<?=$pageno?>">
<input type="hidden" name="editmode" value="<?=$editmode?>">
<table width=100% cellpadding=0 cellspacing=0 class="tbl_box">
<tr>
	<td class="col1">페이지 코드</td>
	<td class="col2"><input size=70 name="in_pagecode" value="<?=$pagecode?>" class="pagecode" readonly onfocus="this.select()"></td>
</tr>
<tr>
	<td class="col1">제목</td>
	<td class="col2"><input name="in_subject" value="<?=$rd[db_subject]?>" size=80 maxlength=80 required autocomplete=off></td>
</tr>
<tr>
	<td class="col1" colspan="2">페이지 내용
	<div style="padding:5px 0 0 0;"><textarea name="in_document" id="in_document" cols=90 rows=32><?=$rd[db_document]?></textarea>
		<script language="javascript">
		var zmContentBody	= "in_document";
		var oEditors = [];
		nhn.husky.EZCreator.createInIFrame({
			oAppRef: oEditors,
			elPlaceHolder: zmContentBody,
			sSkinURI: "<?=$g4[path]?>/zm.smarteditor/SmartEditor2Skin.html",
			fCreator: "createSEditor2"
		});
		</script>
	</div>
	</td>
</tr>
</table>
<div class="bttn_box">
	<input type="submit" accesskey='s' value="저장하기">
<?	if($editmode) : ?>
	<input type="button" value="닫기" onclick="opener.location.reload(); window.close();">
<?	else : ?>
	<input type="button" value="목록" onclick="zm_gourl('./pe.admin.php?pageno=<?=$pageno?>')">
<?	endif; ?>
</div>
</form>

<script>
$(function(){
	document.all.in_subject.focus();
});

function senddata(f) {
	// 에디터의 내용을 에디터 생성시에 사용했던 textarea에 넣어 줍니다. 스마트 에디터
	try{
		oEditors.getById["in_document"].exec("UPDATE_CONTENTS_FIELD", []);
	}catch(e){}

	f.action	="./pe.process.php";

	return true;
}
</script>