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

<link rel="stylesheet" href="<?php echo $member_skin_url; ?>/formmail.css">

<section id="at-mail">
    <form name="fformmail" action="<?php echo $action_url; ?>" onsubmit="return fformmail_submit(this);" method="post" enctype="multipart/form-data" data-ajax="false">
	<input type="hidden" name="to" value="<?php echo $email; ?>">
    <input type="hidden" name="attach" value="2">
    <input type="hidden" name="token" value="<?php echo $token; ?>">
	<?php if ($is_member) { // 회원이면 ?>
	    <input type="hidden" name="fnick" value="<?php echo $member['mb_nick']; ?>">
	    <input type="hidden" name="fmail" value="<?php echo $member['mb_email']; ?>">
    <?php } ?>

	<div class="msg-box box-black">
		<i class="fa fa-envelope fa-large"></i> <?php echo $name ?>님께 메일보내기
	</div>

	<table>
	<?php if (!$is_member) { ?>
		<tr>
		<th scope="row"><i class="fa fa-user"></i> 이름<strong class="sound_only">필수</strong></th>
		<td>
			<input type="text" name="fnick" id="fnick" required></td>
		</tr>
		<tr>
		<th scope="row"><i class="fa fa-star"></i> E-mail<strong class="sound_only">필수</strong></th>
		<td>
			<input type="email" id="fmail" name="fmail" required>
		</td>
		</tr>
	<?php } ?>
	<tr>
	<th scope="row"><i class="fa fa-pencil"></i> 제목<strong class="sound_only">필수</strong></th>
	<td>
		<input type="text" id="subject" name="subject" required style="width:98%">
	</td>
	</tr>
	<tr>
	<th scope="row"><i class="fa fa-code"></i> 형식</th>
	<td>
		<label><input type="radio" name="type" value="0" id="type_text" checked> TEXT</label>
		<label><input type="radio" name="type" value="1" id="type_html"> HTML</label>
		<label><input type="radio" name="type" value="2" id="type_both"> TEXT+HTML</label>
	</td>
	</tr>
	<tr>
	<th scope="row"><i class="fa fa-comment"></i> 내용<strong class="sound_only">필수</strong></th>
	<td>
		<textarea name="content" id="content" rows=5 required style="width:98%;"></textarea>
	</td>
    </tr>
	<tr>
    <th scope="row"><i class="fa fa-paperclip"></i> 첨부</th>
    <td>
		<input type="file" name="file1" id="file1">
		<p><input type="file" name="file2" id="file2"></p>
	</td>
    </tr>
	<tr>
	<th scope="row"><i class="fa fa-lock"></i> 자동등록방지</th>
    <td><?php echo $captcha_html; ?></td>
    </tr>
    </table>
	<p align="center">
		<button type="submit" id="btn_submit"><i class="fa fa-check-circle fa-lg"></i> <b>보내기</b></button>
	</p>
	</form>

	<script>
	function fformmail_submit(f) {
		<?php echo $captcha_js; ?>

		if (f.file1.value || f.file2.value) {
			// 4.00.11
	        if (!confirm("첨부파일의 용량이 큰경우 전송시간이 오래 걸립니다.\n\n메일보내기가 완료되기 전에 창을 닫거나 새로고침 하지 마십시오."))
		        return false;
		}

	    document.getElementById('btn_submit').disabled = true;

		return true;
	}
	</script>
</section>
