<!DOCTYPE html>
<html>
	<head>

		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>CREW | Dashboard</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<meta name="csrf_token" content="{{ csrf_token() }}" />
		<!-- Bootstrap 3.3.6 -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/bootstrap/css/bootstrap.min.css')}}">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
		<!-- Ionicons -->
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/dist/css/AdminLTE.min.css')}}">
		<!-- AdminLTE Skins. Choose a skin from the css/skins
		folder instead of downloading all of them to reduce the load. -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/dist/css/skins/_all-skins.min.css')}}">
		<!-- iCheck -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/plugins/iCheck/flat/blue.css')}}">
		<!-- Date Picker -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/plugins/datepicker/datepicker3.css')}}">
		<!-- Daterange picker -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/plugins/daterangepicker/daterangepicker.css')}}">
		<!-- bootstrap wysihtml5 - text editor -->
		<link rel="stylesheet" href="{{asset('/public/bower_components/AdminLTE/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css')}}">
		<!-- Select2 -->
		<link href="{{asset('/public/bower_components/AdminLTE/plugins/select2/select2.min.css')}}" rel="stylesheet" />
		<link href="{{asset('/public/designer/css/build.css')}}" rel="stylesheet">
		<!-- HTML5 Shim and Respond.js 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.3/html5shiv.min.js"></script>
		<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
		<![endif]-->
		
		<style>
			.skin-black-light .wrapper, .skin-black-light .main-sidebar, .skin-black-light .left-side{
				background-color: #222d32;
			}

			.skin-black-light .sidebar-menu>li:hover>a, 	.skin-black-light .sidebar-menu>li.active>a{
				color: #fff;
				background: #1e282c;
				border-left-color: #fff;
			}
			.skin-black-light .sidebar-menu>li.header{
				color: #4b646f;
    			background: #1a2226;
			}
			.skin-black-light .sidebar a{
				 color: rgb(184, 199, 206);
			}
			.skin-black-light .user-panel>.info, .skin-black-light .user-panel>.info>a {
				color: #fff;
			}
			.skin-black-light .sidebar-menu>li>.treeview-menu{
				margin: 0 1px;
    			background: #2c3b41;
			}
			.skin-black-light .treeview-menu>li.active>a, .skin-black-light .treeview-menu>li>a:hover{
				color: #fff;
			}
			.skin-black .treeview-menu>li>a{
			    color: #8aa4af;
			}
			.box.box-custom-color{
				border-top-color: #222d32;
			}

			.carousel-inner>.item>a>img, .carousel-inner>.item>img, .img-responsive, .thumbnail a>img, .thumbnail>img, .product-center{
				margin: auto;
			}
			.sports-border{
				border:1px solid #e2e2e2;
				padding: 5px;
				margin-bottom:20px;
			}
			.sport-edit-btn{
				margin-top:5px;
			}
			
			#prev-img{
				height: 300px;
				width: 300px;
				overflow:hidden;
				object-fit: contain;
				border: 1px solid #e2e2e2;
				padding: 2px;

			}

			/* #prev-img{
				height: 300px;
				width: 300px;
				overflow:hidden;
				object-fit: contain;
				border: 1px solid #e2e2e2;
				padding: 2px;

			} */

			#prev-print-template{
				height: 300px;
				width: 600px;
				overflow:hidden;
				object-fit: contain;
				border: 1px solid #e2e2e2;
				padding: 2px;
			}
			
			#label-suggest-upload{
				color: red;
			}

			/* for add template step by step design*/
			.wizard {
			    margin: 20px auto;
			    background: #fff;
			    margin-top: -38px;
			}

		    .wizard .nav-tabs {
		        position: relative;
		        margin: 40px auto;
		        margin-bottom: 0;
		        border-bottom-color: #e0e0e0;
		    }

		    .wizard > div.wizard-inner {
		        position: relative;
		    }

			.connecting-line {
			    height: 2px;
			    background: #e0e0e0;
			    position: absolute;
			    width: 65%;
			    margin: 0 auto;
			    left: 0;
			    right: 0;
			    top: 50%;
			    z-index: 1;
			}

			.wizard .nav-tabs > li.active > a, .wizard .nav-tabs > li.active > a:hover, .wizard .nav-tabs > li.active > a:focus {
			    color: #555555;
			    cursor: default;
			    border: 0;
			    border-bottom-color: transparent;
			}

			span.round-tab {
			    width: 70px;
			    height: 70px;
			    line-height: 70px;
			    display: inline-block;
			    border-radius: 100px;
			    background: #fff;
			    border: 2px solid #e0e0e0;
			    z-index: 2;
			    position: absolute;
			    left: 0;
			    text-align: center;
			    font-size: 25px;
			}
			span.round-tab i{
			    color:#555555;
			}
			.wizard li.active span.round-tab {
			    background: #fff;
			    border: 2px solid #5bc0de;
			    
			}
			.wizard li.active span.round-tab i{
			    color: #5bc0de;
			}

			span.round-tab:hover {
			    color: #333;
			    border: 2px solid #333;
			}

			.wizard .nav-tabs > li {
			    width: 33.33333333333333%;
			}

			.wizard li:after {
			    content: " ";
			    position: absolute;
			    left: 46%;
			    opacity: 0;
			    margin: 0 auto;
			    bottom: 0px;
			    border: 5px solid transparent;
			    border-bottom-color: #5bc0de;
			    transition: 0.1s ease-in-out;
			}

			.wizard li.active:after {
			    content: " ";
			    position: absolute;
			    left: 46%;
			    opacity: 1;
			    margin: 0 auto;
			    bottom: 0px;
			    border: 10px solid transparent;
			    border-bottom-color: #5bc0de;
			}

			.wizard .nav-tabs > li a {
			    width: 70px;
			    height: 70px;
			    margin: 20px auto;
			    border-radius: 100%;
			    padding: 0;
			}

		    .wizard .nav-tabs > li a:hover {
		        background: transparent;
		    }

			.wizard .tab-pane {
			    position: relative;
			    padding-top: 20px;
			}

			.wizard h3 {
			    margin-top: 0;
			}

			@media( max-width : 585px ) {

			    .wizard {
			        width: 90%;
			        height: auto !important;
			    }

			    span.round-tab {
			        font-size: 16px;
			        width: 50px;
			        height: 50px;
			        line-height: 50px;
			    }

			    .wizard .nav-tabs > li a {
			        width: 50px;
			        height: 50px;
			        line-height: 50px;
			    }

			    .wizard li.active:after {
			        content: " ";
			        position: absolute;
			        left: 35%;
			    }
			}
			/*end*/

			.custom-panel-footer.panel-footer{
				padding: 2px 2px;
			}
			.custom-panel-body.panel-body{
				padding: 10px;
			}
			.obj-container{
				height:254px; 
				width:100%; 
				margin:auto;
			}


			/*add pattern Select custom css*/
			.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{

				border-radius: 0;
				border-color: #d2d6de;
			}

			.select2-container--default .select2-selection--multiple{
				border-radius: 0;
				border-color: #d2d6de;
			}

			.select2-container--default.select2-container--focus .select2-selection--multiple{
				border-color: #d2d6de;
			}

			.select2-container--default .select2-selection--multiple .select2-selection__choice{
				background-color: #3c8dbc;
				border: 1px solid #3c8dbc;
			    border-radius: 2px;
			    cursor: default;
			    float: left;
			    margin-right: 5px;
			    margin-top: 5px;
			    padding: 0 5;
			}

			.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{

			    color: #c5c5c5;
			    margin-right: 5px;
			}
			/*end add pattern Select custom css*/

			#template-img-preview{
				height: 300px;
				width: 300px;
				overflow:hidden;
				object-fit: contain;
				border: 1px solid #e2e2e2;
				padding: 2px;

			}

			/*listview*/
			div.list-group-item {
			    height:auto;
			    min-height:190px;
			}
			
			div.list-group-item.active small {
			    color:#fff;
			}
			.stars {
			    margin:20px auto 1px;    
			}

			/*.img-print-preview{
				min-height: 250px;
				height: 250px;
				width: 350px;
			}*/

			#homepage-logo{
				margin-top: 120px;
			}

			.no-record{
				color: #bbbbbb;
			}

			.btn-custom-save{
				width : 150px;
			}
			.error{
				color : #F44336;
			}
			
			.custom-box-body{
				min-height: 400px;
			}
			
			.thumbnail>img {
				height: 187px;
			}		
		</style>

	</head>

	<body id="bodyId_" class="sidebar-mini wysihtml5-supported skin-black">
		<div class="wrapper">

            <!-- Header -->
            @include('user-layouts.header')

            <!-- Sidebar -->
            @include('user-layouts.sidebar')
				
	    		<!-- Content Wrapper. Contains page content -->
				@yield('content')

			<!-- Footer -->
			@include('user-layouts.footer')
		</div>
		<!-- ./wrapper -->

		<!-- jQuery 2.2.3 -->
		<script src="{{asset('/public/bower_components/AdminLTE/plugins/jQuery/jquery-2.2.3.min.js')}}"></script>
		<!-- jQuery UI 1.11.4 -->
		<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
		<!-- Bootstrap 3.3.6 -->
		<script src="{{asset('/public/bower_components/AdminLTE/bootstrap/js/bootstrap.min.js')}}"></script>

		<!-- daterangepicker -->
		<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
		<script src="{{asset('/public/bower_components/AdminLTE/plugins/daterangepicker/daterangepicker.js')}}"></script>
		<!-- datepicker -->
		<script src="{{asset('/public/bower_components/AdminLTE/plugins/datepicker/bootstrap-datepicker.js')}}"></script>
		<!-- Bootstrap WYSIHTML5 -->
		<script src="{{asset('/public/bower_components/AdminLTE/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js')}}"></script>
		<!-- Slimscroll -->
		<script src="{{asset('/public/bower_components/AdminLTE/plugins/slimScroll/jquery.slimscroll.min.js')}}"></script>
		<!-- FastClick -->
		<script src="{{asset('/public/bower_components/AdminLTE/plugins/fastclick/fastclick.js')}}"></script>
		<!-- AdminLTE App -->
		<script src="{{asset('/public/bower_components/AdminLTE/dist/js/app.min.js')}}"></script>
		<!-- AdminLTE dashboard demo (This is only for demo purposes)
	    <script src="{{asset('/bower_components/AdminLTE/dist/js/pages/dashboard.js')}}"></script>-->
		<!-- AdminLTE for demo purposes -->
		<script src="{{asset('/public/bower_components/AdminLTE/dist/js/demo.js')}}"></script>

		<!-- Select2 -->
		<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
		<!-- validate jquery -->
		<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
		<!-- \priceformat -->
		<script src="{{asset('/public/designer/js/jquery.priceformat.min.js')}}"></script>
		<script>
			$( document ).ready(function() {
				$('.price_format').priceFormat({
					prefix: '$ '
				});

				resend_timer();
				
				$.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) {         
					var states = [];
					
					for(i = 0 ; i < data.length ; i++){
						states.push(data[i]['state']);	
					}
					var uniqueStates = Array.from(new Set(states));
					// console.log(uniqueItems.sort())
					var selectedState = $('#lst-states').data('selected');
					uniqueStates.sort().forEach(function(key) {
						if(selectedState == key){
							$('#lst-states').append('<option value="'+key+'" selected>'+ key + '</option>');
							// 
							var cities = [];
							for(i = 0 ; i < data.length ; i++){
								cities.push(data[i]);
							}
							var city = getCities(cities, key);
							var uniqueCities = Array.from(new Set(city));
							var selectedCity = $('#lst-cities').data('selected');
							$('.dynamic-city').remove();
							uniqueCities.sort().forEach(function(key) {
								if(selectedCity == key){
									$('#lst-cities').append('<option value="'+key+'" class="dynamic-city" selected>'+ key + '</option>');
								}else{
									$('#lst-cities').append('<option value="'+key+'" class="dynamic-city">'+ key + '</option>');
								}
								
							});

						}else{
							$('#lst-states').append('<option value="'+key+'">'+ key + '</option>');
						}
					});

					

					$(document).on('select change', '#lst-states', function(){
						var cities = [];
						for(i = 0 ; i < data.length ; i++){
							cities.push(data[i]);
						}
						var city = getCities(cities, $(this).val());
						var uniqueCities = Array.from(new Set(city));
						$('.dynamic-city').remove();
						uniqueCities.sort().forEach(function(key) {
							
							$('#lst-cities').append('<option value="'+key+'" class="dynamic-city">'+ key + '</option>');
						});
					});
	
				});
				
				$("#frm-create-address-book").validate({
					rules: {
						fullname: {
							required: true
						},
						mobilenumber: {
							required: true
						},
						address: {
							required: true
						},
						state: {
							required: true
						},
						city: {
							required: true
						},
						zipcode: {
							required: true
						}
					},
					messages: {},
						errorPlacement: function(error, element) {
						var placement = $(element).data('error');
						
						if (placement) {
							
							$(placement).append(error)
						
						}else {
						
							error.insertAfter(element);
						
						}
						},
					submitHandler: submitFormCreateAddressBook
				});

				$("#frm-edit-address-book").validate({
					rules: {
						fullname: {
							required: true
						},
						mobilenumber: {
							required: true
						},
						address: {
							required: true
						},
						state: {
							required: true
						},
						city: {
							required: true
						},
						zipcode: {
							required: true
						}
					},
					messages: {},
						errorPlacement: function(error, element) {
						var placement = $(element).data('error');
						
						if (placement) {
							
							$(placement).append(error)
						
						}else {
						
							error.insertAfter(element);
						
						}
						},
					submitHandler: submitFormEditAddressBook
				});

				$("#frm-edit-profile").validate({
					rules: {
						fullname: {
							required: true
						},
						contactnumber: {
							required: true,
							number: true
						},
						email: {
							required: true,
							email : true
						},
						birthday: {
							required: true
						},
						gender: {
							required: true
						}
					},
					messages: {},
						errorPlacement: function(error, element) {
						var placement = $(element).data('error');
						
						if (placement) {
							
							$(placement).append(error)
						
						}else {
						
							error.insertAfter(element);
						
						}
						},
					submitHandler: submitFormEditProfile
				});
				
				$('#datepicker_bday').datepicker({
					// calendarWeeks: true,
					// todayHighlight: true,
					autoclose: true
				});
				
				$("#frm-change-password").validate({
					rules: {
						current_password: {
							required: true
						},
						new_password: {
							required: true
						},
						con_new_password: {
							required: true
						}
					},
					messages: {},
						errorPlacement: function(error, element) {
						var placement = $(element).data('error');
						
						if (placement) {
							
							$(placement).append(error)
						
						}else {
						
							error.insertAfter(element);
						
						}
						},
					submitHandler: submitFormChangePassword
				});

				$("#frm-design-details").validate({
					rules: {
						design_name: {
							required: true
						},

						design_code:{
							require: true
						}
					},
					messages: {},
						errorPlacement: function(error, element) {
							var placement = $(element).data('error');
							
							if (placement) {
								
								$(placement).append(error)
							
							}else {
							
								error.insertAfter(element);
							
							}
						},
					submitHandler: submitFormDesignDetails
				});

				$("#frm-item-details").validate({
					rules: {
						item_url: {
							required: true
						},
						itemName: {
							required: true
						},
						itemDescription: {
							required: true
						},
						item_price: {
							required: true
						},
						item_privacy: {
							required: true
						}
						
					},
					messages: {},
						errorPlacement: function(error, element) {
							var placement = $(element).data('error');
							
							if (placement) {
								
								$(placement).append(error)
							
							}else {
							
								error.insertAfter(element);
							
							}
						},
					submitHandler: submitFormItemDetails
				});

				$("#frm_verification_code").validate({
					rules: {
						verification_code: {
							required: true
						}
						
					},
					messages: {},
						errorPlacement: function(error, element) {
							var placement = $(element).data('error');
							
							if (placement) {
								
								$(placement).append(error)
							
							}else {
							
								error.insertAfter(element);
							
							}
						},
					submitHandler: submitFormVerificationCode
				});

				$(document).on('button click', '#chk-currentpass', function(){
					
					if($(this).is(':checked')){
						$('#current_password').attr('type', 'text');
					}else{
						$('#current_password').attr('type', 'password');
					}
				});

				$(document).on('button click', '#chk-newpass', function(){
					
					if($(this).is(':checked')){
						$('#new_password').attr('type', 'text');
					}else{
						$('#new_password').attr('type', 'password');
					}
				});

				$(document).on('button click', '#chk-con-newpass', function(){
					
					if($(this).is(':checked')){
						$('#con_new_password').attr('type', 'text');
					}else{
						$('#con_new_password').attr('type', 'password');
					}
				});

				
				$(document).on('a click', '#btn_resend_code', function(){
					
					var email = $(this).data("email");
					
					$.ajax({
						type : 'POST',
						url  : "{{ url('user/post/resend-verification') }}",
						data : {
							email : email
						},
						beforeSend:function(xhr){
							$('#btn_resend_code').attr('disabled', true);
							$('#btn_resend_code').append(' <i class="fa fa-circle-o-notch fa-spin"></i>');
							
							var token = $('meta[name="csrf_token"]').attr('content');

								if (token) {
									return xhr.setRequestHeader('X-CSRF-TOKEN', token);
								}
								xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
						},
						success :  function(response){

							if(response){
								alert("Verification code is successfully sent.");
								
								$('#btn_resend_code').html('<i class="fa fa-angle-double-right"></i> Resend Code <span class="badge" id="resend_countdown"></span>');

								var settime = 120;
								localStorage.setItem('timerRunning', 'true');
								localStorage.setItem('timeleft', settime);
								var getTimeleft = parseInt(localStorage.getItem('timeleft'));


								var getTimeleft = parseInt(localStorage.getItem('timeleft'));
								var downloadTimer = setInterval(function(){
									$('#resend_countdown').html(getTimeleft);
									
									var timeleft = getTimeleft -= 1;
									localStorage.setItem('timeleft', timeleft);

										if(timeleft <= 0){
											clearInterval(downloadTimer);
											$('#resend_countdown').html('');
											localStorage.setItem('timerRunning', 'false');
											$('#btn_resend_code').attr('disabled', false);
											
										}
								}, 1000);

							}else{
								alert("Something went wrong, Please try again.");
								location.reload();
							}
						}
					});

				});


				

				$('.image-thumbnails').click(function(){
                    // console.log($(this)[0].firstElementChild.geAttribute('class'))
                    // console.log($(this).attr('src'))
                    $('#main-thumbnail').attr('src', $(this).attr('src'));
                    
                    $('.a_thumbnail').removeClass('active');
                    $(this).parent().addClass('active');
				});
				
				$(document).on('button click', '#btn-reload-thumbnails', function(){
					
					$(this).attr('disabled', 'disabled');
					$('.thumb-content').html('Please wait..');
					var ip = "116.93.97.200";
					var port = $(this).data('port');
					var url = "http://"+ip+":"+port+"/forceload/"+ $(this).data('dd');
					// console.log(url);
					$.ajax({    //create an ajax request to load_page.php
						type: "GET",
						url: "http://"+ip+":"+port+"/forceload/"+ $(this).data('dd'),
						dataType: "json",   //expect html to be returned
						beforeSend: function() {
							console.log('loading images');
						},
						success: function(response){
							if(response['status'] == "success"){
								location.reload();
							}else{
								alert("Error: failed to reload the thumbnail. Please try again");
								location.reload();
							}
						}
					});
					
					
				});
			});

			// function 
			function getCities(arr, q){
				var sd = [];
				arr.find(function(element) {
					if(element['state']  == q){
						sd.push(element['city']);
					}
				});
				return sd;
			}

			function submitFormCreateAddressBook(){
				var data = $("#frm-create-address-book").serialize();
				$.ajax({
					type : 'POST',
					url  : "{{ url('user/address-book/save') }}",
					data : data,
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){ 
						// console.log(response);
						if(response){
							alert("Address is successfully added.");
							window.location = "{{ url('user/address-book') }}";
						}else{
							alert("Something went wrong. Please try again!");
							location.reload();
						}
					}
				});
				return false;
			}

			function submitFormEditAddressBook(){
				var data = $("#frm-edit-address-book").serialize();
				// console.log(data);
				$.ajax({
					type : 'POST',
					url  : "{{ url('user/address-book/update') }}",
					data : data,
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){ 
						// console.log(response);
						if(response){
							alert("Address is successfully updated.");
							window.location = "{{ url('user/address-book') }}";
						}else{
							alert("Something went wrong. Please try again!");
							location.reload();
						}
					}
				});
				return false;
			}

			function submitFormEditProfile(){
				var data = $("#frm-edit-profile").serialize();
				// console.log(data);
				$.ajax({
					type : 'POST',
					url  : "{{ url('user/profile/update') }}",
					data : data,
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){ 
						// console.log(response);
						if(response){
							alert("Your profile is successfully updated.");
							window.location = "{{ url('user/profile') }}";
						}else{
							alert("Something went wrong. Please try again!");
							location.reload();
						}
					}
				});
				return false;
			}

			function submitFormChangePassword(){
				var data = $("#frm-change-password").serialize();
				// console.log(data);
				$.ajax({
					type : 'POST',
					url  : "{{ url('user/profile/update-password') }}",
					data : data,
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){ 
						// console.log(response);
						if(response){
							if (response != 1){
								alert(response);
								// window.location = "{{ url('user/profile/change-password') }}";
							}else{
								
								alert("Your password is successfully updated.");
								window.location = "{{ url('user/profile') }}";
							}
							
						}else{
							alert("Something went wrong. Please try again!");
							location.reload();
						}
					}
				});
				return false;
			}

			function submitFormDesignDetails(){
				var data = $("#frm-design-details").serialize();
				// console.log(data);
				$.ajax({
					type : 'POST',
					url  : "{{ url('user/my-designs/update') }}",
					data : data,
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){ 
						// console.log(response);
						if(response){
							alert('Design details is successfully updated.');
							location.reload();	
						}else{
							alert("Something went wrong. Please try again!");
							location.reload();
						}
					}
				});
				return false;
			}


			function submitFormItemDetails(){
				var data = $("#frm-item-details").serialize();
				
				$.ajax({
					type : 'POST',
					url  : "{{ url('user/store-items/update') }}",
					data : data,
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){ 
						// console.log(response);
						if(response){
							alert('Item details is successfully updated.');
							location.reload();	
						}else{
							alert("Something went wrong. Please try again!");
							location.reload();
						}
					}
				});
				return false;
			}		

			function submitFormVerificationCode(){
				var data = $("#frm_verification_code").serialize();

				$.ajax({
					type : 'POST',
					url  : "{{ url('user/post/verify-code') }}",
					data : data,
					dataType: 'json',
					beforeSend:function(xhr){
						var token = $('meta[name="csrf_token"]').attr('content');

							if (token) {
								return xhr.setRequestHeader('X-CSRF-TOKEN', token);
							}
							xhr.setRequestHeader( 'X-Requested-With',  'XMLHttpRequest');
					},
					success :  function(response){
						// console.log(response);
						if(response.success){
							alert(response.message);
							window.location = "{{ url('user/profile') }} ";	
						}else{
							alert(response.message);
							location.reload();
						}
					}
				});
				return false;
			}		

			function resend_timer(){
				var settime = 129;
				var getTimeStatus = localStorage.getItem('timerRunning');

				if(getTimeStatus == 'true'){
					
					var getTimeleft = parseInt(localStorage.getItem('timeleft'));
					var downloadTimer = setInterval(function(){
					$('#resend_countdown').html(getTimeleft);
					
					var timeleft = getTimeleft -= 1;
					localStorage.setItem('timeleft', timeleft);

						if(timeleft <= 0){
							clearInterval(downloadTimer);
							$('#resend_countdown').html('');
							localStorage.setItem('timerRunning', 'false');
							$('#btn_resend_code').attr('disabled', false);
							
						}else{
							$('#btn_resend_code').attr('disabled', true);
						}
					}, 1000);
				}
			}
				
		</script>

	</body>
</html>
