<script>
	//
// 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 ChangeOption(optn) {
document.getElementById('maincontent').style.display = (optn == 'maincontent') ? "block" : "none";
document.getElementById('additional').style.display = (optn == 'additional') ? "block" : "none";
document.getElementById('attaches').style.display = (optn == 'attaches') ? "block" : "none";
}
function approveMode(mode) {
document.getElementById('approve').value = mode;
return true;
}
function preview() {
var form = document.getElementById("postForm");
if (form.ng_news_content{% if (flags.edit_split) %}_short{% endif %}.value == '' || form.title.value == '') {
alert('{{ lang.addnews['msge_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';
}
}
</script>
<div class="comments-area" style=" margin-bottom: 30px;">
	<div class="row mb-2">
		<div class="col-sm-6 d-none d-md-block ">
			<h3>
				{{ lang.editnews['news_title'] }}</h3>
		</div>
		<!-- /.col -->
		<div class="col-sm-6">
			<ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item">
					<a href="{{ php_self }}">
						<i class="fa fa-home"></i>
					</a>
				</li>
				<li class="breadcrumb-item">
					<a href="{{ php_self }}?mod=news">{{ lang.addnews['news_title'] }}</a>
				</li>
				<li class="breadcrumb-item active" aria-current="page">{{ lang.addnews['addnews_title'] }}</li>
			</ol>
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->
</div>
<div class="comments-area">
	<form name="DATA_tmp_storage" action="" id="DATA_tmp_storage">
		<input type="hidden" name="area" value=""/>
	</form>

	<!-- Main content form -->
	<form id="postForm" name="form" enctype="multipart/form-data" method="post" action="{{ php_self }}" target="_self">
		<input type="hidden" name="token" value="{{ token }}"/>
		<table border="0" cellspacing="1" cellpadding="0">
			<tr>
				<td class="contentNav" align="left">
					<input type="button" onmousedown="javascript:ChangeOption('maincontent')" value="{{ lang.addnews['bar.maincontent'] }}" class="navbutton"/>
					<input type="button" onmousedown="javascript:ChangeOption('additional')" value="{{ lang.addnews['bar.additional'] }}" class="navbutton"/>
					<input type="button" onmousedown="javascript:ChangeOption('attaches')" value="{{ lang.addnews['bar.attaches'] }}" class="navbutton"/>
				</td>
			</tr>
			<tr>
				<td>
					<!-- MAIN CONTENT -->
					<div id="maincontent" style="display: block;">
						<table width="100%" cellspacing="1" cellpadding="0" border="0">
							<tr>
								<td width="100">{{ lang.addnews['title'] }}</td>
								<td><input type="text" class="important" size="60" id="newsTitle" name="title" value="" tabindex="1"/></td>
							</tr>
							{% if not flags['altname.disabled'] %}
								<tr>
									<td>{{ lang.addnews['alt_name'] }}:</td>
									<td><input type="text" name="alt_name" class="important" value="{{ alt_name }}" {% if flags['altname.disabled'] %} disabled="disabled" {% endif %} tabindex="1"/></td>
								</tr>
							{% endif %}

							<tr>
								<td width="100">
									<span class="f15">{{ lang.addnews['category'] }}</span>
								</td>
								<td class="important">{{ mastercat }}
									{% if (flags.mondatory_cat) %}&nbsp;
										<span style="font-size: 16px; color: red;">
											<b>*</b>
										</span>
									{% endif %}
								</td>
							</tr>
							<tr>
								<td valign="top" colspan="3">{{ quicktags }}<br/>
									{{ smilies }}<br/>
									{% if (flags.edit_split) %}
										<div id="container.content.short" class="contentActive">
											<textarea style="width: 99%; padding: 1px; margin: 1px;" onclick="changeActive('short');" onfocus="changeActive('short');" name="ng_news_content_short" id="ng_news_content_short" rows="10" tabindex="2"></textarea>
										</div>
										{% if (flags.extended_more) %}
											<table cellspacing="2" cellpadding="0" width="100%">
												<tr>
													<td nowrap>{{ lang.addnews['editor.divider'] }}: &nbsp;</td>
													<td style="width: 90%"><input tabindex="2" type="text" name="content_delimiter" style="width: 99%;" value=""/></td>
												</tr>
											</table>
										{% endif %}
										<div id="container.content.full" class="contentInactive">
											<textarea style="width: 99%; padding: 1px; margin: 1px;" onclick="changeActive('full');" onfocus="changeActive('full');" name="ng_news_content_full" id="ng_news_content_full" rows="10" tabindex="2"></textarea>
										</div>
									{% else %}
										<div id="container.content" class="contentActive">
											<textarea style="width: 99%; padding: 1px; margin: 1px;" name="ng_news_content" id="ng_news_content" rows="10" tabindex="2"></textarea>
										</div>
									{% endif %}
								</td>
							</tr>

							{% if (flags.meta) %}
								<tr>
									<td>{{ lang.addnews['description'] }}:</td>
									<td>
										<textarea name="description" cols="80"></textarea>
									</td>
								</tr>
								<tr>
									<td>{{ lang.addnews['keywords'] }}:</td>
									<td>
										<textarea id="newsKeywords" name="keywords" cols="80"></textarea>
									</td>
								</tr>
								{% if (pluginIsActive('autokeys')) %}
									<tr>
										<td colspan="2">
											{{ plugin.autokeys }}
										</td>
									</tr>
								{% endif %}
							{% endif %}
							{% if (pluginIsActive('xfields')) %}
								<!-- XFields -->
								{{ plugin.xfields[1] }}
								<!-- /XFields -->
							{% endif %}
						</table>
					</div>
				</td>
			</tr>
		</table>
		<!-- ADDITIONAL -->
		<div id="additional" style="display: none;">
			<table border="0" cellspacing="1" cellpadding="0" width="98%">
				{% if not flags['customdate.disabled'] %}
					<tr>
						<td colspan="2">{{ lang.editnews['date.manage'] }}</td>
					</tr>
					<tr>
						<td colspan="2">
							<table cellspacing="0" cellpadding="3" border="0" width="100%" style="font: 11px verdana, sans-serif;">
								<tr>
									<td width="30"><input type="checkbox" name="setdate_custom" id="setdate_custom" value="1" class="check" onclick="document.getElementById('setdate_current').checked=false;"/></td>
									<td width="250">
										<label for="setdate_custom">{{ lang.addnews['custom_date'] }}</label>
									</td>
									<td><input type="text" id="cdate" name="cdate" value="{{ cdate }}" class="form-control" pattern="[0-9]{2}\.[0-9]{2}\.[0-9]{4} [0-9]{2}:[0-9]{2}" placeholder="{{ "now" | date('d.m.Y H:i') }}" autocomplete="off" style="width: 100%;"/></td>
								</tr>

							</table>

						</td>
					</tr>

				{% endif %}
				{% if (pluginIsActive('xfields')) %}
					<!-- XFields -->
					{{ plugin.xfields[0] }}
					<!-- /XFields -->
				{% endif %}
				{% if (pluginIsActive('nsched')) %}
					{{ plugin.nsched }}
				{% endif %}

				{% if (pluginIsActive('tags')) %}
					{{ plugin.tags }}
				{% endif %}
				{% if (pluginIsActive('tracker')) %}
					{{ plugin.tracker }}
				{% endif %}
			</table>
		</div>
		<script>
			$("#cdate").datetimepicker({currentText: "DD.MM.YYYY HH:MM", dateFormat: "dd.mm.yy", timeFormat: "hh:mm"});
		</script>
		<!-- ATTACHES -->
		<div id="attaches" style="display: none;">
			<br/>
			<span class="f15">{{ lang.addnews['attach.list'] }}</span>
			<table width="100%" cellspacing="1" cellpadding="2" border="0" id="attachFilelist">
				<thead>
					<tr class="contHead">
						<td>#</td>
						<td width="80">{{ lang.editnews['attach.date'] }}</td>
						<td>{{ lang.editnews['attach.filename'] }}</td>
						<td width="90">{{ lang.editnews['attach.size'] }}</td>
						<td width="40">DEL</td>
					</tr>
				</thead>
				<tbody>
					<!-- <tr><td>*</td><td>New file</td><td colspan="2"><input type="file"/></td><td><input type="button" size="40" value="-"/></td></tr> -->
					<tr>
						<td colspan="3">&nbsp;</td>
						<td colspan="2"><input type="button" value="Добавить поле" class="button" style="width: 100%;" onclick="attachAddRow();"/></td>
					</tr>
				</tbody>
			</table>
		</div>
	</td>
	<td>
		<!-- Right edit column -->
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td colspan="2">
					<span class="f15">{{ lang['editor.comminfo'] }}</span>
				</td>
			</tr>
			{% if (pluginIsActive('comments')) %}
				<tr>
					<td width="100">
						<span class="f15">{{ lang['comments:mode.header'] }}:</span>
					</td>
					<td class="important">
						<select name="allow_com">
							<option value="0" {{ plugin.comments['acom:0'] }}>{{ lang['comments:mode.disallow'] }}</option>
							<option value="1" {{ plugin.comments['acom:1'] }}>{{ lang['comments:mode.allow'] }}</option>
							<option value="2" {{ plugin.comments['acom:2'] }}>{{ lang['comments:mode.default'] }}</option>
						</select>
					</td>
				</tr>
			{% endif %}
			<tr>
				<td width="50%">
					<b>{{ lang['editor.configuration'] }}</b>
					<div class="list">
						<label><input type="checkbox" name="mainpage" value="1" class="check" id="mainpage" {% if (flags.mainpage) %} checked="checked" {% endif %} {% if flags['mainpage.disabled'] %} disabled {% endif %}/>
							{{ lang.addnews['mainpage'] }}</label><br/>
						<label><input type="checkbox" name="pinned" value="1" class="check" id="pinned" {% if (flags.pinned) %} checked="checked" {% endif %} {% if flags['pinned.disabled'] %} disabled {% endif %}/>
							{{ lang.addnews['add_pinned'] }}</label><br/>
						<label><input type="checkbox" name="catpinned" value="1" class="check" id="catpinned" {% if (flags.catpinned) %} checked="checked" {% endif %} {% if flags['catpinned.disabled'] %} disabled {% endif %}/>
							{{ lang.addnews['add_catpinned'] }}</label><br/>
						<label><input type="checkbox" name="favorite" value="1" class="check" id="favorite" {% if (flags.favorite) %} checked="checked" {% endif %} {% if flags['favorite.disabled'] %} disabled {% endif %}/>
							{{ lang.addnews['add_favorite'] }}</label><br/>
						<label><input name="flag_HTML" type="checkbox" class="check" id="flag_HTML" value="1" {% if (flags['html.disabled']) %} disabled {% endif %} {% if (flags['html']) %} checked="checked" {% endif %}/>
							{{ lang.addnews['flag_html'] }}</label><br/>
						<label><input type="checkbox" name="flag_RAW" value="1" class="check" id="flag_RAW" {% if (flags['html.disabled']) %} disabled {% endif %} {% if (flags['raw']) %} checked="checked" {% endif %}/>
							{{ lang.addnews['flag_raw'] }}</label><br/>

					</div>
				</td>
				{% if flags['multicat.show'] %}
					<td>
						<span class="f15">{{ lang['editor.extcat'] }}</span>
						<div style="overflow: auto; height: 150px;" class="list">{{ extcat }}</div>
					</td>
				{% endif %}
			</tr>
		</table>
		<input type="hidden" name="mod" value="news"/>
		<input type="hidden" name="action" value="add"/>
		<input type="hidden" name="subaction" value="submit"/>
		<input type="hidden" name="approve" id="approve" value="0"/>
		<p>
			<input type="button" value="{{ lang.addnews['preview'] }}" class="button" onclick="return preview();"/>
			<input type="submit" value="Сохранить черновик" class="button" onclick="return approveMode(-1);"/>
			<input type="submit" value="Отправить на модерацию" class="button" onclick="return approveMode(0);"/>
			{% if flags['can_publish'] %}
				<input type="submit" value="Опубликовать" class="button" onclick="return approveMode(1);"/>
			{% else %}
				&nbsp;
			{% endif %}
		</p>
		{% if (pluginIsActive('xfields')) %}
			<!-- XFields [GENERAL] -->
			{{ plugin.xfields.general }}
			<!-- /XFields [GENERAL] -->
		{% endif %}
	</td>
</form>
<script>
	// 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>
<script>
	<!--
	function attachAddRow() {
var tbl = document.getElementById('attachFilelist');
var lastRow = tbl.rows.length;
var row = tbl.insertRow(lastRow - 1);
// Add cells
row.insertCell(0).innerHTML = '*';
row.insertCell(1).innerHTML = '{{ lang.editnews['attach.new_file'] }}';
// Add file input
var el = document.createElement('input');
el.setAttribute('type', 'file');
el.setAttribute('name', 'userfile[' + (
++ attachAbsoluteRowID
) + ']');
el.setAttribute('size', '80');
var xCell = row.insertCell(2);
xCell.colSpan = 2;
xCell.appendChild(el);
el = document.createElement('input');
el.setAttribute('type', 'button');
el.setAttribute('onclick', 'document.getElementById("attachFilelist").deleteRow(this.parentNode.parentNode.rowIndex);');
el.setAttribute('value', '-');
row.insertCell(3).appendChild(el);
}
// Add first row
var attachAbsoluteRowID = 0;
attachAddRow();
	-->
</script>
