{% extends localPath(0) ~ "site.body.tpl" %}
{% block content %}
	{% if (flags.link_news) %}
		<div class="alert alert-info" style="margin: 10px;">
			<b>Запрос по новости : <a href="{{ news.url }}">{{ news.title }}</a></b>
		</div>
	{% endif %}
	{{ description }}<br/><br/>
	{% if (flags.jcheck) %}
		<script language="JavaScript">
			var FBF_INIT = {{ FBF_DATA }};
			function FBF_CHECK() {
				var frm = document.getElementById('feedback_form');
				if (frm == null) return true;

				var i;
				for (i in FBF_INIT) {
					if (FBF_INIT[i][1]) {
						if (FBF_INIT[i][0] == 'date') {
							if ((frm[i + ':day'].value == '1') && (frm[i + ':month'].value == '1') && (frm[i + ':year'].value == '1970')) {
								alert('{l_feedback:form.err.notfilled} (' + FBF_INIT[i][2] + ')!');
								frm[i + ':day'].focus();
								return false;
							}
						} else if (frm[i].value == '') {
							alert('{l_feedback:form.err.notfilled} (' + FBF_INIT[i][2] + ')!');
							frm[i].focus();
							return false;
						}
					}
				}
				return true;
			}
		</script>
	{% endif %}
	<form method="post" action="{{ form_url }}" class="form newtopic" id="feedback_form" name="feedback_form">
		<div class="card">
			{{ hidden_fields }}
			<input type="hidden" name="id" value="{{ id }}"/>
			{% for entry in entries %}
				{% if entry.type == 'text' %}
					<div>
						<label>{{ entry.title }}</label>
						<input type="text" name="{{ entry.name }}" class="form-control" />
					</div>
				{% endif %}
				{% if entry.type == 'email' %}
					<div>
						<label>{{ entry.title }}</label>
						<input type="text" name="{{ entry.name }}" class="form-control" />
					</div>
				{% endif %}
				{% if entry.type == 'textarea' %}
					<div>
						<label>{{ entry.title }}</label>
						<textarea name="{{ entry.name }}" class="form-control" />{{ entry.value }}</textarea>
					</div>
				{% endif %}
				{% if entry.type == 'select' %}
					<div>
						<label>{{ entry.title }}</label>
						<select name="{{ entry.name }}" class="form-control">{{ entry.options.select }}</select>
					</div>
				{% endif %}
				{% if entry.type == 'date' %}
					<div>
						<label>{{ entry.title }}</label>
						<select name="{{ entry.name }}:day">{{ entry.options.day }}</select>.<select name="{{ entry.name }}:month">{{ entry.options.month }}</select>.<select name="{{ entry.name }}:year">{{ entry.options.year }}</select>
					</div>
				{% endif %}
			{% endfor %}
			{% if (flags.captcha) %}
				<div>
					<label>{{ lang.theme.code }}</label>
					<div><span><img id="img_captcha" onclick="this.src='{{ captcha_url }}&rand='+Math.random();" src="{{ captcha_url }}&rand={{ captcha_rand }}" style="background: #fff; cursor: pointer;" alt="Security code" width="120" height="40" /></span></div>
					<div><input type="text" name="vcode" style="width:120px" /></div>
					<div class="label-desc">{{ lang.theme.code_desc }}</div>
				</div>
			{% endif %}
			{% if (flags.recipients) %}
				<div>
					<label>{{ lang['feedback:sform.elist'] }}</label>
					<select name="recipient" class="form-control">{{ recipients_list }}</select>
				</div>
			{% endif %}
		</div>
		<div class="postinfobot">
			<div class="pull-right postreply">
				<div class="pull-left"><button class="btn btn-primary" {% if (flags.jcheck) %}onclick="return FBF_CHECK();" {% endif %}type="submit">{{ lang.theme.send }}</button></div>
				<div class="clearfix"></div>
			</div>
			<div class="clearfix"></div>
		</div>
	</form>
{% endblock %}