<script type="text/javascript">
	// Global variable: ID of current active input area
	{% if (flags.edit_split) %}var currentInputAreaID = 'ng_news_content_short';{% else %}var currentInputAreaID = 'ng_news_content';{% endif %}
	function preview(){
		var form = document.getElementById("postForm");
		if (form.ng_news_content{% if (flags.edit_split) %}_short{% endif %}.value == '' || form.title.value == '') {
			alert('{{ lang.nsm['err.preview'] }}');
			return false;
		}
		form['mod'].value = "preview";
		form.target = "_blank";
		form.submit();
		form['mod'].value = "news";
		form.target = "_self";
		return true;
	}
	function changeActive(name) {
		if (name == 'full') {
			document.getElementById('container.content.full').className  = 'contentActive';
			document.getElementById('container.content.short').className = 'contentInactive';
			currentInputAreaID = 'ng_news_content_full';
		} else {
			document.getElementById('container.content.short').className = 'contentActive';
			document.getElementById('container.content.full').className  = 'contentInactive';
			currentInputAreaID = 'ng_news_content_short';
		}
	}
	function approveMode(mode) {
		document.getElementById('approve').value = mode;
		return true;
	}
</script>
<form id="postForm" name="form" ENCTYPE="multipart/form-data" method="POST" action="{{ currentURL }}">
<input type="hidden" name="token" value="{{ token }}"/>
<input type="hidden" name="mod" value="news"/>
<input type="hidden" name="approve" id="approve" value="0"/>
<h2 class="section_name">{{ lang.nsm['addnews_title'] }} - [ <a role="button" href="{{ listURL }}">{{ lang.nsm['news.list'] }}</a> ]</h2>
<article class="box_content">
	<div class="box_in">
		<div class="addform">
			<ul class="ui-form">
				<li class="form-group">
					<label class="imp">{{ lang.nsm['newstitle'] }}</label>
					<input type="text" name="title" value="" class="wide" required>
				</li>
				<li class="form-group">
					<label>{{ lang.nsm['alt_name'] }}</label>
					<input type="text" name="alt_name" value="" class="wide" required>
				</li>
				<li class="form-group">
					<label class="imp">{{ lang.nsm['category'] }}</label>
					{{ mastercat }}
				</li>
				{% if flags['multicat.show'] %}
					<li class="form-group">
						<label>{{ lang.nsm['dop.categories'] }}</label>
						<div style="overflow:auto;max-height:100px;margin-bottom:10px">
							{{ extcat }}
						</div>
					</li>
				{% endif %}
				{% if (flags.edit_split) %}
					<li class="form-group">
						<label class="imp">{{ lang.nsm['news.anons'] }}: ({{ lang.nsm['desk.news.anons'] }})</label>
						<div class="bb-editor">
							{{ quicktags }}
							<textarea onclick="changeActive('short');" onfocus="changeActive('short');" name="ng_news_content_short" id="ng_news_content_short" rows="5" class="wide" required></textarea>
						</div>
					</li>
					{% if (flags.extended_more) %} 
						<li class="form-group">
							<label>{{ lang.nsm['news.more'] }}</label>
							<input type="text" name="content_delimiter" value="" class="wide" required>
						</li>
					{% endif %}
					<li class="form-group">
						<label class="imp">{{ lang.nsm['full.news'] }}: ({{ lang.nsm['desk.news.full'] }})</label>
						<div class="bb-editor">
							{{ quicktags }}
							<textarea onclick="changeActive('full');" onfocus="changeActive('full');" name="ng_news_content_full" id="ng_news_content_full" rows="5" class="wide" required></textarea>
						</div>
					</li>
				{% else %}
					<li class="form-group">
						<div class="bb-editor">
							{{ quicktags }}
							<textarea name="ng_news_content" id="ng_news_content" rows="10" class="wide" required></textarea>
						</div>
					</li>
				{% endif %}
				<li class="form-group">
					<div class="admin_checkboxs">
						<div>
							{% if not flags['mainpage.disabled'] %}
								<label><input type="checkbox" name="mainpage" value="1" id="mainpage" {% if (flags.mainpage) %}checked="checked" {% endif %}{% if flags['mainpage.disabled'] %}disabled {% endif %}  /> {{ lang.nsm['mainpage'] }}</label><br />
							{% endif %}
							{% if not flags['pinned.disabled'] %}
								<label><input type="checkbox" name="pinned" value="1" id="pinned" {% if (flags.pinned) %}checked="checked" {% endif %}{% if flags['pinned.disabled'] %}disabled {% endif %}  /> {{ lang.nsm['add_pinned'] }}</label><br />
							{% endif %}
							{% if not flags['catpinned.disabled'] %}
								<label><input type="checkbox" name="catpinned" value="1" id="catpinned" {% if (flags.catpinned) %}checked="checked" {% endif %}{% if flags['catpinned.disabled'] %}disabled {% endif %}  /> {{ lang.nsm['add_catpinned'] }}</label><br />
							{% endif %}
							{% if not flags['favorite.disabled'] %}
								<label><input type="checkbox" name="favorite" value="1" id="favorite" {% if (flags.favorite) %}checked="checked" {% endif %}{% if flags['favorite.disabled'] %}disabled {% endif %}  /> {{ lang.nsm['add_favorite'] }}</label><br />
							{% endif %}
							{% if not flags['html.disabled'] %}
								<label><input name="flag_HTML" type="checkbox" id="flag_HTML" value="1" {% if (flags['html.disabled']) %}disabled {% endif %}{% if flags['html'] %}checked="checked"{% endif %} /> {{ lang.nsm['flag_html'] }}</label><br />
								<label><input type="checkbox" name="flag_RAW" value="1" id="flag_RAW" {% if (flags['html.disabled']) %}disabled {% endif %}{% if flags['html'] %}checked="checked"{% endif %}  /> {{ lang.nsm['flag_raw'] }}</label><br />
							{% endif %}
						</div>
					</div>
				</li>
			</ul>
			<div class="form_submit">
				{% if flags['can_publish'] %}
					<button class="btn btn-big" onclick="return approveMode(1);" type="submit"><b>{{ lang.nsm['add'] }}</b></button>
				{% else %} &nbsp; {% endif %}
				<button class="btn btn-big" onclick="return approveMode(0);" type="submit"><b>{{ lang.nsm['moder.news'] }}</b></button>
				<button class="btn btn-big" onclick="return approveMode(-1);" type="submit"><b>{{ lang.nsm['save.draft'] }}</b></button>
				<button class="btn btn-big" onclick="return preview();" otype="button"><b>{{ lang.nsm['preview'] }}</b></button>
			</div>
		</div>
	</div>
</article>
</form>
<script language="javascript" type="text/javascript">
	// Restore variables if needed
	var jev = {{ JEV }};
	var form = document.getElementById('postForm');
	for (i in jev) {
		//try { alert(i+' ('+form[i].type+')'); } catch (err) {;}
		if (typeof(jev[i]) == 'object') {
			for (j in jev[i]) {
				//alert(i+'['+j+'] = '+ jev[i][j]);
				try { form[i+'['+j+']'].value = jev[i][j]; } catch (err) {;}
			}
		} else {
			try {
				if ((form[i].type == 'text')||(form[i].type == 'textarea')||(form[i].type == 'select-one')) {
					form[i].value = jev[i];
				} else if (form[i].type == 'checkbox') {
					form[i].checked = (jev[i]?true:false);
				}
			} catch(err) {;}
		}
	}
</script>