{subtemplate header}

<div id="nav"><a href="$indexname">$bbname</a> $navigation &raquo; <!--{if $special == 1}-->{lang post_newthread_poll}<!--{elseif $special == 3}-->{lang post_newthread_reward}<!--{elseif $special == 5}-->{lang post_newthread_debate}<!--{else}-->{lang post_newthread}<!--{/if}--></div>

<!--{if $special == 4 || $special == 5}-->
	<script type="text/javascript" src="include/javascript/calendar.js"></script>
<!--{elseif $special == 6}-->
	<script type="text/javascript" src="include/javascript/video.js"></script>

<!--{/if}-->
<script type="text/javascript">
var postminchars = parseInt('$minpostsize');
var postmaxchars = parseInt('$maxpostsize');
var disablepostctrl = parseInt('$disablepostctrl');
var typerequired = parseInt('$forum[threadtypes][required]');
var tagrequired = parseInt('$forum[allowtag]');
var bbinsert = parseInt('$bbinsert');
var seccodecheck = parseInt('$seccodecheck');
var secqaacheck = parseInt('$secqaacheck');
var special = parseInt('$special');
var isfirstpost = 1;
var allowposttrade = parseInt('$allowposttrade');
var allowpostreward = parseInt('$allowpostreward');
var allowpostactivity = parseInt('$allowpostactivity');
lang['board_allowed'] = '{lang board_allowed}';
lang['lento'] = '{lang lento}';
lang['bytes'] = '{lang bytes}';
lang['post_curlength'] = '{lang post_curlength}';
lang['post_subject_and_message_isnull'] = '{lang post_subject_and_message_isnull}';
lang['post_subject_toolong'] = '{lang post_subject_toolong}';
lang['post_message_length_invalid'] = '{lang post_message_length_invalid}';
lang['post_type_isnull'] = '{lang post_type_isnull}';
lang['post_tag_isnull'] = '{lang post_tag_isnull}';
lang['post_reward_credits_null'] = '{lang post_reward_credits_null}';
</script>

{subtemplate post_preview}
<form method="post" id="postform" action="post.php?action=newthread&fid=$fid&extra=$extra&topicsubmit=yes" $enctype>
	<input type="hidden" name="formhash" id="formhash" value="{FORMHASH}" />
	<input type="hidden" name="frombbs" value="1" />
	<!--{if $special}-->
		<input type="hidden" name="special" value="$special" />
	<!--{/if}-->

	<div class="mainbox formbox">
		<span class="headactions"><a class="notabs" href="member.php?action=credits&view=forum_post&fid=$fid" target="_blank">{lang credits_policy_view}</a></span>
		<h1><!--{if $special == 1}-->{lang post_newthread_poll}<!--{elseif $special == 3}-->{lang post_newthread_reward}<!--{elseif $special == 5}-->{lang post_newthread_debate}<!--{else}-->{lang post_newthread}<!--{/if}--></h1>
		<table summary="post" cellspacing="0" cellpadding="0" id="newpost">
			<thead>
				<tr>
					<th>{lang username}</th>
					<td>
						<!--{if $discuz_uid}-->
							$discuz_userss [<a href="$link_logout">{lang member_logout}</a>]
						<!--{else}-->
							{lang guest} [<a href="$link_login">{lang member_login}</a>]
						<!--{/if}-->
					</td>
				</tr>
			</thead>

		{subtemplate seccheck}

		<!--{if $special == 3 && $allowpostreward}-->
			<tr>
				<th>{lang reward_price}<!--{if !empty($extcredits[$creditstrans][title])}-->({$extcredits[$creditstrans][title]})<!--{/if}--></th>
				<td><input onkeyup="getrealprice(this.value)" type="text" name="rewardprice" size="6" value="$minrewardprice" tabindex="2" /> <em class="tips">
			{lang reward_tax_after}: <span id="realprice">0</span>  {$extcredits[$creditstrans][unit]} ({lang reward_low} $minrewardprice {$extcredits[$creditstrans][unit]}<!--{if $maxrewardprice > 0}--> - $maxrewardprice {$extcredits[$creditstrans][unit]}<!--{/if}--></em>)
			</td>
			</tr>
			<script type="text/javascript">
				$('realprice').innerHTML = parseInt($('postform').rewardprice.value) + parseInt(Math.ceil( $('postform').rewardprice.value * $creditstax ));
				function getrealprice(price){
					if(!price.search(/^\d+$/) ) {
						n = Math.ceil(parseInt(price) + price * $creditstax);
						if(price > 32767) {
							$('realprice').innerHTML = '<b>{lang reward_price_overflow}</b>';
						} else if(price < $minrewardprice || ($maxrewardprice > 0 && price > $maxrewardprice)) {
							$('realprice').innerHTML = '<b>{lang reward_price_bound}</b>';
						} else {
							$('realprice').innerHTML = n;
						}
					}else{
						$('realprice').innerHTML = '<b>{lang input_invalid}</b>';
					}
				}
			</script>
		<!--{/if}-->

		<tr>
			<th style="border-bottom: 0"><label for="subject">{lang subject}</label></th>
			<td style="border-bottom: 0">
				$typeselect
				<input type="text" name="subject" id="subject" size="45" value="$subject" tabindex="3" />

			</td>
		</tr>

		<tbody id="threadtypes"></tbody>

		<!--{if $special == 6 && $allowpostvideo}-->
			<thead>
				<tr>
					<th>{lang video_upload}</th>
					<td>&nbsp;</td>
				</tr>
			</thead>
			<tr>
				<th valign="top">{lang video_title}</th>
				<td style="border-bottom: 0">
					<script type="text/javascript">
						function v_onComplete(vid, vlength) {
							$('vid').value = vid;
							$('vlength').value = vlength;
						}
					</script>
					$vtypeselect &nbsp; <input type="text" name="vsubject" size="41">&nbsp;&nbsp;	<input type="checkbox" name="vautoplay" value="1">{lang video_auto}&nbsp;<input type="checkbox" name="vshare" value="1" checked>{lang video_share}
					<input type="hidden" name="vid" id="vid" value="">
					<input type="hidden" name="vlength" id="vlength" value="">
				</td>
			</tr>
			<tr>
				<th valign="top">{lang video_tag}</th>
				<td valign="top"> <input type="text" name="vtag" size="53">&nbsp;&nbsp;{lang video_tag_tips}</td>
			</tr>
			<tr>
				<th valign="top">{lang video_upload}</th>
				<td valign="top"><!--{if $videoupload}-->$videoupload<!--{else}-->{lang video_key_invalid}<!--{/if}--></td>
			</tr>
		<!--{/if}-->

		<!--{if $special == 1 && $allowpostpoll}-->
			<tr>
				<th><label for="expiration">{lang poll_days_valid}</label></th>
				<td><input type="text" name="expiration" id="expiration" value="0" size="6" tabindex="4" /><em class="tips">({lang post_zero_is_nopermission})</em></td>
			</tr>
			<tr>
			<th valign="top">{lang post_poll_options}<br />
			{lang post_poll_comment}<br /><br />
			<input type="checkbox" name="visiblepoll" value="1" /> {lang poll_submit_after}<br />
			<input type="checkbox" name="multiplepoll" value="1" onclick="this.checked?$('maxchoicescontrol').style.display='':$('maxchoicescontrol').style.display='none';" /> {lang post_poll_allowmultiple}<br />
			<span id="maxchoicescontrol" style="display: none">{lang poll_max_options}: <input type="text" name="maxchoices" value="$maxpolloptions" size="5"><br /></span>
			</th><td>
			<textarea rows="8" name="polloptions" style="width: 600px; word-break: break-all" tabindex="5">$polloptions</textarea></td>
			</tr>
		<!--{/if}-->

		<tr>
			{subtemplate post_editor}
		</tr>

		<!--{if $tagstatus}-->
			<tr>
				<th><label for="tags">{lang post_tag}</label></th>
				<td>
					<input size="45" type="input" id="tags" name="tags" value="" tabindex="200" />&nbsp;
					<button onclick="relatekw();return false">{lang searchtags}</button><span id="tagselect"></span>
					<em class="tips">{lang tag_comment}</em>
				</td>
			</tr>
		<!--{/if}-->

		<!--{if $special == 5}-->
			<tr>
			<th><label class="affirmpoint">{lang debate_square_point}</label></th>
			<td><textarea name="affirmpoint" id="affirmpoint" rows="10" cols="20" style="width:99%; height:60px" tabindex="201" onkeydown="ctlent(event)"></textarea></td>
			</tr>
			<tr>
			<th><label class="negapoint">{lang debate_opponent_point}</label></th>
			<td><textarea name="negapoint" id="negapoint" rows="10" cols="20" style="width:99%; height:60px" tabindex="202" onkeydown="ctlent(event)"></textarea></td>
			</tr>
		<!--{/if}-->

		<thead>
			<tr>
				<th>&nbsp;</th>
				<td><label><input id="advshow" class="checkbox" type="checkbox" onclick="showadv()" tabindex="203" />{lang post_otherinfo}</label></td>
			</tr>
		</thead>
		<tbody id="adv" style="display: none">

			<!--{if $special == 5}-->
				<tr>
				<th><label for="endtime">{lang debate_endtime}</label></th>
				<td><input onclick="showcalendar(event, this, true)" type="text" name="endtime" size="45" value="" tabindex="204" /></td>
				</tr>
				<tr>
				<th><label for="umpire">{lang debate_umpire}</label></th>
				<td><input type="text" name="umpire" id="umpire" size="45" tabindex="205" onblur="checkuserexists(this.value, 'checkuserinfo')" value="$discuz_user" /><span id="checkuserinfo"></span></td>
				</tr>
			<!--{/if}-->

			<!--{if $allowsetreadperm}-->
				<tr>
					<th><label for="readperm">{lang readperm_thread}</label></th>
					<td><input type="text" name="readperm" id="readperm" size="6" value="$readperm" tabindex="206" /> <em class="tips">({lang post_zero_is_nopermission})</em></td>
				</tr>
			<!--{/if}-->

			<!--{if $maxprice && !$special}-->
				<tr>
					<th><label for="price">{lang price}({$extcredits[$creditstrans][title]})</label></th>
					<td><input type="text" name="price" id="price" size="6" value="$price" tabindex="207" /> <em class="tips">{$extcredits[$creditstrans][unit]} ({lang post_price_comment}<!--{if $maxincperthread}-->{lang post_price_income_comment}<!--{/if}--><!--{if $maxchargespan}-->{lang post_price_charge_comment}<!--{/if}-->)
					{lang post_price_free_comment}</em>
				</td>
				</tr>
			<!--{/if}-->

			<!--{if !$special}-->
				<tr>
					<th>{lang icon}</th>
					<td><label><input class="radio" type="radio" name="iconid" value="0" checked="checked" tabindex="208" /> {lang none}</label> $icons</td>
				</tr>
			<!--{/if}-->

			</tbody>
			<tr class="btns">
				<th>&nbsp;</th>
				<td>
					<input type="hidden" name="wysiwyg" id="{$editorid}_mode" value="$editormode" />
					<button type="submit" name="topicsubmit" id="postsubmit" value="true" tabindex="300"><!--{if $special == 1}-->{lang post_newthread_poll}<!--{elseif $special == 3}-->{lang post_newthread_reward}<!--{elseif $special == 5}-->{lang post_newthread_debate}<!--{else}-->{lang post_newthread}<!--{/if}--></button>
					<em>{lang post_submit_hotkey}</em>&nbsp;&nbsp;
					&nbsp;<a href="###" id="restoredata" onclick="loadData()" title="{lang post_autosave_last_restore}">{lang post_autosave_restore}</a>
				</td>
			</tr>
		</table>
	</div>
<br />

</form>

<script type="text/javascript">
	function showadv() {
		if($("advshow").checked == true) {
			$("adv").style.display = "";
		} else {
			$("adv").style.display = "none";
		}
	}
	function checkuserexists(username, objname) {
		var x = new Ajax();
		username = is_ie && document.charset == 'utf-8' ? encodeURIComponent(username) : username;
		x.get('ajax.php?inajax=1&action=checkuserexists&username=' + username, function(s){
			var obj = $(objname);
			obj.innerHTML = s;
		});
	}
	<!--{if $typeid}-->ajaxget('post.php?action=threadtypes&typeid=$typeid&fid=$fid&inajax=1', 'threadtypes', 'threadtypeswait');<!--{/if}-->
</script>

{subtemplate post_js}

{subtemplate footer}