<section id="register-section" class="register-section sec-ptb-100 bg-offwhite clearfix">
<div class="container">
<script>

		$(document).ready(function(){
$(".form-control").val("");
	//\\alert("asdf");
	
	$("#resend_otp").click(function(e){e.preventDefault();
		var mob=$(this).attr("href");
		$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>home/ajax_resend_otp',
			 data: {mob:mob},
			 success: function(res){
				 alert("OTP Sent Again");
				//$(".otp_error").html(res);
			 }
		});
	});
	$("#verify_otp").submit(function(e){e.preventDefault();
		//var plid=$("#plid").val();
		$("#verify_otp1").html('<i class="fa fa-spin fa-spinner"></i> Loading..',true);
		var formdata=$(this).serialize();
		$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>home/ajax_verify_otp',
			 data: {formdata:formdata},
			 success: function(res){//alert(res);return false;
			 	 $("#verify_otp1").html('Verify OTP');
				 if(res==1){
					$("#verify_otp").after("<br/><h3>Your Registration is Successful. Your Account is pending for Company Approval. You can download our App to start trading.</h3><a href='#' target='_blank' class='btn btn-warning'><i class='fa fa fa-android'></i> Download Android App</a>"); 
					$("#verify_otp").hide();
					//$("#verify_otp1").html("<h3>Your Account is pending for Company Approval</h3>");
					//window.setTimeout(function () {
					//	window.location.href = "<?php //echo base_url();?>home/dashboard";
					//}, 2000);
				 }else{
					$(".otp_error").html(res);
				 }
			 }
			 });
	});
	$("#signupform").submit(function(e){e.preventDefault();
		var formdata=$(this).serialize();
		//alert(formdata);//return false;
		$(".reg_error").hide();
		$(".reg_error").html("");
		if($("#pass").val()!=$("#cpass").val()){
		$(".reg_error").show();
		$(".reg_error").html("Your Both Passwords Doesnot Match.<br/>");return false;
		}
		if($("#pass").val().length<6){
		$(".reg_error").show();
		$(".reg_error").html("Make Sure Your Password is of 6 Character long.<br/>");return false;		
		}
		var phone=$("#phone").val();
		if(phone.length!=10 || !$.isNumeric(phone)){
		$(".reg_error").show();
		$(".reg_error").html("Please Enter a Valid 10 digit Phone Number.<br/>");return false;	
		}
		$("#submitbtn").attr("disabled",true);
		$("#submitbtn").html('<i class="fa fa-spin fa-spinner"></i> Loading..',true);
		
		$.ajax({
			url: "<?php echo base_url();?>home/ajax_signup", // Url to which the request is send
			type: "POST",             // Type of request to be send, called as method
			data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
			contentType: false,       // The content type used when sending data to the server.
			cache: false,             // To unable request pages to be cached
			processData:false,        // To send DOMDocument or non processed data file it is set to false
			success: function(res)   // A function to be called if request succeeds
			{
				// alert(res);
				 //return false;
				// console.log(res);return false;
				 if(res==0){
					 $(".error").html("Email id is Already Registered<br/>");
				 }else if(res==1){
					  $(".error").html("Phone Number is Already Registered<br/>");
				 }else if(res==2){
					  $(".error").html("Invalid Referral Id.<br/>");
				 }else{
					$("#resend_otp").attr("href",res);
					$("#signupform").hide(); 
					$("#verify_otp").show(); 
				 }
				 $("#submitbtn").removeAttr("disabled");
				 $("#submitbtn").html('Register');
			}
		});
	});

			$("#showforgotform").click(function(){

				$("#loginform").hide();

				$("#forgotform").show();

			});

			$("#showloginform").click(function(){

				$("#loginform").show();

				$("#forgotform").hide();

			});

			$("#forgotform").submit(function(e){e.preventDefault();

				var formdata=$(this).serialize();

				$.ajax({

					 type: "POST",

					 url: '<?php echo base_url();?>home/ajax_reset_otp',

					 data: {formdata:formdata},

					 success: function(res){

						 if(res==0){

							$("#forgotform").hide();

							$("#forgotform_votp").show(); 

						 }else{

						 	alert(res);

						 }

						//alert("OTP Sent To Your Mobile Number");

						//$(".otp_error").html(res);

					 }

				});

			});

			$("#forgotform_votp").submit(function(e){e.preventDefault();

				var formdata=$(this).serialize();

				$.ajax({

					 type: "POST",

					 url: '<?php echo base_url();?>home/ajax_reset_otp2',

					 data: {formdata:formdata},

					 success: function(res){

						 if(res==0){

							alert("Your Password Reset Successfully."); 

							$("#loginform").show();

							$("#forgotform_votp").hide();

							//window.location.href = "<?php //echo base_url();?>home/dashboard";

						 }else{

						alert(res);

						 }

	//					 alert("OTP Sent To Your Mobile Number");

						//$(".otp_error").html(res);

					 }

				});

			});

		$("#loginform").submit(function(e){e.preventDefault();

			var formdata=$(this).serialize();
			//alert(formdata);

			$.ajax({

			type: "POST",

			url: '<?php echo base_url();?>home/ajax_login',

			data: {formdata:formdata},

			success: function(res){//alert(res);

				if(res==1){

					$(".login-success").show(); 

					$(".login-error").hide();

					window.setTimeout(function () {

						window.location.href = "<?php echo base_url();?>home/dashboard";

					}, 3000);

				}else{

					$(".login-error").show();

					$(".login-success").hide(); 

				}

			}

			});

			});	

		});

		</script>
<div class="row justify-content-lg-center justify-content-md-center">
<div class="col-lg-6 col-md-6">
<div class="login-form">
<h3 class="title-medium mb-15">Login to Your Account</h3>
 <div class="alert alert-success login-success" style="display:none;"><i class="fa fa-spin fa-spinner"></i> Login Success. Redirecting You to Dashboard.</div>
                    <div class="alert alert-danger login-error" style="display:none;">Your Login Details are Invalid.</div>
                    
                    <form autocomplete="off" action="" method="post" id="forgotform"   style="display:none;">

                        <div class="form-group">

                            <label>Enter Registered Mobile Number</label>

                            <input class="form-control" value="" required name="mobile" id="fmobile_field" type="text">

                        </div>

                        <button type="submit" class="btn btn-warning">Get OTP</button>

                        <button type="button" class="btn btn-default float-right" id="showloginform">Back to Login</button>

                    </form>
                    
                    
                                            <form  autocomplete="off" action="#" method="post" id="loginform">
<div class="row">
<div class="col-lg-6 col-md-6 col-md-12">
<div class="input-item">
<input type="text" placeholder="Mobile" value="" name="mobile" required>
<label><i class="fa fa-mobile"></i></label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-md-12">
<div class="input-item">
<input type="password" placeholder="Password" value="" name="password" required>
<label><i class="ion-locked"></i></label>
</div>
</div>
<div class="col-lg-12 col-md-12 col-md-12">
<button type="submit" class="btn btn-warning waves-effect waves-light">
Log In
</button>
<button type="button" id="showforgotform" class="btn btn-danger waves-effect waves-light float-right">
Forgot password?
</button>
                                                   
</div>
</div>
</form>
</div>
</div>
</div>


<div class="signup-form">
<div class="row">
<!--<div class="col-lg-6 col-md-12 col-sm-12">
<div class="signup-image">
<img src="assets/images/signup-img.jpg" alt="image_not_found">
</div>
</div>-->
<div class="col-lg-12 col-md-12 col-sm-12">
<h3 class="title-medium clr-white mb-30">Sign Up With a new account</h3>
<form action="" method="post" id="signupform"  autocomplete="off" enctype="multipart/form-data">
                            <div class="row">
                                <div class="col-xl-6 col-lg-6 col-md-6">
                                    <h4 class="sub-title">Personal Information</h4>
                                    <input type="text" value=""  autocomplete="false" required name="name" placeholder="Full Name*">
                                    <input type="email" value=""  autocomplete="false" required name="email" placeholder="Email*">
                                    <input type="text" value=""  required name="phone" id="phone" placeholder="Mobile*">
                                    <div class="row">
                                    	<div class="col-md-6">
                                    		<input type="password" value=""  name="password"  id="pass" required placeholder="Create Password*">
                                        </div>
                                        <div class="col-md-6">
                                    		<input type="password" value=""  name="cpassword"  id="cpass" required placeholder="Confirm Password*">
                                        </div>
                                    </div>
                                    <div class="row">
                                    	<div class="col-md-6">
                                    		<input type="text" value=""  name="city"  required placeholder="City*">
                                        </div>
                                        <div class="col-md-6">
                                    		<input type="text" value=""  name="pincode" required placeholder="Pincode*">
                                        </div>
                                    </div>
                                </div>
                                <style>label{color:#fff;}</style>
                                <div class="col-xl-6 col-lg-6 col-md-6 additional-info">
                                    <h4 class="sub-title">KYC Details</h4>
                                    <input type="text" required value=""  name="aadhar"  placeholder="Aadhar No*">
                                    <input type="text" required value=""  name="pan_no" placeholder="PAN No*">
                                    <div class="row">
                                    <div class="form-group col-md-6">
                                        <label>Upload Aadhar Front</label>
                                        <input type="file"  class="form-control" name="aadhar_doc">
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label>Upload Aadhar Back</label>
                                        <input type="file" class="form-control"  name="aadhar_doc2">
                                    </div>
                                    </div>
                                    <div class="form-group">
                                        <label>Upload PAN ID</label>
                                        <input type="file"  class="form-control" name="pan_doc">
                                    </div>
                                </div>
                            </div>
                            <!--<div class="term-condition">
                                <h4 class="title">Terms and Conditions</h4>
                                <p>
                                    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                                    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat ipsum dolor sit
                                    amet, consectetur adipiscing elit, sed do eiusmod tempor.
                                    <br>
                                    <br>
                                    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                                    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat ipsum dolor sit
                                    amet, consectetur adipiscing elit, sed do eiusmod tempor.
                                </p>
                            </div>-->
                            <div class="row">
                                <div class="col-xl-6 col-lg-6">
                                    <div class="form-check">
                        <input required  type="checkbox" name="exampleRadios" id="exampleRadios5" value="option2">
                        <label  for="exampleRadios5">
                            I agree to the terms &amp; conditions.
                        </label>
                        <p>(*) We will never share your personal information with third parties.</p>
                                    </div>
                                </div>
                                <div class="col-xl-6 col-lg-6">
                                	
                                        <div class="alert alert-danger reg_error" style="display:none;"></div>
                                    <button class="btn btn-warning" id="submitbtn" type="submit">Create Account <i class="fa fa-user"></i></button>
                                </div>
                            </div>
                        </form>
                        <form action="#" method="post" id="verify_otp" style="display:none;">
                                <div class="row">
                                    <div class="form-group col-md-4 offset-md-4">
                                    <div class="text-center">
                                    <p class="text-warning">Verify 6 Digit OTP sent to Your Mobile & Email</p>
                                        <i class="fa fa-mobile fa-5x text-warning"></i><hr/>
                    <input type="text" class="form-control" required name="otp" placeholder="6 Digit Code" style="text-align:center;" />
                                        <p class="text-danger otp_error"></p>
                                        </div>
                                        <button type="submit" id="verify_otp1" class="btn btn-warning">Verify OTP</button> 
                                        <button type="submit" id="resend_otp" class="btn btn-default float-right">Resend OTP</button> 
                                    </div>
                                </div>
                            </form>
</div>
</div>
</div>

</div>
</section>