<%@ page contentType="text/html; charset=UTF-8"
	import="java.net.URLEncoder" import="kr.co.kihyun.lang.MString"
	import="kr.co.kihyun.text.html.TagFilter"
	import="kr.co.kihyun.lang.StringConverter"
	import="kr.co.kihyun.moumi.Moumi" import="kr.co.kihyun.lang.Encoder"
	import="kr.co.kihyun.lang.MLong" import="javax.jdo.PersistenceManager"
	import="javax.jdo.Transaction"
	import="kr.co.kihyun.beans.entity.util.*"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%
PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();
try{
	/********** get Parameter *************/
	Long docID = MLong.parseLong(request.getParameter("docID"),null);
	String gubun = clearXSS(Encoder.toJava(request.getParameter("gubun")),"");

	/*********** doc value *****************/
	String docForm = "";
	if(docID != null){
		TotDoc totDoc = null;
		totDoc = docID == null ? null : pm.getObjectById(TotDoc.class, docID);
		String docName = totDoc.getName();
		
		docForm = totDoc.getForm();
		docForm = TagFilter.convertSingle(docForm);
		docForm = StringConverter.toOneLine(docForm);

		//한글2002 버전특성에 인한 " "이 잘못 쌓여지는 버그가 있어서 추가한 부분
		docForm = docForm.replaceAll("font-family: \"","font-family: ");
		docForm = docForm.replaceAll("\"; text-align: ","; text-align: ");
		docForm = docForm.replaceAll("<table width=700 border=0><tbody><tr><td width=\"100%\"></td></tr></tbody></table>","\"자료입력창\"");
	}

%>

<%@page import="kr.co.kihyun.beans.entity.TotDoc"%><html>
<head>
<title><%=Moumi.getTitle()%></title>
<link rel="stylesheet" href="/totsys/common/css/text.css"
	type="text/css">
<link rel="stylesheet" href="/totsys/common/css/kecttep.css"
	type="text/css">
<script src="/totsys/common/js/rollover.js"></script>
<script language=javascript>
			function docFormContentModify(){
				docFormCM.docFCM.value = EditCtrl.document.body.innerHTML;

				if(docFormCM.docFCM.value == ''){
					alert('변경할 문서가 없습니다.\\n 다시 확인하시고 변경하여 주십시요.');
					return;
				}else{
					docFormCM.submit();
					//window.close();
				}
			}

			<%if(docID != null){%>
			function initForm(){
				EditCtrl.document.body.innerHTML = '<%= docForm %>';
			}
			<%}%>
		</script>


<script language="javascript">
		function formContentModify(){
			location.href="./form_content_modify.jsp?docID=<%=docID%>";
		}
	</script>


</head>

<body style='' bgcolor="#FFFFFF" text="#000000" leftmargin="0"
	topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td valign="top">
		<table valign="top" width="100%" height="100%" border="0"
			cellpadding="0" cellspacing="0">

			<!-- 뉴타이틀 -->
			<jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" />
			<!-- 뉴타이틀 -->
			<tr>
				<!----  topbar  버튼 시작---->
				<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td><a href="./doc_list.jsp"><img
							src="/totsys/common/images/bt_doc_list.gif" border="0"></a></td>
						<td align="right">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><a href="./doc_view.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_doc_view.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a href="./doc_form_view.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_form_view2.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a href="./reports/report_list.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_report_list.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a
									href="./tot_reports/total_reports.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_total_reports.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a
									href="./tot_report/total_report.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_total_report.gif" border="0"></a></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
				<!----  topbar  버튼 끝---->
			</tr>

			<tr>
				<td height="1"></td>
			</tr>
			<tr>
				<td bgcolor="6891cb" height="2" colspan="4"></td>
			</tr>
			<tr>
				<td height="1"></td>
			</tr>

			<tr>
				<!----  subtopbar  버튼 시작---->
				<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td width="537">&nbsp;</td>
						<td align="right">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><a href="#" onclick="javacscript:formContentModify();"><img
									src="/totsys/common/images/bt_doctxt_modify2.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a href="./doc_form_modify.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_form_modify.gif" border="0"></a></td>
						</table>
						</td>
					</tr>
				</table>
				</td>
				<!----  topbar  버튼 끝---->
			</tr>


			<tr>
				<td height="10"></td>
			</tr>

			<tr>
				<td width="100%">
				<table valign="top" cellSpacing="0" cellPadding="0" border="0"
					width="100%">
					<tr>
						<td>
						<table width="100%" border="0" cellpadding=0 cellspacing=0
							class=llist1>
							<form name="gocomp0" action="/Mail-bin/send_mail.frame"
								method=post><input type="hidden" name=What value=0>
							<input type="hidden" name=BODY> <input type="hidden"
								name=CMD value=''> <input type="hidden" name=MSGID
								value=''> <input type="hidden" name=TO> <input
								type="hidden" name=CC> <input type="hidden" name=BCC>
							<input type="hidden" name=SUBJECT> <input type="hidden"
								name=XSUBJECT value=''> <input type="hidden" name=PID
								value='11295'></form>
							<FORM name=Mail_Form target=_parent method=post
								action="/Mail-bin/start_mail/simplehtml"><input
								type="hidden" name=SENDACTION value=""> <input
								type="hidden" name=RESV_Y value=""> <input type="hidden"
								name=RESV_M value=""> <input type="hidden" name=RESV_D
								value=""> <input type="hidden" name=RESV_H value="">
							<input type="hidden" name=ISLINEANS value=""> <input
								type="hidden" name=PID value="11295"> <input
								type="hidden" name=MSGID value=> <input type="hidden"
								name=LINKURL value=""> <input type="hidden"
								name=LINKCOMMENT value=""> <input type="hidden"
								name=KEYWORD value=""> <input type="hidden" name=KEYTYPE
								value=""> <input type="hidden" name=FOLDER value="">
							<input type="hidden" name=mpage value=""> <input
								type="hidden" name=UseCompose value=""> <SCRIPT
								LANGUAGE='javascript' src='/totsys/common/js/editor.js'></SCRIPT>
							<tr class=bgw1>
								<td colspan=3><iframe id='i_fontcolor'
									style='background-color: #ffffff; border: 1px double #BFBFBF; cursor: hand; position: absolute; visibility: hidden;'
									scrolling=no frameborder=0 width=120 height=120></iframe> <iframe
									id='i_backcolor'
									style='background-color: #ffffff; border: 1px double #BFBFBF; cursor: hand; position: absolute; visibility: hidden;'
									scrolling=no frameborder=0 width=120 height=120></iframe> <iframe
									id='i_image'
									style='font-size: 9pt; color: #000000; font-family: 굴림; background-color: #efefef; border: 1px double #BFBFBF; cursor: default; position: absolute; visibility: hidden;'
									scrolling=no frameborder=0 width=325 height=85></iframe> <iframe
									id='i_link'
									style='font-size: 9pt; color: #000000; font-family: 굴림; background-color: #efefef; border: 1px double #BFBFBF; cursor: default; position: absolute; visibility: hidden;'
									scrolling=no frameborder=0 width=325 height=70></iframe> <iframe
									id='i_emoticon'
									style='background-color: #efefef; border: 1px double #BFBFBF; cursor: hand; position: absolute; visibility: hidden;'
									scrolling=no frameborder=0 width=125 height=125></iframe>

								<table width="100%" cellpadding=0 cellspacing=0 border=0>
									<tr>
										<td><font face='굴림체'>
										<div id='editctrl' style='display: show;'><iframe
											name='EditCtrl' width='100%' height='400' scrolling='YES'
											onfocus='layeroff();' onblur='nowkong.SaveSelection();'
											frameborder="0"></iframe></div>
										<input type="hidden" name=FORSAVE
											value="&lt;HEAD&gt;
																	&lt;STYLE&gt;
																	P {margin-top:2px;margin-bottom:2px;}
																	&lt;/STYLE&gt;
																	&lt;/HEAD&gt;
																	&lt;BODY oncontextmenu='return false;' style='background-color: ; background-image: url(); font-size:10pt; font-family:굴림;' topmargin=11 leftmargin=11&gt;
																	&lt;/BODY&gt;">
										</font> <input type="hidden" name=BODY value=""> <input
											type="hidden" name=BODYBG value=""> <input
											type="hidden" name=BODYBGC value=""></td>
									</tr>
								</table>
								</td>
							</tr>
							</FORM>
						</table>
						<br>
						<SCRIPT FOR=window EVENT=onbeforeunload LANGUAGE="JScript">
												document.Mail_Form.FORSAVE.value=EditCtrl.document.documentElement.innerHTML;
											</SCRIPT> <SCRIPT FOR=window EVENT=onload LANGUAGE="javascript">
											<%if(docID != null){%>
												initRepDocID();
											<%}else{%>
												init();
											<%}%>
											</SCRIPT>
						<table align="center" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<!--
													<td><a href="#" onclick="javascript:docFormContentModify();" ><img src="/totsys/common/images/bt_enter.gif" name="bt_enter1" border="0" id="bt_enter1"></a></td>
													<td >&nbsp;</td>
													<td><a href="./doc_form_view.jsp?docID=<%//= docID %>"><img src="/totsys/common/images/bt_cancel3.gif" name="bt_cancel3" border="0"></a></td>
													-->
								<td><a href="./doc_form_view.jsp?docID=<%= docID %>"><img
									src="/totsys/common/inc/documents/tot_doc/images/bt_pre.gif"
									name="bt_pre" border="0"></a></td>
								<td>&nbsp;</td>
								<td><a href="#"
									onclick="javascript:docFormContentModify();"><img
									src="/totsys/common/inc/documents/tot_doc/images/bt_preview.gif"
									name="bt_next" border="0"></a></td>
							</tr>
						</table>
						</form>
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<!-----  내용 들어갈 부분  끝 ---->
			<tr>
				<td height="10"></td>
			</tr>
			<tr>
				<!----  subtopbar  버튼 시작---->
				<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td width="537">&nbsp;</td>
						<td align="right">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><a href="#" onclick="javacscript:formContentModify();"><img
									src="/totsys/common/images/bt_doctxt_modify2.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a href="./doc_form_modify.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_form_modify.gif" border="0"></a></td>
						</table>
						</td>
					</tr>
				</table>
				</td>
				<!----  topbar  버튼 끝---->
			</tr>

			<tr>
				<td height="1"></td>
			</tr>
			<tr>
				<td bgcolor="6891cb" height="2" colspan="4"></td>
			</tr>
			<tr>
				<td height="1"></td>
			</tr>

			<tr>
				<!----  topbar  버튼 시작---->
				<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td width="537"><a href="./doc_list.jsp"><img
							src="/totsys/common/images/bt_doc_list.gif" border="0"></a></td>
						<td align="right">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><a href="./doc_view.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_doc_view.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a href="./doc_form_view.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_form_view2.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a href="./reports/report_list.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_report_list.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a
									href="./tot_reports/total_reports.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_total_reports.gif" border="0"></a></td>
								<td width="3"></td>
								<td><a
									href="./tot_report/total_report.jsp?docID=<%= docID %>"><img
									src="/totsys/common/images/bt_total_report.gif" border="0"></a></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
				<!----  topbar  버튼 끝---->
			</tr>


		</table>
		</td>

		<td width="10"></td>
	</tr>







</table>
<form name="docFormCM"
	action="/servlet/kr.co.kihyun.beans.totsys.doc.HttpReFormReader"
	method="post" encType="multipart/form-data"><input type="hidden"
	name="docFCM"> <input type="hidden" name="docID"
	value="<%= docID %>"></form>
</body>
</html>
<%
}catch(Exception ex){
        //38.오류메세지를 통한 정보 노출(getMessage)_CWE-209 : Update by YOUNGJUN,CHO
	//out.println(ex);
	ex.printStackTrace();
	//out.println("<html><body style='overflow=auto' bgcolor='white'><h1>Can't contact servlet runner</h1><br><br>Message : "+ex.getMessage()+"</body></html>");
	//out.println("<META HTTP-EQUIV='refresh' CONTENT='0.1; URL=/error/exception.jsp'>");
        //================================================
}finally{
    if(tx.isActive())
    tx.rollback();
    pm.close();
}
%>
