<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

//모바일 구분자
if(G4_IS_MOBILE) {
	$scope = '';
	$tr = '</tr><tr>';
	$colspan = '';
	$rowspan = '';
} else {
	$scope = ' scope="row" class="th_w"';
	$tr = '';
	$colspan = ' colspan=2';
	$rowspan = ' rowspan=2';
}

?>

<h1 id="wrapper_title" class="none"><?php echo $g4['title']; ?></h1>

<div class="head-write-back"><div class="head-write-front"><div class="head-write"></div></div></div>

<table id="bo_w" border="1" class="frm_tbl">
<tbody>

<?php if ($is_name) { ?>
<tr>
	<th<?php echo $scope; ?>><label for="wr_name">이름</label></th>
	<?php echo $tr; ?>
	<td><input id="wr_name" type="text" maxlength="20" size="15" name="wr_name" itemname="이름" value="<?php echo $name; ?>" class="wr_m"></td>
</tr>
<?php } ?>

<?php if ($is_password) { ?>
<tr>
    <th<?php echo $scope; ?>><label for="wr_password">패스워드</label></th>
	<?php echo $tr; ?>
    <td><input id="wr_password" type="password" maxlength="20" size="15" name="wr_password" itemname="패스워드" class="wr_m"></td>
</tr>
<?php } ?>

<?php if ($is_email) { ?>
<tr>
    <th<?php echo $scope; ?>><label for="wr_email">이메일</label></th>
	<?php echo $tr; ?>
	<td><input id="wr_email" type="text" maxlength="100" size="50" name="wr_email" email itemname="이메일" value="<?php echo $email; ?>" class="wr_l"></td>
</tr>
<?php } ?>

<?php if ($is_homepage) { ?>
<tr>
    <th<?php echo $scope; ?>><label for="wr_homepage">홈페이지</label></th>
	<?php echo $tr; ?>
    <td><input id="wr_homepage" type="text" size="50" name="wr_homepage" itemname="홈페이지" value="<?php echo $homepage; ?>" class="wr_l"></td>
</tr>
<?php } ?>

<?php if ($option) { ?>
<tr>
    <th<?php echo $scope; ?>><label>글옵션</label></th>
	<?php echo $tr; ?>
    <td>
		<?php echo $option; ?><?php if ($is_secret && $is_secret !=1) echo ' (자동비밀글)'; ?>
	</td>
</tr>
<?php } ?>

<?php if ($is_category) { ?>
<tr>
    <th<?php echo $scope; ?>><label for="ca_name">카테고리</label></th>
	<?php echo $tr; ?>
    <td>
		<select id="ca_name" name="ca_name" itemname="분류">
			<option value="">선택하세요</option>
			<?php echo $category_option; ?>
		</select>
	</td>
</tr>
<?php } ?>

<?php if ($is_star) { ?>
<tr>
    <th<?php echo $scope; ?>><label>별점주기</label></th>
	<?php echo $tr; ?>
    <td>
		<input type="radio" id="star_score10" name="star_score" value="10"<?php if($star['score'] == "10" || !$star['score']) echo ' checked'; ?>>
		<label for="star_score10"><?php echo amina_star_mark($amina['star_color'],"10|1","s"); ?><span class="none">10점</span></label>

		<input type="radio" id="star_score8" name="star_score" value="8"<?php if($star['score'] == "8") echo ' checked'; ?>>
		<label for="star_score8"><?php echo amina_star_mark($amina['star_color'],"8|1","s"); ?><span class="none">8점</span></label>

		<input type="radio" id="star_score6" name="star_score" value="6"<?php if($star['score'] == "6") echo ' checked'; ?>>
		<label for="star_score6"><?php echo amina_star_mark($amina['star_color'],"6|1","s"); ?><span class="none">6점</span></label>

		<input type="radio" id="star_score4" name="star_score" value="4"<?php if($star['score'] == "4") echo ' checked'; ?>>
		<label for="star_score4"><?php echo amina_star_mark($amina['star_color'],"4|1","s"); ?><span class="none">4점</span></label>

		<input type="radio" id="star_score2" name="star_score" value="2"<?php if($star['score'] == "2") echo ' checked'; ?>>
		<label for="star_score2"><?php echo amina_star_mark($amina['star_color'],"2|1","s"); ?><span class="none">2점</span></label>
	</td>
</tr>
<?php } ?>

<?php if ($is_emoticon) { ?>
<tr>
    <th<?php echo $scope; ?>><label>이모티콘</label></th>
	<?php echo $tr; ?>
    <td>
		<img id="emo_icon" onclick="amina_win('emo','<?php echo $bo_table; ?>');" name="emo_icon" src="<?php echo $emo_skin_url.'/'.$wr_icon['post_icon']; ?>.gif" alt="이모티콘" />
		<input type="hidden" name="post_icon" value="<?php echo $wr_icon['post_icon']; ?>">
		<?php if($member['mb_id']) { ?>	
			<p><input type="checkbox" id="post_icon_mb" name="post_icon_mb" value="1"<?php if($wr_icon['post_icon_mb'] == "1") echo ' checked'; ?>> <label for="post_icon_mb">이모티콘 대신 회원사진 적용</label></p>
		<?php } ?>
		<div class="clear"></div>
	</td>
</tr>
<?php } ?>

<tr>
    <th<?php echo $scope; ?>><label for="wr_subject">글제목</label></th>
	<?php echo $tr; ?>
    <td><input type="text" name="wr_subject" size="50" id="wr_subject" itemname="제목" value="<?php echo $subject; ?>" class="wr_max"></td>
</tr>

<?php if ($is_admin) { ?>
<tr>
    <th<?php echo $scope; ?>><label>제목모양</label></th>
	<?php echo $tr; ?>
    <td>
		<input type="checkbox" id="subj_b" name="subj_b" value="1"<?php if($post['subj_b'] == "1") echo ' checked'; ?>>
		<label for="subj_b">두껍게</label>

		<input type="checkbox" id="subj_i" name="subj_i" value="1"<?php if($post['subj_i'] == "1") echo ' checked'; ?>>
		<label for="subj_i">이탤릭</label>

		<input type="checkbox" id="subj_s" name="subj_s" value="1"<?php if($post['subj_s'] == "1") echo ' checked'; ?>>
		<label for="subj_s">취소선</label>
	</td>
</tr>
<tr>
    <th<?php echo $scope; ?>><label for="subj_color">제목색상</label></th>
	<?php echo $tr; ?>
    <td>
		<script src="<?php echo AMINA_URL?>/app/iColorPicker/iColorPicker.js" type="text/javascript"></script>

		<input type="text" id="subj_color" name="subj_color" itemname="제목색상" value="<?php echo $post['subj_color']; ?>" size="10" class="iColorPicker wr_s">
		&nbsp; 예) black 또는 #000000
	</td>
</tr>
<?php } ?>

<tr>
    <td<?php echo $colspan; ?> class="wcontent">
        <div id="autosave_wrapper">
			<?php if(!$editor_form) { ?>
				<?php if ($write_min || $write_max) { ?>
					<button type="button" class="wr-frm-btn">
						<b><span id="char_count"></span></b>자
						<?php 
							if ($write_min && $write_max) { 
								echo '('.$write_min.'/'.$write_max.')';
							} else if (!$write_min && $write_max) { 
								echo '(최대 '.$write_max.')';
							} else if ($write_min && !$write_max) { 
								echo '(최소 '.$write_min.')';
							}
						?>
					</button>
				<?php } ?>
				<button type="button" onclick="amina_textarea('wr_content', 'down');" class="wr-frm-btn">늘임</button>
	            <button type="button" onclick="amina_textarea('wr_content', '150');" class="wr-frm-btn">처음</button>
				<button type="button" onclick="amina_textarea('wr_content', 'up');" class="wr-frm-btn">줄임</button>
			<?php } ?>

			<button type="button" onclick="amina_win('help','<?php echo $bo_table; ?>');" class="wr-frm-btn">도움말</button>

			<?php if ($is_autosave) { // 임시 저장된 글 기능 ?>
		        <button type="button" id="btn_autosave" class="wr-frm-btn">임시저장 글 (<span id="autosave_count"><?php echo $autosave_count; ?></span>)</button>
			    <div id="autosave_pop">
		            <div><b>임시저장 글 목록</b> <button type="button" class="autosave_close"><img src="<?php echo AMINA_URL; ?>/img/btn_close.gif" alt="닫기"></button></div>
			        <ul></ul>
		        </div>
            <?php } ?>

        </div>

		<?php if($editor_form) { ?>
            <?php echo $editor_form; ?>
		<?php } else { ?>
			<div class="wr_content_wrap">
				<textarea id="wr_content" name="wr_content" rows="10" itemname="내용" required 
		        <?php if ($write_min || $write_max) { ?>onkeyup="check_byte('wr_content', 'char_count');"<?php } ?>><?php echo $content; ?></textarea>
			    <?php if ($write_min || $write_max) { ?><script> check_byte('wr_content', 'char_count'); </script><?php } ?>
			</div>
        <?php } ?>
	</td>
</tr>

<?php if ($is_daum_view) { ?>
<tr> 
	<th<?php echo $scope; ?>><label for="daum_view">다음뷰</label></th>
	<?php echo $tr; ?>
	<td>
		<input type="text" size="35" id="daum_view" name="daum_view" itemname="다음 View nid" value="<?php echo $post['daum_view']; ?>" class="wr_m">
		다음 view 주소의 nid 값 입력
	</td>
</tr>
<?php } ?>

<?php if ($is_video) { ?>
<tr> 
	<th<?php echo $scope; ?>><label for="movie_url">동영상</label></th>
	<?php echo $tr; ?>
	<td>
		<select id="movie_file" name="movie_file">
			<option value=""<?php if(!$movie['movie_file']) echo ' selected'; ?>>공유주소</option>
			<option value="1"<?php if($movie['movie_file'] == "1") echo ' selected'; ?>>파일주소</option>
		</select>

		<input type="text" size="35" id="movie_url" name="movie_url" itemname="유튜브 등 동영상 공유 URL" value="<?php echo $movie['movie_url']; ?>" class="wr_l">
		-
		<a href="javascript:amina_show('movie_opt');">옵션설정</a>
		<div id="movie_opt" class="movie_opt" style="display:<?php if($movie['movie_img'] || $movie['movie_align']) { echo 'block'; } else { echo 'none'; } ?>">
			<select id="movie_align" name="movie_align">
				<option value=""<?php if(!$movie['movie_align']) echo ' selected'; ?>>상단출력</option>
				<option value="1"<?php if($movie['movie_align'] == "1") echo ' selected'; ?>>하단출력</option>
			</select>
			<input type="text" size="35" id="movie_img" name="movie_img" itemname="동영상 이미지 URL" value="<?php echo $movie['movie_img']; ?>" class="wr_l"> - 이미지 URL
		</div>
	</td>
</tr>
<?php } ?>

<?php if ($is_file) { ?>
<tr>
    <th<?php echo $scope; ?><?php echo $rowspan?>>
		<label>파일첨부</label>
    </th>
	<?php echo $tr; ?>
	<td>
	<?php 
		if($is_uploader) {
			echo $is_uploader;
		} else {
			$upload_max = number_format(($board['bo_upload_size'] / 1024),0); 

			$file_script = "";
			$file_length = -1;
			// 수정의 경우 파일업로드 필드가 가변적으로 늘어나야 하고 삭제 표시도 해주어야 합니다.
			if ($w == "u") {
			    for ($i=0; $i<$file['count']; $i++) {
				    $row = sql_fetch(" select bf_file, bf_content from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i' ");
					if ($row['bf_file']) {
						$file_script .= "add_file(\"<p><label><input type='checkbox' name='bf_file_del[$i]' value='1'> {$file[$i][source]}({$file[$i][size]}) 파일 삭제</label></p>";
				        if ($is_file_content)
			                $file_script .= "<p><input type='text' size=50 name='bf_content[$i]' value='".addslashes(get_text($row['bf_content']))."' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.'></p>";
					        $file_script .= "\");\n";
				        } else {
						    $file_script .= "add_file('');\n";
						}
				    }
					$file_length = $file['count'] - 1;
				}

				if ($file_length < 0) {
				    $file_script .= "add_file('');\n";
				    $file_length = 0;
				}
		?>
		<table id="variableFiles" border="1">
		<tr><td>
			<ul class="bar11">
				<li class="first"><a onclick="add_file();" class="wr_cursor">파일 추가</a></li>
				<li class="last"><a onclick="del_file();" class="wr_cursor">파일 삭제</a></li>
			</ul>		
		</td></tr>
		</table><?// print_r2($file); ?>
        <script>
        var flen = 0;
        function add_file(delete_code)
        {
            var upload_count = <?php echo (int)$board['bo_upload_count']; ?>;
            if (upload_count && flen >= upload_count)
            {
                alert("이 게시판은 "+upload_count+"개 까지만 파일 업로드가 가능합니다.");
                return;
            }

            var objTbl;
            var objRow;
            var objCell;
            if (document.getElementById)
                objTbl = document.getElementById("variableFiles");
            else
                objTbl = document.all['"variableFiles"'];

            objRow = objTbl.insertRow(objTbl.rows.length);
            objCell = objRow.insertCell(0);

            objCell.innerHTML = '<p><input type="file" name="bf_file[]" title="파일 용량 <?php echo $upload_max?>KB 이하만 업로드 가능"></p>';
            if (delete_code)
                objCell.innerHTML += delete_code;
            else
            {
                <?php if ($is_file_content) { ?>
                objCell.innerHTML += '<p><input type="text" size="50" name="bf_content[]" title="업로드 이미지 파일에 해당 되는 내용을 입력하세요."></p>';
                <?php } ?>
                ;
            }

            flen++;
        }

        <?php echo $file_script; //수정시에 필요한 스크립트 ?>

        function del_file()
        {
            // file_length 이하로는 필드가 삭제되지 않아야 합니다.
            var file_length = <?php echo (int)$file_length; ?>;
            var objTbl = document.getElementById("variableFiles");
            if (objTbl.rows.length - 2 > file_length)
            {
                objTbl.deleteRow(objTbl.rows.length - 1);
                flen--;
            }
        }
        </script>
		<?php } ?>
	</td>
</tr>
<tr>
    <td>
		<select id="img_location" name="img_location"<?php echo $is_uploader_script; ?>>
			<option value="top">첨부사진 상단출력</option>
			<option value="bottom"<?php if($post['img_location'] == "bottom") echo ' selected'; ?>>첨부사진 하단출력</option>
			<option value="insert"<?php if($post['img_location'] == "insert") echo ' selected'; ?>>첨부사진 본문삽입</option>
			<option value="hide"<?php if($post['img_location'] == "hide") echo ' selected'; ?>>첨부사진 출력안함</option>
		</select>

		<input type="checkbox" id="img_space" name="img_space" value="1"<?php if($post['img_space'] == "1") echo ' checked'; ?>>
		<label for="img_space">상ㆍ하단 출력시 사진 붙이기</label>
	</td>
</tr>
<?php } ?>

<?php if ($is_link) { ?>
	<tr> 
		<th<?php echo $scope; ?>><label for="wr_link1">관련링크</label></th>
		<?php echo $tr; ?>
		<td>
			<?php for ($i=1; $i <= G4_LINK_COUNT; $i++) { ?>
				<p><input type="text" size="50" id="wr_link<?php echo $i; ?>" name="wr_link<?php echo $i; ?>" itemname="링크 #<?php echo $i; ?>" value="<?php if($w=="u") echo $write['wr_link'.$i]; ?>" class="wr_max"></p>
			<?php } ?>
		</td> 
	</tr>
<?php } ?>

<?php if ($is_map) { ?>
	<tr>
		<th<?php echo $scope; ?>><label for="map_open">구글지도</label></th>
		<?php echo $tr; ?>
	    <td>
			<input type="button" value="<?php echo $map_txt; ?>" name="map_open" id="map_open" onClick="google_map('<?php echo $bo_table; ?>');">
			<input type="hidden" name="map_width" id="map_width" itemname="지도가로" value="<?php echo $map['map_width']; ?>">
			<input type="hidden" name="map_height" id="map_height" itemname="지도세로" value="<?php echo $map['map_height']; ?>">
			<input type="hidden" name="map_lat" id="map_lat" itemname="위도" value="<?php echo $map['map_lat']; ?>">
			<input type="hidden" name="map_lng" id="map_lng" itemname="경도" value="<?php echo $map['map_lng']; ?>">
			<input type="hidden" name="map_zoom" id="map_zoom" itemname="Zoom" value="<?php echo $map['map_zoom']; ?>">

			<?php if(amina_photo_GPS()) { ?>
				<input type="checkbox" id="chk_mapExif" name="chk_mapExif" value="1">
				<label for="chk_mapExif">첨부사진 GPS 등록</label>
			<?php } ?>

			<?php if($map['map_lat'] || $map['map_lng']) { ?>
				<input type="checkbox" id="map_delete" name="map_delete" value="1">
				<label for="map_delete">지도삭제</label>
			<?php } ?>
		</td>
	</tr>
<?php } ?>

<?php if ($is_poll) { ?> 
	<tr>
		<th<?php echo $scope; ?>><label for="chk_poll">설문조사</label></th>
		<?php echo $tr; ?>
	    <td>
			<input type="button" value="<?php echo $poll_btn; ?>" name="poll_open" id="poll_open" onClick="amina_win('poll','<?php echo $bo_table; ?>');">

			<input type="checkbox" id="chk_poll" name="chk_poll" value="poll"<?php if($post['chk_poll'] == "poll") echo ' checked'; ?>>
			<label for="chk_poll">등록하기</label>
			
			<input type="hidden" id="poll_subject" name="poll_subject" value="<?php echo $poll['poll_subject']; ?>">
			<input type="hidden" id="poll_y" name="poll_y" value="<?php echo date("Y", $poll['poll_enddate']); ?>">
			<input type="hidden" id="poll_m" name="poll_m" value="<?php echo date("m", $poll['poll_enddate']); ?>">
			<input type="hidden" id="poll_d" name="poll_d" value="<?php echo date("d", $poll['poll_enddate']); ?>">
			<input type="hidden" id="poll_h" name="poll_h" value="<?php echo date("H", $poll['poll_enddate']); ?>">
			<input type="hidden" id="poll_i" name="poll_i" value="<?php echo date("i", $poll['poll_enddate']); ?>">
			<input type="hidden" id="poll_level" name="poll_level" value="<?php echo $poll['poll_level']; ?>">
			<input type="hidden" id="poll_location" name="poll_location" value="<?php echo $post['poll_location']; ?>">

			<?php $poll['poll_point'] = $poll['poll_point'] ? $poll['poll_point'] : $amina['poll_point']; ?>
			<input type="hidden" id="poll_point" name="poll_point" value="<?php echo $poll['poll_point']; ?>">
			<input type="hidden" id="poll_item1" name="poll_item1" value="<?php echo $poll['poll_item1']; ?>">
			<input type="hidden" id="poll_item2" name="poll_item2" value="<?php echo $poll['poll_item2']; ?>">
			<input type="hidden" id="poll_item3" name="poll_item3" value="<?php echo $poll['poll_item3']; ?>">
			<input type="hidden" id="poll_item4" name="poll_item4" value="<?php echo $poll['poll_item4']; ?>">
			<input type="hidden" id="poll_item5" name="poll_item5" value="<?php echo $poll['poll_item5']; ?>">
			<input type="hidden" id="poll_item6" name="poll_item6" value="<?php echo $poll['poll_item6']; ?>">
			<input type="hidden" id="poll_item7" name="poll_item7" value="<?php echo $poll['poll_item7']; ?>">
			<input type="hidden" id="poll_item8" name="poll_item8" value="<?php echo $poll['poll_item8']; ?>">
			<input type="hidden" id="poll_item9" name="poll_item9" value="<?php echo $poll['poll_item9']; ?>">
		</td>
	</tr>
<?php } ?>

<?php if ($is_po_view || $is_po_down || $is_choice) { ?>
	<tr>
		<th<?php echo $scope; ?>>
			<?php if ($is_po_view || $is_po_down) { ?>
				<label><a href="javascript:amina_show('po_help');" title="이용 및 적립 안내">포인트(!)</a></label>
			<?php } else { ?>
				<label>포인트</label>
			<?php } ?>
		</th>
		<?php echo $tr; ?>
	    <td>
			<?php if ($is_po_view) { ?>
				<label for="po_view_point">열람</label>
				<input type="text" size="6" name="po_view_point" id="po_view_point" numeric itemname="열람포인트" class="wr_t" value="<?php echo $wr_icon['po_view_point']; ?>">
				&nbsp;
			<?php } ?>
			<?php if ($is_po_down) { ?>
				<label for="po_down_point">다운</label>
				<input type="text" size="6" name="po_down_point" id="po_down_point" numeric itemname="다운포인트" class="wr_t" value="<?php echo $wr_icon['po_down_point']; ?>">
				&nbsp;
			<?php } ?>
			<?php if ($is_choice) { ?>
				<label for="choice_point"><?php echo $amina['cmt_choice_txt']; ?></label>
				<input type="text" size="6" id="choice_point" name="choice_point" id="choice_point" numeric itemname="<?php echo $amina['cmt_choice_txt']; ?>포인트" value="<?php echo $wr_icon['choice_point']; ?>" class="wr_t" <?php if(!$is_admin && $w=="u") echo 'readonly style="background:pink;" title="수정불가"'; ?>>
				(최대 <b><?php echo number_format($member['mb_point']); ?></b>점 <?php if($amina['cmt_choice_return'] > 0) { ?> / <?php echo $amina['cmt_choice_txt']; ?>시 <b><?php echo $amina['cmt_choice_return']; ?></b>% 복구<?php } ?>)
			<?php } ?>

			<?php if ($is_po_view || $is_po_down) { ?>
				<table id="po_help" border=0 class="po_help" style="display:none;">
				<tr>
				<th>구분</th>
				<th>이용횟수</th>
				<th>이용기간</th>
				<th>유효시간</th>
				<th>적립기간</th>
				<th>수수료율</th>
				</tr>
				<?php if ($is_po_view) { ?>
				<tr>
				<td>열람</td>
				<td><?php echo $amina['po_view_cnt']; ?> 회</td>
				<td><?php echo $amina['po_view_day']; ?> 일</td>
				<td><?php echo $amina['po_view_time']; ?> 시간</td>
				<td><?php echo $amina['po_view_term']; ?> 일</td>
				<td><?php echo $amina['po_view_fee']; ?> %</td>
				</tr>
				<?php } ?>
				<?php if ($is_po_down) { ?>
				<tr>
				<td>다운</td>
				<td><?php echo $amina['po_down_cnt']; ?> 회</td>
				<td><?php echo $amina['po_down_day']; ?> 일</td>
				<td><?php echo $amina['po_down_time']; ?> 시간</td>
				<td><?php echo $amina['po_down_term']; ?> 일</td>
				<td><?php echo $amina['po_down_fee']; ?> %</td>
				</tr>
				<?php } ?>
				<tr>
				<td colspan=6>
					<ul>
					<li>이용횟수 : 1회 포인트 차감후 이용횟수</li>
					<li>이용기간 : 1회 포인트 차감후 이용기간</li>
					<li>유효시간 : 1회 포인트 차감후 무료이용시간</li>
					<li>적립기간 : 등록일로부터 등록자에게 포인트 적립 기간('0'이면 무제한)</li>
					<li>수수료율 : 수수료율 만큼 차감후 등록자에게 포인트 적립</li>
					</ul>
				</td>
				</tr>
				</table>
			<?php } ?>
		</td>
	</tr>
<?php } ?>

<?php if ($is_po_view) { ?>
	<tr>
		<th<?php echo $scope; ?>><label for="wr_3">열람요약</label></th>
		<?php echo $tr; ?>
	    <td>
			<p><label for="po_img_cnt">미리보기 스샷</label>
			<?php if($wr_icon['po_img_cnt'] == "") $wr_icon['po_img_cnt'] = 1; ?>
			<input type="text" size="2" name="po_img_cnt" id="po_img_cnt" numeric itemname="미리보기 스샷" class="wr_t" value="<?php echo $wr_icon['po_img_cnt']; ?>"> 개
			- 입력글자 <b><span id="po_view_summary">0</span></b>자 / 250자
			</p>
			<div class="wr_content_wrap">
				<textarea id="wr_3" name="wr_3" rows=3 itemname="요약" onkeyup="check_byte('wr_3', 'po_view_summary');"><?php echo $write['wr_3']; ?></textarea>
			    <script> check_byte('wr_3', 'po_view_summary'); </script>
			</div>
		</td>
	</tr>
<?php } ?>

<?php if ($is_tag) { //태그사용여부 체크 ?>
<tr>
    <th<?php echo $scope; ?>><label for="related_tag">관련글</label></th>
	<?php echo $tr; ?>
    <td>
		<?php if($w == "u" && $write['wr_7']) $rtag = amina_array_tag($write['wr_7']); ?>
		<input type="text" size="34" maxlength="100" id="related_tag" name="related_tag" itemname="관련글" value="<?php echo $rtag['related_tag']; ?>" class="wr_l">
		<input type="radio" id="tag_and" name="tag_sop" value="and"<?php if($rtag['tag_sop'] != "or") echo ' checked'; ?>>
		<label for="tag_and">일치</label>
		<input type="radio" id="tag_or" name="tag_sop" value="or"<?php if($rtag['tag_sop'] == "or") echo ' checked'; ?>>
		<label for="tag_or">포함</label>
	</td>
</tr>
<tr>
    <th<?php echo $scope; ?>><label for="tag">태그(tag)</label></th>
	<?php echo $tr; ?>
    <td>
		<?php
			if($post['chk_tag']) {
			    include_once(AMINA_PATH.'/lib/tag.lib.php');
				$tag = amina_get_tag($bo_table, $wr_id);
			}
		?>
		<input type="text" size="34" id="tag" name="tag" itemname="태그" value="<?php echo $tag; ?>" class="wr_l">
		<input type="checkbox" id="chk_tag" name="chk_tag" value="1"<?php if($post['chk_tag'] == "1") echo ' checked'; ?>>
		<label for="chk_tag">등록하기</label>
	</td>
</tr>
<?php } ?>

<?php if (AMINA != "g4s" && $is_trackback) { ?>
<tr>
    <th<?php echo $scope; ?>><label for="wr_trackback">트랙백</label></th>
	<?php echo $tr; ?>
    <td><input type="text" size="50" id="wr_trackback" name="wr_trackback" itemname="트랙백" value="<?php echo $trackback; ?>" class="wr_l">
        <?php if ($w=="u") { ?><input type="checkbox" id="re_trackback" name="re_trackback" value="1"> <label for="re_trackback">핑 보냄</label><?php } ?>
	</td>
</tr>
<?php } ?>

<?php if($captcha_html) { ?>
	<tr>
	    <th<?php echo $scope; ?>><label for="captcha_key">등록코드</label></th>
		<?php echo $tr; ?>
		<td class="wr_cpatcha">
	        <?php echo $captcha_html; ?>
	    </td>
	</tr>
<?php } ?>
</tbody>
</table>

<script>
<?php
// 관리자라면 분류 선택에 '공지' 옵션을 추가함
if ($is_admin) 
{
    echo "
    if (typeof(document.fwrite.ca_name) != 'undefined')
    {
        document.fwrite.ca_name.options.length += 1;
        document.fwrite.ca_name.options[document.fwrite.ca_name.options.length-1].value = '공지';
        document.fwrite.ca_name.options[document.fwrite.ca_name.options.length-1].text = '공지';
    }";
} 
?>

with (document.fwrite) 
{
    if (typeof(wr_name) != "undefined")
        wr_name.focus();
    else if (typeof(wr_subject) != "undefined")
        wr_subject.focus();
    else if (typeof(wr_content) != "undefined")
        wr_content.focus();

    if (typeof(ca_name) != "undefined")
        if (w.value == "u")
            ca_name.value = "<?php echo $write[ca_name]?>";
}

function html_auto_br(obj) 
{
    if (obj.checked) {
        result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
        if (result)
            obj.value = "html2";
        else
            obj.value = "html1";
    }
    else
        obj.value = "";
}

</script>