<%template _header%>
<script language="javascript" type="text/javascript" src="templates/{templatepath}/calendar.js"></script>
<script type="text/javascript">
var postminchars = parseInt({config.minpostsize});
var postmaxchars = parseInt({config.maxpostsize});
var disablepostctrl = parseInt({disablepostctrl});
var tempaccounts = false;
</script>
<!--TheCurrent start-->
<%if page_err==0%>
<%if {ispost}%>
<%template _msgbox%>
<%else%>
<div id="foruminfo">
	<div class="userinfo">
	<h2><a href="{config.forumurl}" class="home">{config.forumtitle}</a><span>{forumnav}<a href="showtree.aspx?topicid={topic.tid}&postid={postinfo.pid}">{postinfo.title}</a></span></h2>
  	</div>
</div>
<!--TheCurrent end-->
<div id="previewtable" style="display: none">
	<div class="ntforumbox">
		<div class="titlebar">
			<h3>预览帖子</h3>
		</div>
		<table width="100%" align="left">
				<tr>
				<td width="194"><span>{username}</span></td>
				<td>
					<span class="fontfamily">{nowdatetime}</span>
					<div id="previewmessage"></span>
				</td>
				</tr>
		</table>
	</div>
</div>

<div class="ntforumbox">
	<div class="titlebar">
		<h3>修改帖子</h3>
	</div>
	<form method="post" name="postform" id="postform" action="" enctype="multipart/form-data" onsubmit="return validate(this);">
	<table cellpadding="0" cellspacing="0" border="0">
		<tbody>
			<tr class="list">
				<th class="formlabel">用户名</th>
				<td class="formbody">
				<h1><%if {userid}>0%>
					{username} [<a href="logout.aspx?userkey={userkey}">退出登录</a>]
				<%else%>
					匿名 [<a href="login.aspx">登录</a>] [<a href="register.aspx">注册</a>]
				<%/if%>
				</h1>
				</td>
			</tr>
		</tbody>
		<tbody>
			<tr class="list">
			<th class="formlabel">标题</th>
			<td class="formbody">
			<%if {postinfo.layer}==0 && {forum.applytopictype}==1%>
				<%if {topictypeselectoptions}!=""%>
				<select name="typeid" ID="typeid">{topictypeselectoptions}</select>
				<script>document.getElementById('typeid').value='{topic.typeid}';</script>
				<%/if%>
			<%/if%>
			<input name="title" type="text" class="colorblue" id="title" value="{postinfo.title}" size="60" title="标题最多为60个字符" />
			</td>
			</tr>
		</tbody>
	<%if {postinfo.Layer}==0%>
		<tbody>
			<tr class="list">
				<th class="formlabel">交易</th>
				<td class="formbody">
				<input name="topicprice" type="text" id="topicprice" class="colorblue" value="{topic.price}" size="5" />
					<%if {userextcreditsinfo.unit}!=""%>
						{userextcreditsinfo.unit}
					<%/if%>
					{userextcreditsinfo.name}
					&nbsp;&nbsp;[ 主题最高售价 {maxprice} 
					<%if {userextcreditsinfo.unit}!=""%>
						{userextcreditsinfo.unit}
					<%/if%>
					{userextcreditsinfo.name}
					 ]
				</td>
			</tr>
		</tbody>
		<tbody>
			<tr class="list">
				<th class="formlabel">阅读权限</th>
				<td class="formbody">
					<input name="topicreadperm" type="text" id="topicreadperm" class="colorblue" value="{topic.readperm}" size="5" />
				</td>
			</tr>
		</tbody>
	<%/if%>
	<tbody>
			<tr class="list">
				<th class="formlabel">图标</th>
				<td class="formbody">
			<input name="iconid" type="radio" value="0"
<%if {topic.iconid}==0%>
		  checked="checked"
<%/if%>
		   />
            无
            <input type="radio" name="iconid" value="1"
			
<%if {topic.iconid}==1%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/1.gif"/>
            <input type="radio" name="iconid" value="2"
<%if {topic.iconid}==2%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/2.gif"/>
            <input type="radio" name="iconid" value="3"
<%if {topic.iconid}==3%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/3.gif"/>
            <input type="radio" name="iconid" value="4"
<%if {topic.iconid}==4%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/4.gif"/>
            <input type="radio" name="iconid" value="5"
<%if {topic.iconid}==5%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/5.gif"/>
            <input type="radio" name="iconid" value="6"
<%if {topic.iconid}==6%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/6.gif"/>
            <input type="radio" name="iconid" value="7"
<%if {topic.iconid}==7%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/7.gif"/> <br />
            <input type="radio" name="iconid" value="8"
<%if {topic.iconid}==8%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/8.gif"/>
            <input type="radio" name="iconid" value="9"
<%if {topic.iconid}==9%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/9.gif"/>
            <input type="radio" name="iconid" value="10"
<%if {topic.iconid}==10%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/10.gif"/>
            <input type="radio" name="iconid" value="11"
<%if {topic.iconid}==11%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/11.gif"/>
            <input type="radio" name="iconid" value="12"
<%if {topic.iconid}==12%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/12.gif"/>
            <input type="radio" name="iconid" value="13"
<%if {topic.iconid}==13%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/13.gif"/>
            <input type="radio" name="iconid" value="14"
<%if {topic.iconid}==14%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/14.gif"/>
            <input type="radio" name="iconid" value="15"
<%if {topic.iconid}==15%>
		  checked="checked"
<%/if%>
			 />
            <img src="images/posticons/15.gif"/>
			</td>
			</tr>
	</tbody>
	<tbody>
		<tr>
			<%template _editor%>
		</tr>
	</tbody>
	<%if {allowviewattach} && {canpostattach}%> 
	<tbody>
		<tr class="list">
				<th class="formlabel">&nbsp;</th>
				<td class="formbody"><input type="button" value="查看已上传附件>>" onclick="expandoptions('attachfilelist');" class="lightbutton"/></td>
			</tr>
	</tbody>
	<!--附件列表开始-->
	<tbody>
	<tr class="list">
	<td colspan="2"  style="border-top:none;">
	<div id="attachfilelist" style="display:none">
        <%if {postinfo.attachment}>0%>
				<script type="text/javascript">
				var attachments = new Array();
				var attachimgurl = new Array();
				function restore(aid) {
				obj = $('attach' + aid);
				objupdate = $('attachupdate' + aid);
				obj.style.display = '';
				objupdate.innerHTML = '<input type="file" name="attachupdated" style="display: none;">';
				
				}
				function attachupdate(aid) {
				obj = $('attach' + aid);
				objupdate = $('attachupdate' + aid);
				obj.style.display = 'none';
				objupdate.innerHTML = '<input type="file" name="attachupdated" class="colorblue" onfocus="this.className=\'colorfocus\';" onblur="this.className=\'colorblue\';"  size="15" /><input type="hidden" value="' + aid + '" name="attachupdatedid" /> <input  onfocus="this.className=\'colorfocus\';" onblur="this.className=\'colorblue\';" class="colorblue" type="button" value="取 &nbsp; 消" onclick="restore(\'' + aid + '\')" />';
				}
				function insertAttachTag(aid) {
				if (bbinsert && wysiwyg) {
				insertText('[attach]' + aid + '[/attach]', false);
				} else {
				AddText('[attach]' + aid + '[/attach]');
				}
				}
				function insertAttachimgTag(aid) {
				if (bbinsert && wysiwyg) {
				var attachimgurl = eval('attachimgurl_' + aid);
				insertText('<img src="' + attachimgurl[0] + '" border="0" aid="attachimg_' + aid + '" alt="" />', false);
				} else {
				AddText('[attachimg]' + aid + '[/attachimg]');
				}
				}
				</script>
	    <table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
              <tr style="line-height:25px;">
                <td width="5%" align="center">删除</td>
                <td width="5%" >附件ID</td>
                <td width="25%">文件名</td>
                <td width="15%">时间</td>
                <td width="10%">附件大小</td>
                <td width="10%">下载次数</td>
                <td width="5%">阅读权限</td>
                <td width="20%">描述</td>
              </tr>
              <%loop attachment attachmentlist%>
              <%if {strtoint({attachment[pid]})}=={postinfo.pid}%>
              <tr onmouseover="this.style.backgroundColor='#fff'" onmouseout="this.style.backgroundColor='#F5FBFF'">
                <td align="center"><input class="checkbox" name="deleteaid" value="{attachment[aid]}" type="checkbox"><!--<a href="javascript:deleteatt({attachment[aid]});">删除</a>--></td>
                <td >{attachment[aid]}<input type="hidden" value="{attachment[aid]}" name="attachupdateid" /></td>
                <td>
					<div id="attach{attachment[aid]}">
						<a href="###" class="right" onclick="attachupdate('{attachment[aid]}')">[更新]</a>
						<a href="###" class="right" onclick="<%if {attachment[filetype]}.IndexOf("image")>-1%>insertAttachimgTag('{attachment[aid]}');<%else%>insertAttachTag('{attachment[aid]}');<%/if%>" title="点击这里将本附件插入帖子内容中当前光标的位置">[插入]</a>
						<script type="text/javascript">attachimgurl_{attachment[aid]} = ['attachment.aspx?attachmentid={attachment[aid]}', 400];</script>
						<span id="imgpreview_{attachment[_id]}" <%if {attachment[filetype]}.IndexOf("image")>-1%>onmouseover="if($('imgpreview_{attachment[_id]}_image').width > 400)$('imgpreview_{attachment[_id]}_image').width = 400;showMenu(this.id, 0, 0, 1, 0);"<%/if%>><a href="attachment.aspx?attachmentid={attachment[aid]}">{attachment[attachment]}</a></span><%if {attachment[filetype]}.IndexOf("image")>-1%><div class="popupmenu_popup" id="imgpreview_{attachment[_id]}_menu" style="display: none;margin-left:20px;"><img id="imgpreview_{attachment[_id]}_image" src="upload/{attachment[filename]}" /></div><%/if%>
					</div>
					<span id="attachupdate{attachment[aid]}"><input type="file" name="attachupdated" style="display: none;"></span>
				</td>
                <td>{attachment[postdatetime]}</td>
                <td>{attachment[filesize]} 字节</td>
                <td>{attachment[downloads]}</td>
                <td><input type="text" name="attachupdatereadperm" size="1" class="colorblue" onfocus="this.className='colorfocus';" onblur="this.className='colorblue';" value={attachment[readperm]} /></td>
                <td><input type="text" name="attachupdatedesc" size="25" class="colorblue" onfocus="this.className='colorfocus';" onblur="this.className='colorblue';" value={attachment[description]} /></td>
              </tr>
              <%/if%>
              <%/loop%>
			</table>
        <%/if%>
        </div>
		<%/if%>
		</td>
		</tr>
		</tbody>
		<!--附件列表结束-->
		<!--投票开始-->
		<%if {ispoll}%>
		<tbody>
			<tr class="list">
				<th class="formlabel">
					<input name="createpoll" type="checkbox" id="createpoll" onclick="expandoptions('divPoll');" value="1" />发布投票
				</th>
				<td class="formbody">
					<div id="divPoll">
					  <input name="button" type="button" class="lightbutton" onclick="clonePoll('{config.maxpolloptions}')" value="增加投票项" />
					  <input name="button" type="button" class="lightbutton" onclick="if(!delObj(document.getElementById('polloptions'),2)){alert('投票项不能少于2个');}" value="删除投票项" />
				  <input id="PollItemname" type="hidden" name="PollItemname" value="" />
				  <input id="PollItemvalue" type="hidden" name="PollItemvalue" value="" />
					  <div>
					  <span style="margin-top:3px;">
					  <%if {polltype}==0%>
					  <input type="radio" name="polltype" value="0" checked="checked" />
					  <%else%>
					  <input type="radio" name="polltype" value="0" />
					  <%/if%>
					  单选
					  &nbsp;
					  <%if {polltype}==1%>
					  <input type="radio" name="polltype" value="1" checked="checked" />
					  <%else%>
					  <input type="radio" name="polltype" value="1" />
					  <%/if%>
					  多选</span>
					  <span  style="margin-top:5px;margin-left:10px;">投票结束日期:
					  <input name="enddatetime" type="text" id="enddatetime" size="10" value="{pollenddatetime}" style="cursor:default" class="colorblue" onClick="showcalendar(event, 'enddatetime', 'cal_startdate', 'cal_enddate', '{nowdate}');" readonly="readonly" /></span>
					  <input type="hidden" name="cal_startdate" id="cal_startdate" size="10"  value="{nowdate}">
					  <input type="hidden" name="cal_enddate" id="cal_enddate" size="10"  value="">
					  </div>
					  <div id="polloptions" style="margin-top:3px;">
						<%loop poll polllist%>
						<div id="PollItem" name="PollItem" style="padding-top:4px">
						  <input type="text" size="70" name="pollitemid" class="colorblue" onfocus="this.className='colorfocus';" onblur="this.className='colorblue';" value="{poll[name]}" />
						</div>
						<%/loop%>
					  </div>
					</div>
				</td>
		</tr>
		</tbody>
		<script type="text/javascript">
					var pi = document.getElementsByName("PollItem");
					pi[0].id = "divPollItem";
					function setPollDisplay() {
					
						var mydiv=document.getElementById('divPoll');
						var check=document.getElementById('createpoll');
						if (mydiv){	
							if(check.checked==false) {
								mydiv.style.display='none';
							} else {
								mydiv.style.display='';
							}
						}
					}
					document.onreadystatechange = setPollDisplay;
					</script>
		<%/if%>
		<!--投票结束-->	      
	 <%if {isseccode}%>
		<tbody>
				<tr class="list">
					<th class="formlabel">验证码</th>
					<td class="formbody">
					<%template _vcode%>	
					</td>
				</tr>
		</tbody>
     <%/if%>
		<tbody>
			<tr class="list">
				<th class="formlabel">&nbsp;</th>
				<td class="formbody">
		<%if {postinfo.layer}==0 && {forum.applytopictype}==1%>
			  <input type="hidden" id="postbytopictype" name="postbytopictype" value="{forum.postbytopictype}" tabindex="3" >
		<%/if%>
		<input class="sbutton" name="editsubmit" type="submit" id="postsubmit" value="编辑帖子" />	[完成后可按 Ctrl + Enter 发布]
				</td>
			</tr>
		</tbody>
		</table>
    <input type="hidden" name="aid" id="aid" value="0">
    <input type="hidden" name="isdeleteatt" id="isdeleteatt" value="0">
    <script type="text/javascript">
						$('postform').onsubmit = function() { return validate($('postform'));};
						function deleteatt(aid){
							document.getElementById('isdeleteatt').value = 1;
							document.getElementById('aid').value = aid;
							document.getElementById('isdeleteatt').form.submit();
						}
	</script>

  <p class="textmsg" id="divshowuploadmsg" style="display:none"></p>
  <p class="textmsg succ" id="divshowuploadmsgok" style="display:none"></p>
  <input type="hidden" name="uploadallowmax" value="10">
  <input type="hidden" name="uploadallowtype" value="jpg,gif">
  <input type="hidden" name="thumbwidth" value="300">
  <input type="hidden" name="thumbheight" value="250">
  <input type="hidden" name="noinsert" value="0">
</form>
</div>
</div>
<%template _copyright%>
<%/if%>
<%else%>
<%template _errmsgbox%>
</div>
<%/if%>
<%template _footer%>