<?
//파라미터정보 *************************************************************************************
$b_num		= InputValue($b_num);
$b_type		= InputValue($b_type);

//**************************************************************************************************




If ($b_num == "") {	//일반등록
	
	$w_mode= "W";

	
	If ($b_type == "") { $b_type = "N"; }//값이 있으면 답변타입이다..
	If ($b_type == "N") { $b_content = $a_writecontent; }

	$b_open = "Y";

	$b_sbjclr = "#ffffff";


}else If ($b_num != "" And  $b_type == "R") { //답변글쓰기 일때
	
	$w_mode= "WR";

	//레코드필드
	$R_Fields = "b_num, b_subject, b_content, b_ref, b_step, b_level";

	$R_tablename_str = $a_tablename;

	$R_WHERE_str = " WHERE b_num=".$b_num;

	SelectQuery ($R_Fields, $R_tablename_str, $R_WHERE_str);

	$b_subject = "RE:".$b_subject;

	$b_content = "<br /><br /><br /><br />------------------ 원문 -------------------------<br /><br />".$b_content;

		
}Else If($b_num != ""){ //그냥 수정일때..

	$w_mode = "M";

	If ($is_ad_cms != "Y") { //관리자가아닐때 체크


		If ($_SESSION["pwd_chk_".$a_num."_".$b_num] != "ok") { //체크통과했으면..
			
			locationhref("pwd.php?prepage=modi&amp;a_num=".$a_num."&amp;b_num=".$b_num."&amp;".$page_info);
			

		}

	}



	//레코드필드
	$R_Fields = "b_num, b_type, b_id, b_name, b_pwd, b_subject, b_email, b_jumin, b_phone1, b_phone2, b_phone3, b_cate, b_catename, b_noticechk, b_content, b_ip, b_count, b_look, b_open, b_ref, b_step, b_level, b_regdate, b_chuchun, b_sbjclr, b_sdate, b_edate, b_temp1, b_temp2, b_temp3, b_temp4, b_file1, b_file2, b_file3, b_file4, b_file5,b_keyword";

	$R_tablename_str = $a_tablename;

	$R_WHERE_str = " WHERE b_num=".$b_num;

	SelectQuery ($R_Fields, $R_tablename_str, $R_WHERE_str);
	
}




if($b_sdate  == ""){

	$b_sdate_y = date("Y");
	$b_sdate_m = date("m");
	$b_sdate_d = date("d");

}else{

	$b_sdate_arr	= explode("-", $b_sdate);

	$b_sdate_y = $b_sdate_arr[0];
	$b_sdate_m = $b_sdate_arr[1];
	$b_sdate_d = $b_sdate_arr[2];

}


if($b_edate  == ""){

	$b_edate_y = date("Y");
	$b_edate_m = date("m");
	$b_edate_d = date("d");

}else{

	$b_edate_arr	= explode("-", $b_edate);

	$b_edate_y = $b_edate_arr[0];
	$b_edate_m = $b_edate_arr[1];
	$b_edate_d = $b_edate_arr[2];

}


?>

<?include("top.php"); //상단파일?>



<script type="text/javascript">//<![CDATA[
		

		
		function w_chk(){
			
			if (CheckSpaces(document.getElementById('frm').b_name, '이름')) {return false;}
			else if (CheckSpaces(document.getElementById('frm').b_pwd, '비밀번호')) {return false;}
			else if (CheckSpaces(document.getElementById('frm').b_subject, '제목')) {return false;}



			loading_st(1);

		}



		function colorPicker(val){

			if(val==1){ //보여라
				document.getElementById('colorPicker_view').style.visibility='visible';

			}else if(val==2){
				document.getElementById('colorPicker_view').style.visibility='hidden'; 
			}
		}

		function colorselect(color) {
			document.getElementById('colorsel').style.backgroundColor= color;
			document.getElementById('b_subject').style.backgroundColor= color;
			document.getElementById('b_subject').style.color= "#FFFFFF";

			document.getElementsByName('b_sbjclr')[0].value = color;
		}

		function colorselect_white(color) {
			document.getElementById('colorsel').style.backgroundColor= color;
			document.getElementById('b_subject').style.backgroundColor= color;
			document.getElementById('b_subject').style.color= "#000000";

			document.getElementsByName('b_sbjclr')[0].value = color;
		}



	//]]>
	</script>

<!-- 쓰기 -->
<div id="board" style="width:<?=$a_width?>;">
	
	<form id="frm" method="post" action="write.php?a_num=<?=$a_num?>&amp;<?=$page_info?>" enctype="multipart/form-data">
	<div>
	<input type="hidden" name="proc_mode" value="write_ok" />
	<input type="hidden" name="b_num" value="<?=$b_num?>" /><!-- (수정일때사용) -->
	<input type="hidden" name="b_type" value="<?=$b_type?>" />
	<input type="hidden" name="w_mode" value="<?=$w_mode?>" />

	<?If ($a_type == "N") { //공개여부?>
	<input type="hidden" name="b_open" value="Y" />
	<?}?>

	<input type="hidden" name="b_ref" value="<?=$b_ref?>" />
	<input type="hidden" name="b_step" value="<?=$b_step?>" />
	<input type="hidden" name="b_level" value="<?=$b_level?>" />

	<input type="hidden" name="b_sbjclr" value="<?=$b_sbjclr?>" />


	</div>


	<div class="guide">
		<span><img src="/content/board/default_calendar/img/ic_vcheck.gif" width="7" height="10" alt="*" /> 표시가 된 곳은 필수 항목입니다.</span>
	</div>

	<!-- 쓰기 테이블 -->
	<div class="table_bwrite">

	

			<table cellspacing="0" >
			<caption><?=str_replace( " | ", "",$tit_name);?></caption>
				<colgroup>
				<col width="130" />
				<col width="" />
				</colgroup>
			<thead>
				<tr>
					<th scope="col"></th>
					<th scope="col" class="th_end">글쓰기</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<th scope="row"><label for="b_name"><img height="10" width="7" alt="*" src="/content/board/default_calendar/img/ic_vcheck.gif"/> 이름</label></th>
					<td><input type="text" size="20" id="b_name" name="b_name" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_name?>" maxlength="30"  /> <span class="text1">* 한글만 사용하실 수 있습니다. </span></td>
				</tr>
				<tr>
					<th scope="row"><label for="b_pwd"><img height="10" width="7" alt="*" src="/content/board/default_calendar/img/ic_vcheck.gif"/> 비밀번호</label></th>
					<td><input type="password" size="22" id="b_pwd" name="b_pwd" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_pwd?>" maxlength="30"  /> <span class="text1">* 10자 이내의 영문/숫자만 사용하실 수 있습니다. </span></td>
				</tr>

				<?If ($a_type == "Y") { //공개/비공개?>
				<tr>
					<th scope="row">공개여부</th>
					<td>
						<input type="radio" id="b_open_Y" name="b_open" value="Y" title="공개 선택" <?if ($b_open == "Y") { echo("checked='checked'"); } ?>  /><label for="b_open_Y">공개</label>
						<input type="radio" id="b_open_N" name="b_open" value="N" title="비공개 선택" <?if ($b_open == "N") { echo("checked='checked'"); } ?>  /><label for="b_open_N">비공개</label>
					</td>
				</tr>
				<?}?>


				<?If ($a_phone == "Y") { //전화번호?>
				<tr>
					<th scope="row"><label for="b_phone1">전화번호</label></th>
					<td><input type="text" size="4" title="연락처 첫번째 입력" id="b_phone1" name="b_phone1" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_phone1?>" maxlength="4"  /> - <input type="text" size="4" title="연락처 두번째 입력" id="b_phone2" name="b_phone2" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_phone2?>"  maxlength="4"  /> - <input type="text" size="4" title="연락처 세번째 입력" id="b_phone3" name="b_phone3" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_phone3?>"  maxlength="4"  /></td>
				</tr>
				<?}?>

				<?If ($a_email == "Y") {//이메일?>
				<tr>
					<th scope="row"><label for="b_email">이메일</label></th>
					<td><input type="text" size="50" id="b_email" name="b_email" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_email?>" maxlength="200"  /> <span class="text1">* <strong>@</strong>포함한 이메일주소를 입력하세요.</span></td>
				</tr>
				<?}?>

				<?If ($a_home == "Y") {//홈페이지?>
				<!--
				<tr>
					<th scope="row"><label for="b_homepage">홈페이지</label></th>
					<td><span class="eng">http://</span> <input type="text" size="45" id="b_homepage" name="b_homepage" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_homepage?>" maxlength=""  /></td>
				</tr>
				-->
				<?}?>
				



				<?
				//사용자필드
				for ($z=1; $z<=4; $z++) {


					eval("\$a_ftemp_str = \$a_ftemp".$z."_str;");

					eval("\$b_temp = \$b_temp".$z.";");

					eval("\$a_ftemp = \$a_ftemp".$z.";");


				

					If ($a_ftemp == "Y") {
				?>
				<tr>
					<th scope="row"><label for="b_temp<?=$z?>"><?=$a_ftemp_str?></label></th>
					<td><input type="text" size="50" id="b_temp<?=$z?>" name="b_temp<?=$z?>" class="board_input" onfocus="focus_on1(this);" onblur="focus_off1(this);" value="<?=$b_temp?>" maxlength="50"  /></td>
				</tr>

				<?
					}
				}
				?>

				
				<tr>
					<th scope="row"><img height="10" width="7" alt="*" src="/content/board/default_calendar/img/ic_vcheck.gif"/>일시</th>
					<td>
					
						<select id="b_sdate_y" name="b_sdate_y">
							<?For ($z=2009; $z <=(date("Y")+5); $z++) {?>
							<option value="<?=$z?>" <?If ($z == $b_sdate_y ) { echo "selected='selected'"; }?>><?=$z?></option>
							<?}?>
						</select><label for="b_sdate_y">년</label> 
						<select id="b_sdate_m" name="b_sdate_m">
							<?For ($z=1; $z <=12; $z++) {?>
							<option value="<?=$z?>" <?If ($z == $b_sdate_m ) { echo "selected='selected'"; }?>><?=$z?></option>
							<?}?>
						</select><label for="b_sdate_m">월</label> 
						<select id="b_sdate_d" name="b_sdate_d">
							<?For ($z=1; $z <=31; $z++) {?>
							<option value="<?=$z?>" <?If ($z == $b_sdate_d ) { echo "selected='selected'"; }?>><?=$z?></option>
							<?}?>
						</select><label for="b_sdate_d">일</label> 
 
						~
 
						<select id="b_edate_y" name="b_edate_y">
							<?For ($z=2009; $z <=(date("Y")+5); $z++) {?>
							<option value="<?=$z?>" <?If ($z == $b_edate_y ) { echo "selected='selected'"; }?>><?=$z?></option>
							<?}?>
						</select><label for="b_edate_y">년</label> 
						<select id="b_edate_m" name="b_edate_m">
							<?For ($z=1; $z <=12; $z++) {?>
							<option value="<?=$z?>" <?If ($z == $b_edate_m ) { echo "selected='selected'"; }?>><?=$z?></option>
							<?}?>
						</select><label for="b_edate_m">월</label> 
						<select id="b_edate_d" name="b_edate_d">
							<?For ($z=1; $z <=31; $z++) {?>
							<option value="<?=$z?>" <?If ($z == $b_edate_d ) { echo "selected='selected'"; }?>><?=$z?></option>
							<?}?>
						</select><label for="b_edate_m">일</label> 
					</td>
				</tr>




				<?If ($a_cate == "Y") { //분류?>
				<tr>
					<th scope="row"><label for="b_cate_tot">분류</label></th>
					<td>
						<select id="b_cate_tot" name="b_cate_tot">
							<option value="" selected="selected" >분류선택</option>
							<?
							$mysql_c = new Mysql_DB;
							$mysql_c->Connect();

							//분류 부분
							$R_Fields_code = "ct_idx, ct_code, ct_name, ct_ref, ct_depth, ct_chk, ct_wdate, ct_codeno, ct_file, a_num";
							$SQL = "Select ".$R_Fields_code." FROM board_code WHERE ct_chk = 'Y' AND a_num='".$a_num."'  ORDER BY ct_code ASC";
							$mysql_c->ParseExec($SQL);

							If ($mysql_c->RowCount() > 0) {
								while($mysql_c->FetchInto(&$rs_code)) {

									$ct_idx			= $rs_code["ct_idx"];
									$ct_name		= $rs_code["ct_name"];
							?>

								<option value="<?=$ct_idx?>,<?=$ct_name?>" <?=chkSelect($ct_idx,$b_cate)?>><?=$ct_name?></option>

							<?
								}
							}
							$mysql_c->Disconnect();
							?>
						</select>
					</td>
				</tr>
				<?}?>

				<tr>
					<th scope="row"><label for="b_subject"><img height="10" width="7" alt="*" src="/content/board/default_calendar/img/ic_vcheck.gif"/> 제목</label></th>
					<td><input type="text" size="90" id="b_subject" name="b_subject" class="board_input"  value="<?=$b_subject?>" maxlength="200" /> 
					
		
					</td>
				</tr>


				<tr>
					<td colspan="2" class="content">
						<?if($a_edit == "Y"){//에디터가 사용일때?>
							
							<?
							//$_SESSION["fck_filepath"] = "/userfiles/";			//첨부파일경로
							//$_SESSION["fck_filepath"] = "/data/popup/";			//첨부파일경로

							$sBasePath = "/fckeditor/" ;						//에디터경로

							$oFCKeditor = new FCKeditor('b_content') ;		//개체명을 인자값으로..
							$oFCKeditor->BasePath	= $sBasePath;
							$oFCKeditor->Value		= $b_content;			//내용
							$oFCKeditor->ToolbarSet	= "Basic3";				//툴바  기본 : Basic, 고급 : Default
							$oFCKeditor->Width		= '100%' ;
							$oFCKeditor->Height		= '250' ;
							$oFCKeditor->Create();

							?>

						<?}else{?>
						<textarea cols="50" rows="15" id="b_content" name="b_content" title="게시글 내용 입력" style="width:98%;" onfocus="focus_on1(this);" onblur="focus_off1(this);" ><?=$b_content?></textarea>
						<?}?>
					</td>
				</tr>


				<?

				If ($a_upload == "Y") { //첨부파일 사용일때

					for ($z=1;$z <= $a_upload_len;$z++) {
						eval("\$b_file_name = \$b_file".$z.";");
					
						
						if($z == 1){
							
							//$link_url = "<a href='javascript:add();'><img src='/content/board/default_calendar/img/file_add.gif' alt='파일추가하기' /></a>";

							//$is_tr_css = "";
						}else{
							//$link_url = "<a href='javascript:del(\"$z\");'><img src='/content/board/default_calendar/img/file_del.gif' alt='파일빼기' /></a>";
							//$is_tr_css = "id='filediv$z' style='display:none'";


						}
				?>

				<tr <?//=$is_tr_css?>>
					<th scope="row"><label for="b_file<?=$z?>">첨부파일 <?=$z?></label> <?=$link_url?></th>
					<td>
						<input type="file" size="70" id="b_file<?=$z?>" name="b_file<?=$z?>" class="board_input_file" onfocus="focus_on1(this);" onblur="focus_off1(this);" value=""  />
						

						<?If ($b_file_name != "") {?>
							
							<br /><?=$b_file_name?>&nbsp;<input type='checkbox' id='b_file_chk<?=$z?>' name='b_file_chk<?=$z?>' value='Y' title="삭제" value='<?=$b_file_name?>'  />삭제
						<?}?>

					</td>
				</tr>
				<?
					}
				}
				?>




				
			</tbody>
			</table>
	
	</div>
	<!-- //쓰기 테이블 -->

	<!-- 버튼 -->
	<div class="board_button2">
		<span><input type="image" src="/content/board/default_calendar/img/save_bt.gif" alt="저장"/></span>
		<span><a href="list.php?a_num=<?=$a_num?>&amp;<?=$page_info?>"><img src="/content/board/default_calendar/img/list_bt.gif" width="62" height="23" alt="목록" /></a></span>
	</div>
	<!-- //버튼 -->

	</form>

</div>
<!-- //쓰기 -->

<script type="text/javascript">
	colorselect('<?=$b_sbjclr?>')
</script>

<script>
colorPicker(2);colorselect_white('#FFFFFF');
</script>

<?include("bottom.php"); //하단파일?>

</body>
</html>
