<script>
	var auth_link_vk = '';
	var auth_link_steam = '';

	jQuery(document).ready(function($)
	{
		<? if($auth_api->vk_api == 1) { ?>
			get_auth_link_vk();
		<? } ?>
		<? if($auth_api->steam_api == 1) { ?>
			get_auth_link_steam();
		<? } ?>

		$('#user-block').html(
			'<div class="user-block">'
				+'<div class="user-links">'
					+'<a href="#" onclick="open_auth_form(); return false">Авторизоваться</a>'
					+'<a href="#" onclick="open_signup_form(); return false">Зарегистрироваться</a>'
					+'<a href="../recovery" class="float-right">Восстановить доступ</a>'
				+'</div>'
			+'</div>'
		);

		$('#api_auth').modal('hide');

		$('.block-form-fix').click(function()
		{
			close_forms();
		});
	});

	function open_auth_form()
	{
		$('#auth_form').show();
		$('.block-form-fix').show();
	}

	function open_signup_form()
	{
		$('#signup_form').show();
		$('.block-form-fix').show();
	}

	function close_forms()
	{
		$('#auth_form').hide();
		$('#signup_form').hide();
		$('.block-form-fix').hide();
	}

	function get_auth_link_vk()
	{
		$.ajax({
			type: 'POST',
			url: '../ajax/fast_actions.php',
			data: 'get_vk_auth_link=1',
			dataType: 'json',
			success: function(data)
			{
				auth_link_vk = data.url;
			}
		});
	}

	function get_auth_link_steam()
	{
		$.ajax({
			type: 'POST',
			url: '../ajax/fast_actions.php',
			data: 'get_steam_auth_link=1',
			dataType: 'json',
			success: function(data)
			{
				auth_link_steam = data.url;
			}
		});
	}

	function user_login_vk()
	{
		location.href = auth_link_vk;
	}

	function user_login_steam()
	{
		location.href = auth_link_steam;
	}

	function show_reg_modal(type)
	{
		close_forms();
		$('#api_auth').modal('show');
		$('#api_reg_btn').attr('onclick', 'reg_by_api("'+type+'")');
	}
</script>

<div id="auth_form" class="block-form-center disp-n">
	<div class="block">
		<div class="header">Авторизация</div>
		<div class="block-content">
			<div class="form-input">
				<label for="user_loginn">Логин</label>
				<input type="text" id="user_loginn" maxlength="30" autocomplete="off">
			</div>
			<div class="form-input">
				<label for="user_password">Пароль</label>
				<input type="password" id="user_password" maxlength="15" autocomplete="off">
			</div>
			<div class="message-send">
				<div class="btn float-left" onclick="user_login()">Авторизоваться</div>
				<? if($auth_api->steam_api == 1) { ?>
					<div class="float-right m-l-5" onclick="user_login_steam()"><i class="fa fa-steam"></i></div>
				<? } ?>
				<? if($auth_api->vk_api == 1) { ?>
					<div class="float-right m-r-5" onclick="user_login_vk()"><i class="fa fa-vk"></i></div>
				<? } ?>
			</div>
			<div class="clear"></div>
			<div id="result" class="m-t-5">{conf_mess}</div>
		</div>
	</div>
</div>

<div id="signup_form" class="block-form-center disp-n">
	<div class="block">
		<div class="header">Регистрация</div>
		<div class="block-content">
			<div class="form-input">
				<label for="reg_login">Логин</label>
				<input type="text" id="reg_login" maxlength="30" autocomplete="off">
			</div>
			<div class="form-input">
				<label for="reg_password">Пароль</label>
				<input type="password" id="reg_password" maxlength="15" autocomplete="off">
			</div>
			<div class="form-input">
				<label for="reg_password2">Пароль еще раз</label>
				<input type="password" id="reg_password2" maxlength="15" autocomplete="off">
			</div>
			<div class="form-input">
				<label for="reg_email">Почта</label>
				<input type="text" id="reg_email" maxlength="255" autocomplete="off">
			</div>
			<? if($conf->privacy_policy == 1) { ?>
				<div class="bs-callout bs-callout-info bs-mini-info m-l-5 m-b-5 m-r-5 m-t-5"><p>Регистрируясь на данном сайте, Вы выражаете согласие на обработку персональных данных</p></div>
			<? } ?>
			<? if($conf->captcha != '2') { ?>
				<div style="transform:scale(0.725);-webkit-transform:scale(0.725);transform-origin:0 0;-webkit-transform-origin:0 0; margin-bottom: -15px" data-theme="light" class="g-recaptcha clearfix" data-sitekey="<? echo $conf->captcha; ?>"></div>
				<script src="https://www.google.com/recaptcha/api.js?hl=ru"></script>
			<? } ?>
			<div class="message-send">
				<div class="btn float-left" onclick="registration()">Зарегистрироваться</div>
				<? if($auth_api->steam_api == 1) { ?>
					<div class="float-right m-l-5" onclick="show_reg_modal('steam')"><i class="fa fa-steam"></i></div>
				<? } ?>
				<? if($auth_api->vk_api == 1) { ?>
					<div class="float-right m-r-5" onclick="show_reg_modal('vk');"><i class="fa fa-vk"></i></div>
				<? } ?>
			</div>
			<div class="clear"></div>
			<div id="result2" class="m-t-5">{conf_mess}</div>
		</div>
	</div>
</div>

<div id="api_auth" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> 
	<div class="modal-dialog"> 
		<div class="modal-content"> 
			<div class="modal-header"> 
				<h4 class="modal-title">Укажите, пожалуйста, свой e-mail.</h4> 
			</div> 
			<div class="modal-body"> 
				<input type="email" maxlength="255" class="form-control" id="api_email" placeholder="E-mail <? if($conf->conf_us == 1) { ?>(Требуется настоящий e-mail!)<? } ?>"> 
				<button id="api_reg_btn" class="btn m-t-5" onclick="">Зарегистрироваться</button>
				<div id="result_api_reg" class="m-t-5"></div> 
			</div> 
		</div> 
	</div> 
</div>