<div class="_hedForm">
	Verify Your Email
</div>

<div class="_bodyForm">

	<div class="_message">
		JIG has sent a verification code to the following email, please check your inbox or spam
	</div>

	<form action="" method="post" id="loginAction">
	<div class="_inputDiv">
		<input name="email" id="email" title="Email" type="text" class="searchfield _inpForm" value="<?php echo $_GET['email'] ?>" autocomplete="off" readonly=""/>
	</div>
	<div class="_label">
		Enter Your Code :
	</div>
	<div class="_inputDiv">
		<input name="kode" id="kode" title="Code" type="text" class="searchfieldCode _inpFormCode" autocomplete="off" alt="cep"/>
	</div>
	<div class="_label">
		<input type="submit" name="submit" id="submit" class="_btnLog" value="Verivication" />
		<span id="_proses"></span>
	</div>
	</form>
	
	
	<div style="margin-top: 25px; text-align: center;">
		<input type="button" name="button" id="_kirimLagi" style="border: none; background: none; min-width: 30px; color: #ffac5e" disabled=""/>
	</div>
	
	<div style="margin-top: 50px; text-align: center;">
		<a href="<?php echo $this->baseUrl.'login/daftar/' ?>">
			<img src="<?php echo $this->baseUrl.'assets/thema/apk2020/css/images/back2.png' ?>" style="width: 60px" title="Back">
		</a>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$('#kode').setMask();
	$('#kode').focus();
	_reg = false;
	$('#loginAction').submit(function(e){
		e.preventDefault();
		
		$('#email').removeAttr("style");
		
		_act = true;

		_email = $('#email').val();
		_email = _email.trim();
		if(_email === ''){
			$('#email').css("border", "1px solid red");
			$('#_proses').html('<span style="color: red">Email Invalid</span>');
			_act = false;
		}
		
		_cek = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_email);
		if (_cek == false){
			$('#email').css("border", "1px solid red");
			$('#_proses').html('<span style="color: red">Email Invalid</span>');
			_act = false;
		}
		
		if(_act === false){
			return;
		}
  
		$('#_proses').html('Proses Login....');
		if(_reg != false){
			_reg.abort();
		}
		_reg = $.ajax({
		type: 'POST',
			url: '<?php echo $this->baseUrl.'login/daftar5' ?>',
			data: $(this).serialize(),
			success: function(data) {
				$('#_proses').html(data);
			}
		})
	})


	function countDown(){
		var waktu = 21;
		var timer = setInterval(function() {
			waktu--;
			if(waktu < 0) {
				$('#_kirimLagi').removeAttr('disabled');
				$('#_kirimLagi').val('Ask for the code again');
				clearInterval(timer);
			}else{
				$('#_kirimLagi').val(waktu);
			}
		}, 1000);
	}
	countDown();

	$('#_kirimLagi').click(function(){
		_cek = $('#_kirimLagi').attr('disabled');
		if(_cek === undefined){
			$('#_kirimLagi').attr('disabled', true);
			countDown();
			if(_reg != false){
				_reg.abort();
			}
			_reg = $.ajax({
			type: 'POST',
				url: '<?php echo $this->baseUrl.'login/daftar4/&email='.$_GET['email'] ?>',
				data: $(this).serialize(),
				success: function(data) {
					$('#_proses').html(data);
				}
			})
		}
	})
})
</script>