<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/lib/website_cg.lib.php");
?>

<link rel='stylesheet' type='text/css' href='<?=$board_skin_path?>/board_style.css'>

<script language="JavaScript">
// 글자수 제한
var char_min = parseInt(<?=$write_min?>); // 최소
var char_max = parseInt(<?=$write_max?>); // 최대
</script>

<!-- 김선용 2005.4 - FF(불여우) 에서는 innerHTML 사용시 폼이 <table> 아래에 있으면 인식하지 못합니다. -->
<form name="fwrite" method="post" action="javascript:fwrite_check(document.fwrite);" enctype="multipart/form-data" autocomplete="off">
<input type=hidden name=w        value="<?=$w?>">
<input type=hidden name=bo_table value="<?=$bo_table?>">
<input type=hidden name=wr_id    value="<?=$wr_id?>">
<input type=hidden name=sca      value="<?=$sca?>">
<input type=hidden name=sfl      value="<?=$sfl?>">
<input type=hidden name=stx      value="<?=$stx?>">
<input type=hidden name=spt      value="<?=$spt?>">
<input type=hidden name=sst      value="<?=$sst?>">
<input type=hidden name=sod      value="<?=$sod?>">
<input type=hidden name=page     value="<?=$page?>">
<table width="<?=$width?>" align=center cellpadding=0 cellspacing=0><tr><td align=center>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td height="30"><img src="<?=$board_skin_path?>/img/btn_arry.gif" width="11" height="11" align="absmiddle">&nbsp;<span class=W_T>홈페이지 기본정보 등록</span></td>
	</tr>

	<tr>
		<td style="padding:0 40px;">
			<table bgcolor="#e0e0e0" width="100%" border="0" cellspacing="1" cellpadding="5">
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>회사 명</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_1 itemname="회사 명" required value="<?=$write[wr_1]?>"></td>
					<td bgcolor="#F7F7F7" width="20%"><span class=W_L>등록자 명</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_name itemname="등록자 명" required value="<?=$name?>"></td>
				</tr>
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>전화번호</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_2 itemname="전화번호" required value="<?=$write[wr_2]?>"></td>
					<td bgcolor="#F7F7F7" width="20%"><span class=W_L>E-mail</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_email email itemname="E-mail" required value="<?=$email?>"></td>
				</tr>
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>부서/직책</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_3 itemname="부서/직책" value="<?=$write[wr_3]?>"></td>
					<td bgcolor="#F7F7F7" width="20%"><span class=W_L>주소</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_4 itemname="주소" value="<?=$write[wr_4]?>"></td>
				</tr>
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>대표전화번호</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT class=W_input style="width:100%;" name=wr_5 itemname="대표전화번호" value="<?=$write[wr_5]?>"></td>
					<td bgcolor="#F7F7F7" width="20%"><span class=W_L>홈페이지주소(URL)</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="30%"><INPUT type="text" class=W_input style="width:100%;" name="wr_link1" itemname="홈페이지" required value="<?=$write["wr_link1"]?>"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td height="60" style="padding:0 40px;">
<span class=W_H>
※ <font color=#ff0000>*</font>표시는 필수로 입력하셔야 합니다.<br>
※ 개인사업자일 경우, 회사 명은 <font color=#ff0000>개인</font>으로 표기해 주세요.
</span>
		</td>
	</tr>
	<tr>
		<td height="30"><img src="<?=$board_skin_path?>/img/btn_arry.gif" width="11" height="11" align="absmiddle">&nbsp;<span class=W_T>홈페이지 내용입력</span></td>
	</tr>

	<tr>
		<td style="padding:0 40px;">
			<table bgcolor="#e0e0e0" width="100%" border="0" cellspacing="1" cellpadding="5">
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>홈페이지 명</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="80%"><INPUT class=W_input style="width:100%;" name=wr_subject itemname="홈페이지 명" required value="<?=$subject?>"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr><td height="5"></td></tr>
	<tr>
		<td style="padding:0 40px;">
			<table bgcolor="#e0e0e0" width="100%" border="0" cellspacing="1" cellpadding="5">
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>홈페이지 설명</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="80%"><INPUT class=W_input style="width:100%;" name=wr_6 itemname="홈페이지 설명" required value="<?=$write[wr_6]?>"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr><td height="5"></td></tr>
	<tr>
		<td style="padding:0 40px;">
			<table bgcolor="#e0e0e0" width="100%" border="0" cellspacing="1" cellpadding="5">
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="20"><span class=W_L>키워드</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="80%"><INPUT class=W_input style="width:100%;" name=wr_8 itemname="키워드" required value="<?=$write[wr_8]?>"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr><td height="5"></td></tr>
	<tr>
		<td style="padding:0 40px;">
			<table bgcolor="#e0e0e0" width="100%" border="0" cellspacing="1" cellpadding="5">
				<tr>
					<td bgcolor="#F7F7F7" width="20%" height="30"><span class=W_L>분류</span><span class=W_P>＊</span></td>
					<td bgcolor="#FFFFFF" width="60%" height="30"><INPUT class=W_input type=text style="width:100%;" name=wr_7 itemname="분류" required readonly value="<?=$write[wr_7]?>"></td>
					<td bgcolor="#FFFFFF" width="20%" height="30" align="center"><a href="javascript:;" onclick="win_website('fwrite', 'wr_7');"><img src="<?=$board_skin_path?>/img/btn_cg_search.gif" width="94" height="27" border="0"></a></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr><td height="5"></td></tr>
	<tr>
		<td style="padding:0 40px;">
			<TEXTAREA id=wr_content name=wr_content class=tx style='width:100%; word-break:break-all;' rows=10 itemname="문의내용" required 
			<? if ($write_min || $write_max) { ?>ONKEYUP="check_byte('wr_content', 'char_count');"<?}?>><?=$content?></TEXTAREA>
			<? if ($write_min || $write_max) { ?><script language="JavaScript"> check_byte('wr_content', 'char_count'); </script><?}?>
		</td>
	</tr>

<? if ($is_file) { ?>
	<tr>
		<td height="30" style="padding:0 40px;">
첨부파일 최대용량은 <?=$upload_max_filesize?> 입니다.
		</td>
	</tr>
	<tr>
		<td style="padding:0 40px;">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="20%" height="20" valign="top" style="padding-top:5px;">
						<span class=W_L>첨부파일</span> <span onclick="add_file();" style='cursor:pointer; font-family:굴림; font-size:10pt;'>+</span> <span onclick="del_file();" style='cursor:pointer; font-family:굴림; font-size:10pt;'>-</span>
					</td>
					<td width="80%">
<table id="variableFiles" cellpadding=0 cellspacing=0></table>
<?// print_r2($file); ?>
        <script language="JavaScript">
        var flen = 0;
        function add_file(delete_code)
        {
            var upload_count = <?=(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 = "<input type='file' class=W_input size=32 name='bf_file[]' title='파일 용량 <?=$upload_max_filesize?> 이하만 업로드 가능'>";
            if (delete_code)
                objCell.innerHTML += delete_code;
            else
            {
                <? if ($is_file_content) { ?>
                objCell.innerHTML += "<br><input type='text' class=W_input size=50 name='bf_content[]' title='업로드 이미지 파일에 해당 되는 내용을 입력하세요.'>";
                <? } ?>
                ;
            }

            flen++;
        }

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

        function del_file()
        {
            // file_length 이하로는 필드가 삭제되지 않아야 합니다.
            var file_length = <?=(int)$file_length?>;
            var objTbl = document.getElementById("variableFiles");
            if (objTbl.rows.length - 1 > file_length)
            {
                objTbl.deleteRow(objTbl.rows.length - 1);
                flen--;
            }
        }
        </script>
					</td>
				</tr>
			</table>
		</td>
	</tr>
<? } ?>

<? if ($is_norobot) { ?>
	<tr>
		<td style="padding:0 40px;" align="center">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="20%" height="30"><?=$norobot_str?></td>
					<td width="80%"><INPUT class=W_input type=input size=10 name=wr_key itemname="자동등록방지" required><span class=W_L>&nbsp;&nbsp;* 왼쪽의 글자중</span> <FONT COLOR="red">빨간글자만</FONT> <span class=W_L>순서대로 입력하세요.</span></td>
				</tr>
			</table>
		</td>
	</tr>
<? } ?>

	<tr>
		<td align="center" height="50" valign="bottom">
			<INPUT type=image id="btn_submit" src="<?=$board_skin_path?>/img/ok.gif" border=0 accesskey='s'>
		</td>
	</tr>
</table>

</td></tr></table>
</form>


<script language="javascript">
    // 웹사이트 등록창
    function win_website(frm_name, frm_addr1)
    {
        url = g4_path + "/" + g4_bbs + "/website.php?frm_name="+frm_name+"&frm_addr1="+frm_addr1;
        win_open(url, "win_website", "left=50,top=50,width=616,height=460,scrollbars=1");
    }

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 = "<?=$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 = "";
}

function fwrite_check(f)
{
    var s = "";
    if (s = word_filter_check(f.wr_subject.value)) {
        alert("제목에 금지단어('"+s+"')가 포함되어있습니다");
        return;
    }

    if (s = word_filter_check(f.wr_content.value)) {
        alert("내용에 금지단어('"+s+"')가 포함되어있습니다");
        return;
    }

    if (char_min > 0 || char_max > 0)
    {
        var cnt = parseInt(document.getElementById('char_count').innerHTML);
        if (char_min > 0 && char_min > cnt)
        {
            alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
            return;
        } else if (char_max > 0 && char_max < cnt)
        {
            alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
            return;
        }
    }

    if (typeof(f.wr_key) != "undefined") {
        if (hex_md5(f.wr_key.value) != md5_norobot_key) {
            alert("자동등록방지용 빨간글자가 순서대로 입력되지 않았습니다.");
            f.wr_key.focus();
            return;
        }
    }

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

    f.action = "./write_update.php";
    f.submit();
}
</script>
