<?php echo Wo_LoadPage('welcome/welcome-header-register');?>
<div class="wrapper">
	<div class="typing-element"></div>
	<div class="login fadeInUp animated animated_5">
		<div class="login_left_combo_parent">
			<div class="carousel slide carousel-fade" data-ride="carousel">
				<div class="carousel-inner" role="listbox">
					<div class="item active" style="background-image: url(<?php echo $wo['config']['theme_url'];?>/img/backgrounds/login.<?php echo $wo['config']['background_extension'];?>)"></div>
					<div class="item" style="background-image: url(<?php echo $wo['config']['theme_url'];?>/img/backgrounds/login2.<?php echo $wo['config']['background_extension'];?>)"></div>
					<div class="item" style="background-image: url(<?php echo $wo['config']['theme_url'];?>/img/backgrounds/login3.<?php echo $wo['config']['background_extension'];?>)"></div>
				</div>
			</div>
			<div class="login_left_combo">
				<div class="fadeInUp animated animated_9">
					<h1><?php echo $wo['lang']['welcome_']?></h1>
					<p><?php echo $wo['lang']['welcome_share_text']?></p>
					<?php if ($wo['config']['facebookLogin'] != 0 ||
								$wo['config']['googleLogin'] != 0 ||
								$wo['config']['twitterLogin'] != 0 ||
								$wo['config']['linkedinLogin'] != 0 ||
								$wo['config']['VkontakteLogin'] != 0 ||
								$wo['config']['instagramLogin'] != 0
							) { ?>
					<div class="social_btns">
						<p><?php echo $wo['lang']['login_with']?> <?php echo $wo['lang']['social_links']?>:</p>
						<?php if($wo['config']['facebookLogin'] != 0): ?>
							<a href="<?php echo $wo['facebookLoginUrl']?>" class="btn btn-facebook"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M17,2V2H17V6H15C14.31,6 14,6.81 14,7.5V10H14L17,10V14H14V22H10V14H7V10H10V6A4,4 0 0,1 14,2H17Z"></path></svg></a>
						<?php endif; ?>
						<?php if($wo['config']['googleLogin'] != 0): ?>
							<a href="<?php echo $wo['googleLoginUrl']?>" class="btn btn-google"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M23,11H21V9H19V11H17V13H19V15H21V13H23M8,11V13.4H12C11.8,14.4 10.8,16.4 8,16.4C5.6,16.4 3.7,14.4 3.7,12C3.7,9.6 5.6,7.6 8,7.6C9.4,7.6 10.3,8.2 10.8,8.7L12.7,6.9C11.5,5.7 9.9,5 8,5C4.1,5 1,8.1 1,12C1,15.9 4.1,19 8,19C12,19 14.7,16.2 14.7,12.2C14.7,11.7 14.7,11.4 14.6,11H8Z"></path></svg></a>
						<?php endif; ?>
						<?php if($wo['config']['twitterLogin'] != 0): ?>
							<a href="<?php echo $wo['twitterLoginUrl']?>" class="btn btn-twitter"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M22.46,6C21.69,6.35 20.86,6.58 20,6.69C20.88,6.16 21.56,5.32 21.88,4.31C21.05,4.81 20.13,5.16 19.16,5.36C18.37,4.5 17.26,4 16,4C13.65,4 11.73,5.92 11.73,8.29C11.73,8.63 11.77,8.96 11.84,9.27C8.28,9.09 5.11,7.38 3,4.79C2.63,5.42 2.42,6.16 2.42,6.94C2.42,8.43 3.17,9.75 4.33,10.5C3.62,10.5 2.96,10.3 2.38,10C2.38,10 2.38,10 2.38,10.03C2.38,12.11 3.86,13.85 5.82,14.24C5.46,14.34 5.08,14.39 4.69,14.39C4.42,14.39 4.15,14.36 3.89,14.31C4.43,16 6,17.26 7.89,17.29C6.43,18.45 4.58,19.13 2.56,19.13C2.22,19.13 1.88,19.11 1.54,19.07C3.44,20.29 5.7,21 8.12,21C16,21 20.33,14.46 20.33,8.79C20.33,8.6 20.33,8.42 20.32,8.23C21.16,7.63 21.88,6.87 22.46,6Z"></path></svg></a>
						<?php endif; ?>
						<?php if($wo['config']['linkedinLogin'] != 0): ?>
							<a href="<?php echo $wo['linkedInLoginUrl']?>" class="btn btn-linkedin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M21,21H17V14.25C17,13.19 15.81,12.31 14.75,12.31C13.69,12.31 13,13.19 13,14.25V21H9V9H13V11C13.66,9.93 15.36,9.24 16.5,9.24C19,9.24 21,11.28 21,13.75V21M7,21H3V9H7V21M5,3A2,2 0 0,1 7,5A2,2 0 0,1 5,7A2,2 0 0,1 3,5A2,2 0 0,1 5,3Z"></path></svg></a>
						<?php endif; ?>
						<?php if($wo['config']['VkontakteLogin'] != 0): ?>
							<a href="<?php echo $wo['VkontakteLoginUrl']?>" class="btn btn-vk"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M20.8,7.74C20.93,7.32 20.8,7 20.18,7H18.16C17.64,7 17.41,7.27 17.28,7.57C17.28,7.57 16.25,10.08 14.79,11.72C14.31,12.19 14.1,12.34 13.84,12.34C13.71,12.34 13.5,12.19 13.5,11.76V7.74C13.5,7.23 13.38,7 12.95,7H9.76C9.44,7 9.25,7.24 9.25,7.47C9.25,7.95 10,8.07 10.05,9.44V12.42C10.05,13.08 9.93,13.2 9.68,13.2C9,13.2 7.32,10.67 6.33,7.79C6.13,7.23 5.94,7 5.42,7H3.39C2.82,7 2.7,7.27 2.7,7.57C2.7,8.11 3.39,10.77 5.9,14.29C7.57,16.7 9.93,18 12.08,18C13.37,18 13.53,17.71 13.53,17.21V15.39C13.53,14.82 13.65,14.7 14.06,14.7C14.36,14.7 14.87,14.85 16.07,16C17.45,17.38 17.67,18 18.45,18H20.47C21.05,18 21.34,17.71 21.18,17.14C21,16.57 20.34,15.74 19.47,14.76C19,14.21 18.29,13.61 18.07,13.3C17.77,12.92 17.86,12.75 18.07,12.4C18.07,12.4 20.54,8.93 20.8,7.74Z"></path></svg></a>
						<?php endif; ?>
						<?php if($wo['config']['instagramLogin'] != 0): ?>
							<a href="<?php echo $wo['instagramLoginUrl']?>" class="btn btn-instagram"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M7.8,2H16.2C19.4,2 22,4.6 22,7.8V16.2A5.8,5.8 0 0,1 16.2,22H7.8C4.6,22 2,19.4 2,16.2V7.8A5.8,5.8 0 0,1 7.8,2M7.6,4A3.6,3.6 0 0,0 4,7.6V16.4C4,18.39 5.61,20 7.6,20H16.4A3.6,3.6 0 0,0 20,16.4V7.6C20,5.61 18.39,4 16.4,4H7.6M17.25,5.5A1.25,1.25 0 0,1 18.5,6.75A1.25,1.25 0 0,1 17.25,8A1.25,1.25 0 0,1 16,6.75A1.25,1.25 0 0,1 17.25,5.5M12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9Z"></path></svg></a>
						<?php endif; ?>
					</div>
				    <?php } ?>
				    <?php if($wo['config']['googleLogin'] != 0): ?>
				    <br>
				    <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
				    <?php endif; ?>
				</div>
			</div>
		</div>
		<div class="col-md-6">
			<form id="login" class="fadeInUp animated animated_9" method="post">
				<p class="title"><?php echo $wo['lang']['login']?></p>
				<div class="errors"></div>
				<div class="wow_form_fields">
					<label for="username"><?php echo $wo['lang']['username']?></label>
					<input id="username" name="username" type="text" autocomplete="off" autofocus>
				</div>
				<div class="wow_form_fields">
					<label for="password"><?php echo $wo['lang']['password']?></label>
					<input id="password" name="password" type="password" autocomplete="off">
				</div>
				<div class="forgot_password">
					<a href="<?php echo Wo_SeoLink('index.php?link1=forgot-password');?>"><?php echo $wo['lang']['forget_password']?></a>
				</div>
				<div class="login_signup_combo">
					<div class="login__">
						<button type="submit" class="btn btn-main btn-mat btn-mat-raised add_wow_loader"><?php echo $wo['lang']['login']?></button>
					</div>
					<div class="signup__">
						<?php if ($wo['config']['user_registration'] == 1): ?>
						<p><?php echo $wo['lang']['dont_have_account']?> <a class="dec" href="<?php echo Wo_SeoLink('index.php?link1=register');?>"><?php echo $wo['lang']['register']?></a></p>
						<?php endif ?>
					</div>
				</div>
				<?php if(!empty( $_GET['last_url'])){?>
					<div class="form-group"><input type="hidden" name="last_url" value="<?php echo urldecode(Wo_Secure($_GET['last_url']));?>"></div>
				<?php } ?>
				<div class="random_users">
					<?php if ($wo['config']['profile_privacy'] == 1) { ?>
						<hr>
						<?php echo Wo_LoadPage('welcome/welcome-users-profiles');?>
					<?php } ?>
				</div>
			</form>
		</div>
	</div>
</div>
<div class="container"><?php echo Wo_LoadPage('footer/welcome');?></div>

<script>
var working = false;
var $this = $('#login');
var $state = $this.find('.errors');

<?php if($wo['config']['googleLogin'] != 0): ?>
function signOut() {
	var auth2 = gapi.auth2.getAuthInstance();
	auth2.signOut().then(function () {
	  console.log('User signed out.');
	});
}

function onSignIn(googleUser) {
    // The ID token you need to pass to your backend:
    var id_token = googleUser.getAuthResponse().id_token;
    $.post(Wo_Ajax_Requests_File() + '?f=google_login', {id_token: id_token}, function(data, textStatus, xhr) {
    	if (data.status == 200) {
    		signOut();
    		$state.addClass('success');
	        $state.html('<?php echo $wo['lang']['welcome_back'] ?>');
			$this.find('.add_wow_loader').removeClass('btn-loading');
	        setTimeout(function () {
	        	window.location.href = data.location;
	        }, 1000);
    	}
    	else{
			$this.find('button').attr("disabled", false);
			$this.find('.add_wow_loader').removeClass('btn-loading');
	        $state.html(data.message);
    	}
    });
}
<?php endif; ?>

$(function() {
  $('#login').ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=login',
    beforeSend: function() {
		working = true;
		$this.find('button').attr("disabled", true);
		$this.find('.add_wow_loader').addClass('btn-loading');
    },
    success: function(data) {
      if (data.status == 200 || data.status == 600) {
      	$state.addClass('success');
        $state.html('<?php echo $wo['lang']['welcome_back'] ?>');
		$this.find('.add_wow_loader').removeClass('btn-loading');
        setTimeout(function () {
        	window.location.href = data.location;
        }, 1000);
      } else {
        var errors = data.errors.join("<br>");
		$this.find('button').attr("disabled", false);
		$this.find('.add_wow_loader').removeClass('btn-loading');
        $state.html(errors);
      } 
      working = false;
    }
  });
});
</script>