{?set $jieqi_pagetitle = "增加章节-{$jieqi_sitename}"?}
{?set $jieqi_contenttitle = "增加章节"?}
<script type="text/javascript">
function frmnewchapter_validate(){
  if(document.frmnewchapter.chaptername.value == ""){
    alert("请输入章节标题");
    document.frmnewchapter.chaptername.focus();
    return false;
  }
}
//统计输入字数
function show_inputwords(txt){
	txt = $_(txt);
	var words = (arguments.length > 1) ? $_(arguments[1]) : $_(txt.id + '_words');
	words.innerHTML = txt.value.replace(/[\x00-\x08\x0e-\x1f\x21-\xff]+/gi, 'w').replace(/\s/g, '').length;
}
//显示默认字数
addEvent(window, 'load', function(){show_inputwords('chaptercontent');});
//临时保存章节内容
function chapter_autosave(){
	if($_('chaptercontent').value != '') Ajax.Request('{?$jieqi_url?}/autosave.php',{method :'POST',parameters:'savedata='+encodeURIComponent($_('chaptercontent').value)});
}
AutoSaveTimer = setInterval(chapter_autosave, 60000);
</script>
<script type="text/javascript" src="{?$jieqi_url?}/scripts/attaches.js"></script>
<form class="form" name="frmnewchapter" id="frmnewchapter" action="{?$url_newchapter?}" method="post" onsubmit="return frmnewchapter_validate();" enctype="multipart/form-data">
<fieldset>
	<div class="frow">
		<label class="col4 flabel">小说名称：</label>
		<div class="col8 last">
			<a href="{?$article_static_url?}/articlemanage.php?id={?$articleid?}">{?$articlename?}</a>
		</div>
	</div>
	<div class="frow">
		<label class="col4 flabel">分卷名称：</label>
		<div class="col8 last">
			<select class="select"  size="1" name="chapterorder" id="chapterorder">
  {?section name=i loop=$volumerows?}
  <option value="{?$volumerows[i].chapterorder?}"{?if $volumerows[i].chapterorder == $chapterorder?} selected="selected"{?/if?}>{?$volumerows[i].volumename?}</option>
  {?/section?}
  </select>
		</div>
	</div>
	<div class="frow">
		<label class="col4 flabel">章节标题：</label>
		<div class="col8 last">
			<input type="text" class="text" name="chaptername" id="chaptername" maxlength="50" value="{?$chaptername?}" />
		</div>
	</div>
	<div class="frow">
		<div class="row">
		<label class="col4 flabel">章节内容：</label>
		<div class="col8 last">
			已输入 <span class="hot" id="chaptercontent_words">0</span> 字
		</div>
		</div>
		<div class="row">
		<textarea class="textarea" name="chaptercontent" id="chaptercontent" rows="15" onkeyup="show_inputwords(this);" oninput="show_inputwords(this);" onpropertychange="show_inputwords(this);">{?if $chaptercontent == ''?}{?$jieqi_autosave?}{?else?}{?$chaptercontent?}{?/if?}</textarea>
		</div>
	</div>
	{?if $attachnum > 0?}
	<div class="frow">
		<label class="col4 flabel">现有附件：</label>
		<div class="col8 last">
			{?section name=i loop=$attachrows?}
    		<label class="checkbox"><input type="checkbox" name="oldattach[]" value="{?$attachrows[i].attachid?}" checked="checked" />{?$attachrows[i].name?}</label>
    		{?/section?}
    		<p class="hot">（取消打勾表示删除该附件）</p>
		</div>
	</div>
	{?/if?}
	{?if $canupload == true && $maxattachnum > 0?}
	<div class="frow">
		<label class="col4 flabel">附件限制：</label>
		<div class="col8 last">
			<span class="hot">文件类型：{?$attachtype?}, 图片最大：{?$maximagesize?}K, 文件最大：{?$maxfilesize?}K</span>
		</div>
	</div>
	<div class="frow">
		<label class="col4 flabel">附件上传：</label>
		<div class="col8 last">
			<input type="file" class="file" name="attachfile[]" id="attachfile" onchange="Attaches.addFile('attachfile', 'attachdiv', true);" /><button type="button" class="filebutton" onclick="if(document.all){document.getElementById('attachfile').outerHTML += '';}else{document.getElementById('attachfile').value = '';}">清空</button>
  			<div id="attachdiv"></div>
		</div>
	</div>
	{?/if?}
	{?if $issign >= 10?}
	<div class="frow">
		<label class="col4 flabel">是否免费：</label>
		<div class="col8 last">
			<label class="radio"><input type="radio" name="isvip" value="0"{?if $cvip == 0?} checked="checked"{?/if?} />免费章节</label>&nbsp;
  			<label class="radio"><input type="radio" name="isvip" value="1"{?if $cvip > 0?} checked="checked"{?/if?} />VIP章节</label>&nbsp;{?if $customprice > 0?}<input type="text" class="text" name="saleprice" id="saleprice" size="4" maxlength="10" value="{?$saleprice?}" />{?$egoldname?} <span class="hot">(留空则自动按字数计价)</span>{?/if?}
		</div>
	</div>
	{?/if?}
	<div class="frow">
		<label class="col4 flabel">是否完本：</label>
		<div class="col8 last">
			<label class="radio"><input type="radio" name="fullflag" value="0" checked="checked" />未完待续</label>&nbsp;
  			<label class="radio"><input type="radio" name="fullflag" value="1" />完结篇</label>
		</div>
	</div>
	{?if $authtypeset == 1?}
	<div class="frow">
		<label class="col4 flabel">小说排版：</label>
		<div class="col8 last">
			<label class="radio"><input type="radio" name="typeset" value="1" checked="checked" />自动排版</label>&nbsp;
  			<label class="radio"><input type="radio" name="typeset" value="0" />无需排版</label>
		</div>
	</div>
	{?/if?}
	<div class="frow">
		<label class="col4 flabel">发表方式：</label>
		<div class="col8 last">
			<label class="radio"><input type="radio" name="posttype" value="0" checked="checked" />直接发表</label>&nbsp;
  			<label class="radio"><input type="radio" name="posttype" value="1" />存为草稿</label>&nbsp;
  			{?if $uptiming > 0?}
  			<label class="radio"><input type="radio" name="posttype" value="2" />定时发表</label>
  			<p><input type="text" class="text" style="width:4em;" name="pubyear" id="pubyear" maxlength="4" value="{?$jieqi_time|date:'Y'?}" />年<input type="text" class="text" style="width:2.4em;" name="pubmonth" id="pubmonth" maxlength="2" value="{?$jieqi_time|date:'m'?}" />月<input type="text" class="text" style="width:2.4em;" name="pubday" id="pubday" maxlength="2" value="{?$jieqi_time|date:'d'?}" />日</p>
  			<p class="mts"><input type="text" class="text" style="width:2.4em;" name="pubhour" id="pubhour" maxlength="2" value="" />时<input type="text" class="text" style="width:2.4em;" name="pubminute" id="pubminute" maxlength="2" value="" />分</p>
  			{?/if?}
		</div>
	</div>
	<div class="frow">
		<label class="col4 flabel">&nbsp;</label>
		<div class="col8 last">
			<button type="submit" class="button" name="submit"> 提 交 </button>
  			{?if $needupaudit > 0?}<br /><span class="hot">注意：直接发表的章节也会先保存在草稿箱待审章节列表中，管理员审核后才能正常显示。</span>{?/if?}
  			<input type="hidden" name="act" value="newchapter" />{?$jieqi_token_input?}
  			<input type="hidden" name="aid" value="{?$articleid?}" />
  			{?if $draftid > 0?}<input type="hidden" name="draftid" value="{?$draftid?}" />{?/if?}
		</div>
	</div>
</fieldset>
</form>