<?
//관리자만 글쓰기 기능 체크
if($arrBoardInfo["list"][0]["useadminonly"] !="Y" || $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]):
	if($_REQUEST[mode]=="reply" && $arrBoardInfo["list"][0]["usereply"] !="Y"):
		jsMsg("답글쓰기가 제한된 게시판 입니다.");
		jsHistory("-1");
		exit;
	endif;
?>
<!-- 글쓰기페이지 START -->
<script language="javascript">
function frmCheck(frm){
	if(frm.name.value.length < 1){
		alert('이름을 입력해 주세요.');
		frm.name.focus();
		return false;
	}

	if(frm.subject.value.length < 1){
		alert('제목을 입력해 주세요.');
		frm.subject.focus();
		return false;
	}
	<?if(!$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]){?>
	if(frm.pass.value.length < 1){
		alert('비밀번호를 입력해 주세요.');
		frm.pass.focus();
		return false;
	}
	<?}?>
	if(frm.writekey.value.length < 1){
		alert('보안문자를 입력해 주세요.');
		frm.writekey.focus();
		return false;
	}
	try{ contents.outputBodyHTML(); } catch(e){ }

}

function editorCheck(gb) {
	if(gb == "Y") {
		document.getElementById("contentEditor1").style.display = "";
		document.getElementById("contentArea1").style.display = "none";
	} else {
		document.getElementById("contentEditor1").style.display = "none";
		document.getElementById("contentArea1").style.display = "";
	}
}

//첨부파일 열 추가
var rowcount = 0;
function append() {   
	var tbl = document.getElementById("files_table").getElementsByTagName("TBODY")[0];  
	var html1 = "<input name='upfiles[]' type='file' class='input'  style='width: 400px;'>";  
	var row = document.createElement("tr"); 
	var col1 = document.createElement("td");   
	row.appendChild(col1);  
	col1.innerHTML = html1;  
	tbl.appendChild(row);  
	rowcount++;
}

function remove() {  
	if(rowcount > 0){
		var tbl = document.getElementById("files_table").getElementsByTagName("TBODY")[0];  
		if (tbl.hasChildNodes()) {      
			tbl.removeChild(tbl.lastChild);     // 마지막 로우   //tbl.removeChild(tbl.firstChild);  // 첫번째 로우  
		}
		rowcount--;
	}
}
//첨부파일 열 추가
</script>

<script type="text/javascript" src="/module/board/md5.js"></script>
<script type="text/javascript" src="/module/board/jquery.kcaptcha.js"></script>

<!-- S 쓰기페이지 -->
<form name="form1" method="post" action="/module/board/board_evn.php" ENCTYPE="multipart/form-data" onsubmit="javascript:return frmCheck(this);">
<?if($_REQUEST[mode]=="reply"):?>
<input type="hidden" name="evnMode" value="reply">
<?elseif($_REQUEST[mode]=="modify"):?>
<input type="hidden" name="evnMode" value="modify">
<?else:?>
<input type="hidden" name="evnMode" value="write">
<?endif;?>

<input type="hidden" name="boardid" value="<?=$arrBoardInfo["list"][0]["boardid"]?>">
<input type="hidden" name="returnURL" value="<?=$_SERVER[PHP_SELF]?>?mNum=<?=$mNum?>&sNum=<?=$sNum?>&boardid=<?=$arrBoardInfo["list"][0]["boardid"]?>&mode=list&category=<?=$_GET[category]?>">
<input type="hidden" name="idx" value="<?=$arrBoardArticle["list"][0]["idx"]?>">
<input type="hidden" name="usehtml" value="Y">
<input type="hidden" name="category" value="<?=$_GET[category]?>">

<div class="board-write">
		<fieldset>
			<legend>글 작성</legend>
			<div class="group first">
				<label for="user_name" class="title">작성자</label>
				<input type="text" name="name" id="user_name" title="작성자" value="<?if($_REQUEST[mode]=="modify"):?><?=$arrBoardArticle["list"][0][name]?><?else:?><?=$_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["NAME"]?><?endif;?>" class="input" style="width:100px" />
			</div>
			<!-- <p>
				<label class="title">공개여부</label>
				<input type="radio" name="publicYN" id="publicY" value="Y" checked="checked" /><label for="publicY">공개글</label> &nbsp;
                <input type="radio" name="publicYN" id="publicN" value="N" /><label for="publicN">비공개글</label>
			</p> -->
			<div class="group">
				<label for="pass" class="title">비밀번호</label>
				<input type="password" name="pass" id="pass" title="비밀번호" class="input" style="width:100px" /> <?if($arrBoardInfo["list"][0]["uselock"]=="Y"):?><input type="checkbox" id="uselock" name="uselock" value="Y"<?=$arrBoardArticle["list"][0][uselock]=="Y"?" checked ":""?>><label for="uselock">글잠금</label><?endif;?>
			</div>
			<?if($arrBoardCatTotal > 0){//카테고리 있을경우?>
			<div class="group">
				<label for="user_name" class="title">카테고리</label>
				<?if($_REQUEST[mode]=="modify"){?>
				<select name="category" class="select">
				<option value=""<?=$_GET[category]==""?" selected":""?>>구분</option>
				<?for($i=0; $i<$arrBoardCatTotal;$i++){?>
				<option value="<?=$arrBoardCategory[$i]?>"<?=$arrBoardArticle["list"][0][category]==$arrBoardCategory[$i]?" selected":""?>><?=$arrBoardCategory[$i]?></option>
				<?}?>
				</select>
				<?}else{?>
				<select name="category" class="select">
				<option value=""<?=$_GET[category]==""?" selected":""?>>구분</option>
				<?for($i=0; $i<$arrBoardCatTotal;$i++){?>
				<option value="<?=$arrBoardCategory[$i]?>"<?=$category==$arrBoardCategory[$i]?" selected":""?>><?=$arrBoardCategory[$i]?></option>
				<?}?>
				</select>
				<?}?>
			</div>
			<?}?>
			<div class="group">
				<label for="title" class="title">제목</label>
				<input type="text" name="subject" id="title" title="제목" class="input" style="width:80%" value="<?=$arrBoardArticle["list"][0]["subject"]?>"/><? if(($_REQUEST[mode]=="write" || $_REQUEST[mode]=="modify") && $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]){?>
			<input name="is_notice" type="checkbox" value="Y"  <?=$arrBoardArticle["list"][0][no]=="0"?" checked ":""?>>공지<? }?>
			</div>
			<div class="group">
				<a href="#boardContent" class="hide">내용작성 바로가기</a><!-- 클릭하면 텍스트에디터 내용작성으로 -->
                <label class="title">내용</label>
				<input type="radio" name="usehtml" id="EditarY" value="Y" <?=($arrBoardArticle["list"][0]["usehtml"]=="Y"||$arrBoardArticle["list"][0]["usehtml"]=="")?"checked='checked'":""?> onclick="editorCheck('Y')" /><label for="EditarY">웹에디터로 내용 작성</label> &nbsp;
                <input type="radio" name="usehtml" id="EditarN" value="N" <?=$arrBoardArticle["list"][0]["usehtml"]=="N"?"checked='checked'":""?> onclick="editorCheck('N')" /><label for="EditarN">텍스트에디터로 내용 작성</label>
			</div>
			<div class="content" id="contentEditor1" <?=($arrBoardArticle["list"][0]["usehtml"]=="Y"||$arrBoardArticle["list"][0]["usehtml"]=="")?"":"Style='display:none;'"?>>
				<? if($_REQUEST[mode]=="reply"):?>
				<? $edit_content = "<p>&nbsp;</div>======================<br>>>".$arrBoardArticle["list"][0][name]."님 글<br><br>".stripslashes($arrBoardArticle["list"][0][contents]); ?>
				<?else:?>
				<? $edit_content = stripslashes($arrBoardArticle["list"][0][contents]); ?>
				<?endif;?>
				<?
				$edit_height="240"; 
				include $_SERVER[DOCUMENT_ROOT] . "/webedit/Editor.html";
				?>		
			</div>
			<div class="content" id="contentArea1" <?=$arrBoardArticle["list"][0]["usehtml"]=="N"?"":"Style='display:none;'"?>>
				<textarea name="contents1" id="contentA" cols="90" rows="20" class="textarea" style="width:99%;" title="내용"><?
				if($_REQUEST[mode]=="reply"):
				echo "\n\n======================\n>>" . $arrBoardArticle["list"][0][name] . "님 글" . stripslashes($arrBoardArticle["list"][0][contents]) ;
				else:
				echo stripslashes($arrBoardArticle["list"][0][contents]) ;
				endif;
				?>
				</textarea>
			</div>
			<?if($arrBoardInfo["list"][0]["usepds"]=="Y"):?>
			<div class="group">
				<label for="file" class="title">첨부파일</label>
				<table id="files_table" class="files_table">
					<tbody>
						<tr>
							<td><input name="upfiles[]" type="file" class="input" style="width: 400px;"> <a href="javascript:append();" class="btn-pack medium"><font color=blue>추가</font></a> <a href="javascript:remove();" class="btn-pack medium"><font color=red>삭제</font></a></td>
						</tr>
					</tbody>
				</table>
				<?
				if($arrBoardArticle["total_files"]>0 && $_REQUEST[mode]=="modify"){
				?>
				<table id="files_list" border="0" cellpadding="3" cellspacing="1" width="100%" style="padding-left:20%">
					<tbody>
				<?for($i=0;$i<$arrBoardArticle["total_files"];$i++){?>
					<tr> 
						<td><input type="checkbox" name="filedel[]" value="<?=$arrBoardArticle["files"][$i][idx]?>" id="filedel_<?=$i?>"><label for="filedel_<?=$i?>">삭제</label> : <?=$arrBoardArticle["files"][$i][ori_name]?></td>
					</tr>
				<?}?>

					</tbody>
				</table>
				<?}?>
			</div>
			<?endif;?>
			<div class="group">
				<label for="file" class="title">보안문자</label>
				<img id='kcaptcha_image' border='0' style="cursor:pointer;">&nbsp;&nbsp;<input class="input" type="text" size="10" name="writekey" id="writekey" style="height:18px;border:1px solid #ccc;">
			</div>
		</fieldset>
</div>
<div class="buttons">
	<div class="cen">
		<input type="submit" value="확인" class="btn-pack large">
		<a href="<?=$_SERVER[PHP_SELF]?>?mNum=<?=$mNum?>&sNum=<?=$sNum?>&boardid=<?=$arrBoardInfo["list"][0]["boardid"]?>&mode=list&category=<?=$_GET[category]?>" class="btn-pack large">취소</a>
	</div>
</div>
<!-- <div class="buttons">
	<div class="cen">
		<span class="btn_pack large"><input type="submit" value="확인" /></span>
    	<span class="btn_pack large"><a href="<?=$_SERVER[PHP_SELF]?>?mNum=<?=$mNum?>&sNum=<?=$sNum?>&boardid=<?=$arrBoardInfo["list"][0]["boardid"]?>&mode=list&category=<?=$_GET[category]?>">취소</a></span>
    </div>
</div> -->
</form>

<?
else:
jsMsg("관리자만 등록/수정/삭제 할 수 있는 게시판 입니다.");
jsHistory("-1");
endif;
?>
