<script type="text/javascript">
	document.ready = function () {
		var sizelimit = {{ info_sizelimit }};
		if (sizelimit <= 0) {
			document.getElementById('sizelimit_text').style.display = "none";
		}
	}
	function validate_form() {
		var f = document.getElementById('profileForm');
		// Email
		var email = f.editmail.value;
		if ((email.length > 0) && (!emailCheck(email))) {
			alert("{{ lang.uprofile['wrong_email'] }}");
			return false;
		}
		// About
		var about = f.editabout.value;
		if (({{ info_sizelimit }} > 0) &&
		(about.length > {{ info_sizelimit }})
	)
		{
			alert("{{ info_sizelimit_text }}");
			return false;
		}
		return true;
	}
</script>
<div class="post">
	<form id="profileForm" method="post" class="form newtopic" action="{{ form_action }}" enctype="multipart/form-data">
		<input type="hidden" name="token" value="{{ token }}"/>
		<div class="postinfotop">
			<h2>{{ lang.uprofile['profile_of'] }} {{ user.name }}</h2>
		</div>
		<div class="accsection">
			<div class="topwrap">
				<div class="card">
					{% if pluginIsActive('xfields') %}{{ plugin_xfields_1 }}{% endif %}
					<div>
						<label>{{ lang.uprofile['email'] }}</label>
						<input type="text" name="editmail" value="{{ user.email }}" class="form-control" />
					</div>
					<div>
						<label>{{ lang.uprofile['from'] }}</label>
						<input type="text" name="editfrom" value="{{ user.from }}" class="form-control" />
					</div>
					<div>
						<label>{{ lang.uprofile['about'] }}</label>
						<textarea name="editabout" class="form-control">{{ user.info }}</textarea>
						<div class="alert alert-warning" id="sizelimit_text">{{ lang.uprofile['sizelimit_min'] }}{about_sizelimit} {{ lang.uprofile['characters'] }}</div>{% if (info_sizelimit > 0) %}{% endif %}
					</div>
					<div>
						<label>{{ lang.uprofile['new_pass'] }}</label>
						<input type="password" name="editpassword" class="form-control" />
					</div>
					<div>
						<label>{{ lang.uprofile['oldpass'] }}</label>
						<input type="password" name="oldpass" value="" class="form-control" />
						<div>{{ lang.uprofile['oldpass#desc'] }}</div>
					</div>
					{% if (flags.avatarAllowed) %}
						<div>
							<label>{{ lang.uprofile['avatar'] }}:</label>
							<input type="file" name="newavatar" class="form-control" />
							{% if (user.flags.hasAvatar) %}
								<img src="{{ user.avatar }}" style="margin: 5px; border: 0px; max-width: 80px; max-height: 80px;" alt=""/>
								<br/>
								<input type="checkbox" name="delavatar" id="delavatar"/>&nbsp;{{ lang.uprofile['delete'] }}
							{% endif %}
						</div>
					{% else %}
						<div>
							<label>{{ lang.uprofile['avatar'] }}:</label>
							{{ lang.uprofile['avatars_denied'] }}
						</div>
					{% endif %}
					{% if pluginIsActive('xfields') %}{{ plugin_xfields_0 }}{% endif %}
					<div class="postinfobot">
						<div class="pull-right postreply">
							<div class="pull-left"><button type="submit" onclick="return validate_form();" class="btn btn-primary">{{ lang.uprofile['save'] }}</button></div>
							<div class="clearfix"></div>
						</div>
						<div class="clearfix"></div>
					</div>
				</div>
				<div class="clearfix"></div>
			</div>
		</div>
	</form>
</div>