<?
//관리자만 글쓰기 기능 체크
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;

if($_REQUEST[mode]=="modify"){
	$arrPhone = explode("-",$arrBoardArticle["list"][0][etc_2]);
	$arrFax = explode("-",$arrBoardArticle["list"][0][etc_3]);
	$arrEmail = explode("@",$arrBoardArticle["list"][0][etc_4]);
}
?>
<!-- 글쓰기페이지 START -->
<script language="javascript">
function frmCheck(frm){
	if(frm.name.value.length < 1){
		alert('이름을 입력해 주세요.');
		frm.name.focus();
		return false;
	}
	<?//if(!$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]){?>
	if(frm.pass.value.length < 1){
		alert('비밀번호를 입력해 주세요.');
		frm.pass.focus();
		return false;
	}
	<?//}?>
	if (frm.etc_1.value==""){
		alert("연락처를 입력해 주세요.");
		frm.etc_1.focus();
		return false;
	}
	if (frm.email.value.length < 2){
		alert("이메일을 입력해 주세요.");
		frm.email.focus();
		return false;
	}
	if(frm.subject.value.length < 1){
		alert('제목을 입력해 주세요.');
		frm.subject.focus();
		return false;
	}
	<?//if(!$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]){?>
	if (frm.agree.checked != true){
		alert("개인정보 수집 및 이용에 동의해주세요.");
		frm.agree.focus();
		return false;
	}	
	<?//}?>
	try{ contents.outputBodyHTML(); } catch(e){ }

}

function setEmailDom(frm,val){
		frm.email_domain.value = val;
		if(val==""){
			frm.email_domain.focus();
		}
}

//첨부파일 열 추가
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>
<!-- 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="N">
<input type="hidden" name="uselock" value="Y">
<input type="hidden" name="etc_4" value="">

<fieldset>
	<legend>문의하기</legend>
	<div class="mailform">
		<!-- <p class="compulsory"><span class="star">*</span>는 필수항목입니다.</p> -->
		<table summary="문의를 위한 정보 입력">
			<caption>문의하기</caption>
			<colgroup>
				<col width="17.5%">
				<col width="82.5%">
			</colgroup>
			<tbody>
				<?if($arrBoardCatTotal > 0){//카테고리 있을경우?>
				<tr>
					<th scope="row"><label for="category">문의유형</label></th>
					<td>
						<?if($_REQUEST[mode]=="modify"){?>
						<select name="category" class="select" style="width:375px;">
						<!-- <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" style="width:375px;">
						<!-- <option value=""<?=$_GET[category]==""?" selected":""?>>구분</option> -->
						<?for($i=0; $i<$arrBoardCatTotal;$i++){?>
						<option value="<?=$arrBoardCategory[$i]?>"<?=$category==$arrBoardCategory[$i]?" selected":""?>><?=$arrBoardCategory[$i]?></option>
						<?}?>
						</select>
						<?}?>
					</td>
				</tr>	
				<?}?>
				<?
				if($_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]){
				?>
				<tr>
					<th scope="row"><label for="subject">조회수</label></th>
					<td>
					<input type="text" name="hit" id="hit" title="조회수" class="input" style="width:20%" value="<?if($_REQUEST[mode]=="modify"):?><?=$arrBoardArticle["list"][0][hit]?><?else:?>0<?endif;?>"/>
					</td>
				</tr>
				<?}?>
				<tr>
					<th scope="row"><label for="subject">제목</label></th>
					<td>
						<input type="text" name="subject" id="title" title="제목" class="input" style="width:98%" value="<?=$arrBoardArticle["list"][0]["subject"]?>"/>
					</td>
				</tr>
				<tr>
					<th scope="row"><label for="name">이름</label></th>
					<td>
					<input type="text" name="name" id="name" class="input" style="width:98%;" value="<?if($_REQUEST[mode]=="modify"):?><?=$arrBoardArticle["list"][0][name]?><?else:?><?=$_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["NAME"]?><?endif;?>" placeholder="이름을 입력해 주세요"/>
					</td>
				</tr>
				<tr>
					<th scope="row"><label for="pass">비밀번호</label></th>
					<td>
					<input type="password" name="pass" id="pass" class="input" style="width:98%;" value="<?=$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["ID"]!=""?$arrBoardArticle["list"][0][pass]:""?>" placeholder="비밀번호를 입력해 주세요"/>
					</td>
				</tr>
				<tr>
					<th scope="row"><label for="phone_1">연락처</label></th>
					<td>
						<input type="text" name="etc_1" id="tel" class="input" style="width:98%;" placeholder="연락처를 입력해주세요" value="<?=stripslashes($arrBoardArticle["list"][0][etc_1])?>">
					</td>
				</tr>
				<tr>
					<th scope="row"><label for="email1">이메일</label></th>
					<td>
						<input type="text" name="email" id="email" class="input" style="width:100%;" placeholder="이메일을 입력해주세요" value="<?=stripslashes($arrBoardArticle["list"][0][email])?>">
					</td>
				</tr>	
				<tr>
					<th scope="row"><label for="memo">내용</label></th>
					<td>
						<textarea name="contents1" id="memo" class="textarea" style="width:98%;height:180px;"><?=stripslashes($arrBoardArticle["list"][0][contents])?></textarea>
					</td>
				</tr>	
				<tr>
					<th scope="row"><label for="file">첨부파일</label></th>
					<td>
						<input type="file" name="upfiles[]" id="file" style="width:400px;">
					</td>
				</tr>
				<!-- <tr>
					<th scope="row"><label for="file2">첨부파일 2</label></th>
					<td>
						<input type="file" name="upfiles[]" id="file2" style="width:400px;">
					</td>
				</tr> -->
				<?
				if($arrBoardArticle["total_files"]>0 && $_REQUEST[mode]=="modify"){
				?>
				<?for($i=0;$i<$arrBoardArticle["total_files"];$i++){?>
					<tr>
					<th scope="row"><label for="file2">등록된 첨부파일</label></th>
						<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>

	<div class="form-agree">
		<a href="../sub/pop_privacy.html" class="pop_privacy btn">[개인정보취급방침 전문보기]</a>
		<dl>
			<dt>개인정보 수집 및 이용에 대한 안내</dt>
			<dd>
				<div class="scroll-box" tabindex="0">
					'국제 알버트 슈바이처 재단'는 기업/단체 및 개인의 정보 수집 및 이용 등 처리에 있어 아래의 사항을 관계법령에 따라 고지하고 안내해 드립니다. <br>
					<br>
					1. 정보수집의 이용 목적 : 상담 및 진행<br>
					2. 수집/이용 항목 : 이름, 일반전화, 휴대전화, 이메일, 상담내용<br>
					3. 보유 및 이용기간 : 상담 종료후 6개월, 정보제공자의 삭제 요청시 즉시<br>
					4. 개인정보처리담당 : 전화 000-000-0000 / 이메일 test@naver.com
				</div>
			</dd>
			<dd><input type="checkbox" name="agree" id="p_chk"><label for="p_chk">개인정보 수집 및 이용에 동의합니다.</label></dd>
		</dl>
	</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>
</fieldset>	

<!-- <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;
?>
