<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>CREW Sportswear</title>

	<link href="{{ asset('public/css/app.css') }}" rel="stylesheet">

	<!-- Fonts -->
	<link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>

	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
	<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
        
	<link href="{{asset('public/assets/css/style.css')}}" rel="stylesheet">
	<!-- <link href="{{asset('public/assets/login/css/style.css')}}" rel="stylesheet">
	<link href="{{asset('public/assets/login/css/form-elements.css')}}" rel="stylesheet"> -->
	<script src='https://www.google.com/recaptcha/api.js'></script>
	<!-- Global site tag (gtag.js) - Google Analytics -->
	<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136108155-1"></script>
	<script>
		window.dataLayer = window.dataLayer || [];
		function gtag(){dataLayer.push(arguments);}
		gtag('js', new Date());

		gtag('config', 'UA-136108155-1');
	</script>
</head>
<body>
	<!-- <nav class="navbar navbar-default">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
					<span class="sr-only">Toggle Navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
			</div>

			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav">
					<li><a href="{{ url('/') }}"><i class="fa fa-angle-double-left"></i> Back</a></li>
				</ul>

				<ul class="nav navbar-nav navbar-right">
					@if (Auth::guest())
						<li><a href="{{ url('/auth/login') }}">Login</a></li>
						<li><a href="{{ url('/auth/register') }}">Register</a></li>
					@else
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ Auth::user()->username }} <span class="caret"></span></a>
							<ul class="dropdown-menu" role="menu">
								<li><a href="{{ url('user') }}">Dashboard</a></li>
								<li><a href="{{ url('/auth/logout') }}">Logout</a></li>
							</ul>
						</li>
					@endif
				</ul>
			</div>
		</div>
	</nav> -->
	@include('layout.navbar')
	@yield('content')
	<!-- Footer -->
	
	<!-- Scripts -->
	<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
	<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
	<script>
		$(document).ready(function(){
			$('.reveal-password').click(function(e){
				var $pwd = $(".pwd");
				if ($pwd.attr('type') === 'password') {
					$pwd.attr('type', 'text');
					$(this).html('<i class="fa fa-eye-slash"></i>');
				} else {
					$pwd.attr('type', 'password');
					$(this).html('<i class="fa fa-eye"></i>');
				}
			});

			if($('.data-errors').length > 0){
				$('#team-store-login').modal('show')
				return false;
			}

			$("#frm-login").validate({
				rules: {
					email: {
						required: true,
						email: true
					},
					password: {
						required: true
						//minlength: 6  // <-- removed underscore
					}
				},
				messages: {},
				errorPlacement: function(error, element) {
					var placement = $(element).data('error');
					if (placement) {
						$(placement).append(error);
					}else {
						error.insertAfter(element);
					}
				},
				submitHandler: submitLoginForm
			});

			$("#frm-register").validate({
				rules: {
					name: {
						required : true
					},
					username: {
						required : true
					},
					email: {
						required: true,
						email: true
					},
					password: {
						required: true
						//minlength: 6  // <-- removed underscore
					}
				},
				messages: {},
				errorPlacement: function(error, element) {
					var placement = $(element).data('error');
					if (placement) {
						$(placement).append(error);
					}else {
						error.insertAfter(element);
					}
				},
				submitHandler: submitRegisterForm
			});

			$('.password-protected').click(function(){

				$('#_teamstore_id').val($(this).data('store-id'))
				// console.log($(this).data('store-id'))
				$('#team-store-login').modal('show')
				return false;

			});

			$(document).on('change', '#select_sort_stores', function(event) {
				event.preventDefault();
				$('#frm_search_store').submit();
			});
                

		}); // end document ready

		function submitLoginForm (){
			// method="POST" action="{{ url('/auth/login') }}"
			var data = $("#frm-login").serialize();
			// console.log(data)
			$.ajax({
				type : 'POST',
				url  : "{{ url('/custom/auth') }}",
				data : data,
				dataType : 'json',
				beforeSend: function() { 
					$("#login-response-msg").fadeOut();
					$("#btn-login").html('Signing in &nbsp; <i class="fa fa-spinner fa-spin"></i>');
				},
				success :  function(response){ 
					$("#login-response-msg").html("");
					$("#login-response-msg").fadeIn(1000, function(){
						
						if(response.success){
							// $("#login-response-msg").html(response);
							// console.log();
							location.reload();
						}else{
							$("#login-response-msg").html(response.message);
						}
						//

						// console.log(response.success);
						$("#btn-login").html('<span class="glyphicon glyphicon-log-in"></span> &nbsp; Sign In');
					});
				}
			});
			return false;
		}/* login submit */

		function submitRegisterForm (){
			var data = $("#frm-register").serialize();

			$.ajax({
				type : 'POST',
				url  : "{{ url('/custom/register') }}",
				data : data,
				dataType : 'json',
				beforeSend: function() { 
					$("#register-response-msg").fadeOut();
					$("#btn-register").html('Please wait &nbsp; <i class="fa fa-spinner fa-spin"></i>');
				},
				success :  function(response){ 
					$("#register-response-msg").html("");
					$("#register-response-msg").fadeIn(1000, function(){
						
						if(response.success){
							location.reload();
						}else{
							$("#register-response-msg").html(response.message);
						}
						$("#btn-register").html('Register');
					});

					// console.log(response);
				}
			});
			return false;

		}

		
	</script>
</body>
</html>
