var OTP='';

//var timeLeft = 30;

/*************************************************************************************************/ 
function clear_msg()
{ 
    $("#loginform").validate().resetForm(); 
    $("#login_msg").html("");   
} 


function clear_msgRegi()
{ 
    $("#registrationform").validate().resetForm(); 
    $("#login_msg").html("");  
    $("#registration_msg").html("");   
} 

function setCookie(cvalue,exdays) 
{ 	
	cname = "loginCookies";
	var d = new Date();
	d.setTime(d.getTime() + (exdays*24*60*60*1000));
	var expires = "expires=" + d.toGMTString();
	document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
} 

function getCookie() 
{
  cname = "loginCookies";
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');        
  var ca1 = ca.toString();      
  var ca2 = ca1.split(',');       
  var set = 0;   
  for(var i = 0; i < ca2.length; i++) 
  { 
	  str = (ca2[i].trim());
	  ca3 = str.split('=');          
	  if(ca3[0]=="loginCookies") 
	  {
		  return ca3[1]; 
	  }    
  }  
} 

function removeCookie()
{
	$.ajax({	
	type: "POST",
	url: CarURL+"/login_logout.php", 
	data: {unset_login_cookies:1},
	beforeSend: function(){ 
	},
	success: function(data)
	{ 
		 						   
	}
  });
}  

$(document).ready(function()
{
    
    $("#registered_name_labeltest").hide();
    $("#registered_mob_labeltest").hide();
    $("#registered_id_labeltest").hide();  
    $("#registered_email_labeltest").hide();
    $("#registered_pwd_labeltest").hide();
    $("#registered_close_labeltest").hide();
     
     
     
    
    $.ajax({	
		type: "POST",
		url: CarURL+"/all-ajax/login-ajax.php",
		data: {unset_data:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
		    			
		}
	});
	  
	$("#login_modal").click( function(e)
	{ 					
	    var CurrentUrl= window.location.href;
		user=1;
		setCookie(user,30);
		url = CarURL+"/login/login-modals.php";
		$("#LoginModalLoad").load(url); 
		$("#login").modal({
			show: 'true',
			backdrop: 'static',
			keyboard:false
		});   		
		removeCookie(); 
		e.preventDefault();
		
    	$.ajax({	
    		type: "POST",
    		url: CarURL+"/all-ajax/login-ajax.php", 
    		data: {setgmail_loginVal:1,CurrentUrl:CurrentUrl},
    		beforeSend: function(){ 
    		},
    		success: function(data)
    		{ 
    									   
    		}
    	});
	});
	
	$("#registration_modal").click( function()
	{ 		        
		user=2;
		setCookie(user,30);
		url = CarURL+"/login/login-modals.php";
		$("#LoginModalLoad").load(url); 
		$("#login").modal({
			show: 'true',
			backdrop: 'static',
			keyboard:false
		});    		
		removeCookie(); 
	});

});


/************************************************************************************************/




$(document).ready(function()
{ 
    $("#entered_OTP_label").hide();
    $("#entered_opt_label").hide();
	$("#socialform").show();
	$("#reg_some_div").hide();
	$("#message").hide();
	$("#login_pwd").hide();  
	$("#show_pwd").hide();  
	$("#some_div").hide();  
	$("#password").hide(); 
	$("#password_label").hide(); 
	$("#submit_login").hide();
    $("#submit_reset").hide();	
	$("#submit_login_otp").hide(); 
	$("#entered_opt").hide(); 
	$("#submit_otp").hide();
    $("#entered_OTP").hide(); 
	$("#submit_OTP").hide();
    $("#resend_otp").hide();
	$("#login_terms").hide();
	$("#login_terms_condn").hide();
	$("#resend_reg_otp").hide();
	
	
	/************* login start    Js start**/
	
	$("#resend_otp").click(function(e)
	{
	   $("#resend_otp").hide();	   
	   
	   $.ajax({	
		type: "POST",
		url: CarURL+"/all-ajax/login-ajax.php",
		data: {check_resend_otp:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
		    if(data==3)
            {
            	$("#login_msg").html("Your today's OTP limit has been exceeded"); 
            	$("#resend_otp").hide();		
    			$("#some_div").hide();
            }
            else if(data==1) 
            {
    		    var timeLeft = 30;
                var elem = document.getElementById('some_div');
    			var timerId = setInterval(countdown1, 1000);
    		    function countdown1() {
    			  $("#resend_otp").hide();		
    			  $("#some_div").show();
    			  if (timeLeft == 0) {
    			   clearTimeout(timerId);
    			   $("#resend_otp").show();
    			   $("#some_div").hide();
    			  }
    			  else {				
    				elem.innerHTML = timeLeft + ' seconds remaining';
    				timeLeft--;	                				
    			  }			  
    			}	
            }
		}
	  }); 	
    });	
    
    $("#submit_otp").click(function(e) 
	{
		var otpReg = /^\d{4}$/; 
		if(!otpReg.test($("#entered_opt").val()))  
			$("#login_msg").html("Enter 4 digit number!!!");//alert("Enter 4 digit number!!!"); 
		else 
		{ 
	        $("#login_msg").html("");
			$.ajax({	
			type: "POST",
			url: CarURL+"/login_logout.php", 
			data: {checked_otp:1,entered_opt:$("#entered_opt").val()},
			beforeSend: function(){ 
			    $('#submit_otp').addClass('disableloginbtn');
			},
			success: function(data)
			{ 
			   $('#submit_otp').removeClass('disableloginbtn');     
			   if(data==1)
			   {
				   $('#login').modal('hide');
				   //window.location.href = URL;
				   location.reload();
			   }
			  else if(data==0)
			  {
				$("#login_msg").html("Wrong OTP!!! Please enter correct OTP");//alert("Wrong OTP!!! Please enter correct OTP"); 
				$("#entered_opt").val('');
			  }             		  
			}			
		  });  
		}
	});
  
	
	$("#show_pwd").click(function() {
		if($(this).hasClass('fa fa-eye-slash'))
		{           
			$(this).removeClass('fa fa-eye-slash');
			$(this).addClass('fa fa-eye');
			$('#password').attr('type','text');          
		}
		else
		{ 
		  $(this).removeClass('fa fa-eye');  
		  $(this).addClass('fa fa-eye-slash');  
          $('#password').attr('type','password');
		}
    });	
    
    $('#login_terms').click(function() 
    {
        if ($("#login_terms").is(':checked')) 
        {
            $("#login_msg").html("");
        }
    });
    
    
	$("#submit_login_otp").off().on('click',function(e) 
	{ 
	   clear_msg(); 
       var isChecked = $("#login_terms").is(":checked");
       if(isChecked)
  	   { 
  	       $("#login_msg").html("");
  	        $.ajax({	
    		type: "POST",
    		url: CarURL+"/all-ajax/login-ajax.php",
    		data: {check_loginotp_count:1,login_id:$("#login_id").val()},
    		beforeSend: function(){ 
    		    $('#submit_login_otp').addClass('disableloginbtn');
    		},
    		success: function(val)
    		{
    		    $('#submit_login_otp').removeClass('disableloginbtn');  
    		      if(val==3)
    		      {
    		        $("#login_msg").html("Your today's OTP limit has been exceeded");  
    		        $("#contineCheck").hide();
    		        $("#loginhead").show();
            		$("#login_id").show(); 
            		$("#login_id_label").show(); 
                    $("#login_pwd").show();
                    $("#show_pwd").show();
                    $("#password").show(); 
                    $("#password_label").show();
                    $("#login_terms").show(); 
                    $("#login_terms_condn").show();
                    $("#submit_login").show(); 
                    $("#submit_login_otp").show();
                    
            		$("#entered_opt").hide();    
            		$("#entered_opt_label").hide();
            		$("#some_div").hide();
            		$("#resend_otp").hide();
            		$("#submit_otp").hide();
            		
    		      }
          	      else if(val==1) 
          	      {
                  	    $('#submit_login_otp').addClass('disableloginbtn');  
                  	    $("#loginhead").hide();
                		$("#login_id").hide(); 
                		$("#login_id_label").hide(); 
                		$("#login_pwd").hide();
                		$("#show_pwd").hide();
                		$("#password").hide(); 
                		$("#password_label").hide();
                		$("#submit_login").hide();
                        $("#forgot_pass").hide();
                        $("#submit_pwd").hide();
                        $("#submit_reset").hide();			
                		$("#submit_login_otp").hide(); 
                		$("#entered_opt").show();    
                		$("#entered_opt_label").show();    
                		$("#submit_otp").show();
                		$("#some_div").show();
                		$("#resend_otp").hide();
                        $("#login_terms").hide();
                	    $("#login_terms_condn").hide();
                        $("#login_msg").html("");		
                		
                		var mobileno=$("#login_id").val();
                		
                		
                		$.ajax({	
                    		type: "POST",
                    		url: CarURL+"/custom_function/EmailConfigure.php",
                    		data: {check_login_otp:1,login_id:$("#login_id").val()},
                    		beforeSend: function(){ 
                    		    
                    		},
                    		success: function(data)
                    		{  
                    		    if(data>0)
                    		    $("#entered_opt_label").html("OTP sent to "+mobileno+" & Email id as well");
                    		    else
                    		    $("#entered_opt_label").html("OTP sent to "+mobileno+" ");
                    		    
                    		    $('#submit_login_otp').removeClass('disableloginbtn');
                    		    var timeLeft = 30;
                                var elem = document.getElementById('some_div');
                    			var timerId = setInterval(countdown, 1000);
                    		    function countdown() {
                    			  if (timeLeft == 0) {
                    			   clearTimeout(timerId);
                    			   $("#resend_otp").show();
                    			   $("#some_div").hide();
                    			  }
                    			  else {
                    				elem.innerHTML = timeLeft + ' seconds remaining';
                    				timeLeft--;
                    			  }
                    			}
                    		 }
                		  });
          	         }
    		    }
  	        });
        }
        else 
        {    
          clear_msg();        
          $("#login_msg").html("Please select terms and conditions");
        }
        e.preventDefault();
	});
	
	
	$("#loginform").validate({ 
			
			errorElement:'div',
			rules:{ 
		       login_id:{
					required: true,
				    remote: CarURL+"/all-ajax/value_check.php"
				}, 
			password: {
                 required:true 				 				
                },		
			
			forgot_pass: {
                 required:true 				 				
                },				
					
			entered_opt: {
                 required:true 				 				
                },
				
			login_terms: {
                 required:true 				 				
                }	
			},
       
	   messages:{				 
    				
			  login_id:{
					required:"Inavalid email or mobile",
					remote:"Enter valid email id or mobile no"											
				}, 
			  password:{
					required:"Enter your password"								 
				},
				
			  forgot_pass:{
					required:"Enter your password"								 	 
			  },
			  
			  entered_opt:{
					required:"Please enter an OTP"								 
			  },

              login_terms:{					
                  required:"Please select terms and conditions"				  		
				}			  
			}
		});   
    
    $("#login_id").keyup(function (e) 
	{ 
	    $('#contineCheck').removeClass('disableloginbtn');
	    $("#login_pwd").hide();
        $("#show_pwd").hide();
        $("#password").hide(); 
        $("#password_label").hide(); 
        $("#submit_login").hide();
        $("#submit_login_otp").hide();
        $("#login_terms").hide(); 
        $("#login_terms_condn").hide(); 
        $("#contineCheck").show(); 
        $("#loginform").validate().resetForm(); 
        $("#login_msg").html("");
	}); 
	
	
	$("#password").keyup(function (e) 
	{   
	    clear_msg();
        $("#loginform").validate().resetForm();  
	}); 
	$("#entered_opt").keyup(function (e) 
	{   
	    clear_msg();
        $("#loginform").validate().resetForm();  
	});    
	
	$("#contineCheck").click(function(e) 
	{  
	        set = 1; 
	        if(set==1)
	        {   
        		$.ajax({	
    			type: "POST",
    			url: CarURL+"/all-ajax/login-ajax.php",
    			data: {check_user_existance:1,login_id:$("#login_id").val(),userPWd:$("#userPWd").val()},
    			beforeSend: function(){
    			    $('#contineCheck').addClass('disableloginbtn');
    			},
    			success: function(data)
    			{  	 
    			       $('#contineCheck').removeClass('disableloginbtn');   
    			       if(data==1) 
    			       {     
                            $("#contineCheck").hide(); 
                            $("#login_pwd").hide();
        					$("#show_pwd").hide();
        					$("#password").hide(); 
        					$("#password_label").hide();
        					$("#submit_login").hide();
        					$("#submit_login_otp").hide();	
        					$("#show_pwd").hide();
        					$("#password").hide(); 
        					$("#password_label").hide();
        					$("#submit_login").hide();
        					 $("#login_pwd").hide();
        					$("#show_pwd").hide();
        					$("#password").hide(); 
        					$("#password_label").hide();
        					$("#submit_login").hide();
        					$("#submit_login_otp").hide(); 
        					$("#login_terms").hide(); 
                            $("#login_terms_condn").hide(); 	 
                            clear_msg(); 
                            //window.location.href = window.location.href;
                            
                             
                           
                            var audioElement1 = document.createElement('audio');
                            audioElement1.setAttribute('src', 'https://www.dailypayservices.in/mob/sound/welcome_msg.mp3'); 
                            audioElement1.addEventListener('', function() 
                            {
                            //this.play();
                            }, false);
                            audioElement1.play();  
                            
                            window.setTimeout(function()
                            {  
                                window.location.href = "https://www.dailypayservices.in/mob/dashboard/default.php?userid=DP112233";     
                            },(2000));

    			           
    			       }else
    			       {
                            
                           
                            
           				    $("#contineCheck").show(); 
        				    $("#login_msg").html("Sorry!!! Invalid Credentails");  
    			       } 
    			       
    			 }
    			  
    		     });
    		     e.preventDefault();  // this is help to prevent from submit
	        }
	        else  if(details=='')
	            $("#login_msg").html("Enter valid email id or mobile no");
	});
		   
	$("#loginform").submit(function(event)  // on click on this id...we will do folowwings
	{
	  if ($('#loginform').valid())  
	  {    
	        $("#login_msg").html("");
            var formData = $('#loginform').serialize();  // i have taken all form in serialized format here...
    		$.ajax({	
    		type: "POST",
    		url: CarURL+"/login_logout.php", 
    		data: {check_user_login:1,formData:formData},	
    				beforeSend: function(){
    				    $('#submit_login').addClass('disableloginbtn');
    				},
    				success: function(data){
    			
                    if(data==1)
                    {
                        ////////////alert("Login Done Successfully!!");
                        //window.location.href = URL;
    					location.reload();
                    }
                    else if(data==2)
                    {
                        $("#login_msg").html("Incorrect Password!!!");
                        $('#submit_login').removeClass('disableloginbtn');    
                    }
                    else if(data==3)
                    {
                        $("#login_msg").html("Invalid Credientials!!!");
                        $('#submit_login').removeClass('disableloginbtn');    
                    }
    		    }  
    		});   
		}
		event.preventDefault();  // this is help to prevent from submit 
	});		
	
    /************* login start    Js End  **/    

    // registration start
    
    $("#registrationform").submit(function( event )  // on click on this id...we will do folowwings
	{     
		if($('#registrationform').valid())  
		{ 
	       ////if(($("#letter").hasClass("correct")) && ($("#capital").hasClass("correct")) && ($("#number").hasClass("correct")) && ($("#length").hasClass("correct")) && ($("#special_character").hasClass("correct"))) 
		  {
            //$("#submit_reg").hide();			
            //$("#waiting_image").show(300);
            
              $.ajax({	
        		type: "POST",
        		url: CarURL+"/all-ajax/login-ajax.php",
        		data: {check_regiOTP_count:1,registered_mob:$("#registered_mob").val()},
        		beforeSend: function(){ 
        		    $('#submit_reg').addClass('disableloginbtn');
        		},
        		success: function(val)
        		{
        		    if(val==3)
    		        {
    		            $("#registration_msg").html("Your today's OTP limit has been exceeded");
    		            $("#registered_mob").val("");
    		            $('#submit_reg').removeClass('disableloginbtn');
    		        }      
			        else if(val==1)
			        {
            			var formData = $('#registrationform').serialize();  // i have taken all form in serialized format here...
            			$.ajax({	
            			type: "POST",
            			url: CarURL+"/all-ajax/login-ajax.php",
            			data: {check_reg:1,formData:formData},	
            					beforeSend: function(){
            						$('#submit_reg').addClass('disableloginbtn');
            					},
            				  success: function(val)
            				   { 			   
            				        $('#submit_reg').removeClass('disableloginbtn');
            				        
            				        const myArr = JSON.parse(val);  
            				        val =  myArr['Output'];   
                					if(val==1)
                					{
                					    
                					    //alert("Thanks for registration with us");
                						clear_msgRegi(); 
                                       // $('#login').modal('hide');
                                        //window.location.href = URL;
                                        //location.reload();
                                        $("#entered_OTP_label").html("Enter OTP sent to "+$("#registered_email").val());
                                         
                                         
                                        $('#UserReg_name').css('display','none');
                                        $('#UserReg_mob').css('display','none');;
                                        $('#UserReg_email').css('display','none');;
                                        $('#UserReg_pwd').css('display','none');;
                                        $('#UserReg_refId').css('display','none');;   
                                          
                                        
                						$("#registrationform").show();
                						$("#registerhead").show();  
                						$("#registered_name_label").hide(); 
                						$("#registered_mob_label").hide(); 
                						$("#registered_email_label").hide();
                						$("#registered_password_label").hide();
                						//$("#registered_name").hide(); 
                						//$("#registered_mob").hide();
                						//$("#registered_refId").hide();
                						
                						
                						//$("#registered_email").hide();
                						$("#registered_password").hide();
                						$("#registered_pwd").hide();
                						//$("#show_regipwd").hide();
                						$("#reg_terms").hide();
                						$("#log").hide();
                						$("#iam").hide();
                						$("#submit_reg").hide();
                						//$("#entered_OTP_label").show();
                						//$("#entered_OTP").show();     
                						//$("#submit_OTP").show();
                						$("#reg_some_div").hide(); 	
                						/*var timeLeft = 30;
                						var elem = document.getElementById('reg_some_div');
                						var timerId = setInterval(countdown2, 1000);
                						function countdown2() 
                						{						  
                						  $("#reg_some_div").show();
                						  if (timeLeft == 0) {
                						   clearTimeout(timerId);
                						   $("#resend_reg_otp").show();
                						   $("#reg_some_div").hide();
                						  }
                						  else {				
                							elem.innerHTML = timeLeft + ' seconds remaining';
                							timeLeft--;	                				
                						  }			  
                						}*/ 
                						
                						$("#regi").html("Thanks for registration!!");         
                                        $("#registered_name_labeltest").show(); 
                                        $("#registered_mob_labeltest").show();
                                        $("#registered_id_labeltest").show();  
                                        $("#registered_email_labeltest").show();
                                        $("#registered_pwd_labeltest").show();
                                        $("#registered_close_labeltest").show();
                                        $('#UserReg_address').hide();
                                        $('#UserReg_txnpwd').hide();
                                        
                                        
                                        
                                        
                                        $("#registered_name_labeltest").val("Name: "+myArr['Fname']);
                                        $("#registered_mob_labeltest").val("Phone: "+myArr['ph_no']);
                                        $("#registered_id_labeltest").val("Id: "+myArr['id']);
                                        $("#registered_email_labeltest").val("Email: "+myArr['email']);
                                        $("#registered_pwd_labeltest").val("Password: "+myArr['passwprd']);
                                        
                						
                					}
                					else
                					{
                					    alert("Sorry Error Occurred");
                						if(val==0)
                						{
                							$("#message").show();     
                							
                						}
                						else
                						{
                						    if(val==7)
                					            $("#registration_msg").html("Some error occured. please try again");		
                                            /*else 		
                                               $("#registration_msg").html("Some error occured. please try again");	*/
                                               
                                            //$("#submit_reg").show();			
                                            //$("#waiting_image").hide();   
                    						event.preventDefault(); 
                						}
                					}				
            				    }  
            			    });  
			             }
        		       }
                 });
		 }
		 /****else
		 {
			 $("#message").show();
			 event.preventDefault();
		 }*****/
		 
		}
		event.preventDefault();  // this is help to prevent from submit
	});	
	
	$("#entered_OTP").keyup(function()
    {
        var otpReg = /^\d{4}$/;    
        if( ($("#entered_OTP").val()!='') && ($("#entered_OTP").val().match(otpReg)))
        {
           $("#registration_msg").html("");
        }
        else
        {
		   $("#registration_msg").html("Enter 4 digit number!!!");
        }
    });
	
	$("#submit_OTP").click(function(e) 
	{
		var otpReg = /^\d{4}$/; 
		
		  
		
		if( ($("#entered_OTP").val()!='') && ($("#entered_OTP").val().match(otpReg)))
		{ 
            $("#reg_some_div").hide();
            $("#resend_reg_otp").hide();
			$.ajax({	
			type: "POST",
			url: CarURL+"/all-ajax/login-ajax.php",
			data: {submit_OTP:1,entered_OTP:$("#entered_OTP").val()},
			beforeSend: function(){ 
			    $('#submit_OTP').addClass('disableloginbtn');
			},
			success: function(data)
			{               		
			    $('#submit_OTP').removeClass('disableloginbtn');
			   if(data==1)
			   {
                    /*user=1;
                    setCookie(user,30);
                    url = CarURL+"/login/login-modals.php";
                    $("#LoginModalLoad").load(url); 
                    $("#login").modal({
                    	show: 'true',
                    	backdrop: 'static',
                    	keyboard:false
                    });   		
                    removeCookie(); 
                    alert("Thank you for registered with us , please check your mail box to verify your email.");*/
                    
                    $('#login').modal('hide');
                    $.ajax({	
            			type: "POST",
            			url: CarURL+"/login_logout.php", 
            			data: {NormalUser_RegCookiesSet:1,},
            			beforeSend: function(){ 
            			    
            			},
            			success: function(setVal)
            			{
            			    if(setVal==1)
            			    {
            			        alert("Thank you for registered with us , please check your mail box to verify your email.");
            			        location.reload();
            			    }
            			}			
		            });
			   }
			  else if(data==0)
			  {
			    $("#reg_some_div").show(); 
				$("#entered_OTP").val('');
				$("#registration_msg").html("Wrong OTP!!! Please enter correct OTP");
			  }
			  else if(data==3)
			  {
			    $("#reg_some_div").show(); 
				$("#entered_OTP").val('');
				$("#registration_msg").html("Your Email Id and Mobile Number already registered");
			  }
			}			
		  });  
		}
		else
		{
			$("#entered_OTP").val('');
			$("#registration_msg").html("Enter 4 digit number!!!");
		}
	}); 
	
	$("#resend_reg_otp").click(function(e)
	{
	   $("#resend_reg_otp").hide();	
	   
	   $.ajax({	
		type: "POST",
		url: CarURL+"/all-ajax/login-ajax.php",
		data: {check_reg_otp:1},
		beforeSend: function(){ 
		},
		success: function(data)
		{   
		    if(data==3)
            {
                $("#entered_OTP").val("");
                (document.getElementById('reg_some_div')).innerHTML="";
                
            	$("#registration_msg").html("Your today's OTP limit has been exceeded"); 
            	$("#resend_reg_otp").hide();		
    			$("#reg_some_div").hide();
            }
            else if(data==1) 
            {
                clear_msgRegi();
    		    var timeLeft = 30;
                var elem = document.getElementById('reg_some_div');
    			var timerId = setInterval(countdown1, 1000);
    		    function countdown1() {
    			  $("#reg_some_div").show();
    			  if (timeLeft == 0) {
    			   clearTimeout(timerId);
    			   $("#resend_reg_otp").show();
    			   $("#reg_some_div").hide();
    			  }
    			  else {				
    				elem.innerHTML = timeLeft + ' seconds remaining';
    				timeLeft--;	                				
    			  }			  
    			}	
            }	
		}
	  }); 	
    });
    
    $("#show_regipwd").click(function() 
	{
		if($(this).hasClass('fa fa-eye-slash'))
		{           
			$(this).removeClass('fa fa-eye-slash');
			$(this).addClass('fa fa-eye');
            $('#registered_password').attr('type','text');			
		}
		else
		{ 
		  $(this).removeClass('fa fa-eye');  
		  $(this).addClass('fa fa-eye-slash');
		  $('#registered_password').attr('type','password'); 
		}
		
    });	
    
    // registration end
	
	 // Forgot Password end 
	// master logout start
	
	$(".master_logout").click(function(e) 
	{
		$.ajax({	
    		type: "POST",
    		url: CarURL+"/login_logout.php",//CarURL+"/all-ajax/login-ajax.php",
    		//data: {master_logout:1},
    		data: {the_logout:1},
    		beforeSend: function(){
    		
    		},
    		success: function(data)
    		{   
    			window.location.href = window.location.href;  
    		}
	   }); 
	});
	
	// master logout end
	

    /*$("#submit_pwd").click(function(e)  //  not used
	{
		clear_msg();
		var email_ph=$("#login_id").val();
		if(email_ph)
			$("#forgot_pass").val(email_ph);
		$("#login_id").hide(); 
		$("#show_pwd").hide();
		$("#password").hide();   
		$("#submit_login").hide();        		  
		$("#submit_pwd").hide(); 
        $("#login_terms").hide();        		  
		$("#login_terms_condn").hide();
        $("#submit_login_otp").hide();
		$("#social_heading").hide();
		$("#socialform").hide();		
		$("#forgot_pass").show();
        $("#submit_reset").show();
        $("#forgot_password_heading").show();		
	});	
	*/
	$("#forgot_password_form").submit(function(event)  // on click on this id...we will do folowwings
	{
	     
	  if($('#forgot_password_form').valid())  
	  {     
	      
	     var formData = $('#forgot_password_form').serialize();  // i have taken all form in serialized format here...
	     $.ajax({	
			type: "POST",
			//url: CarURL+"/all-ajax/login-ajax.php",
			url: CarURL+"/custom_function/EmailConfigure.php",
			data: {submit_reset:1,formData:formData},//forgot_pass:$("#forgot_pass").val()
			beforeSend: function(){
			 $('#submit_forgot').addClass('disableloginbtn');
			},
			success: function(val)
			{   
			    $('#submit_forgot').removeClass('disableloginbtn');
			    //$("#forgot_pass").val('');
			    //if(data!='false')
			    if(val==1)
			    {
			        $("#forgot_password_form").validate().resetForm(); 
			        $('#login').modal('hide');
                    alert("kindly check your mail to reset password");
                    event.preventDefault(); 
			    }
			}		
		  });
	    }
		event.preventDefault();  // this is help to prevent from submit 
	});	
	
	
}); 



function get_first_name(val,type)
{
    var regex = /^[a-zA-Z ]*$/;  
   
    if(type==1)
    {
        if(!val.match(regex))
        {
		   $("#registration_msg").html("name allow only alphabets and spaces");
           $('#registered_name').val('');
        }
        else
        {
            $("#registration_msg").html("");
        }
    }
}  
$(document).ready(function() 
{  		
	 $("#registrationform").validate({ 
			
			errorElement:'div',
			rules:{ 
		     registered_name:{
				 required:true,
				 minlength:3,
				 maxlength:35
				},	

			registered_email:{
				required: true,
				email: true,
				remote: CarURL+"/all-ajax/value_check.php"
				},

		     registered_mob:{
                    required:true,
				    number:true,
				    minlength:10,
				    maxlength:10,					
                    remote: CarURL+"/all-ajax/value_check.php"					 
                },
				
			registered_password: {
                 required:true,
                 minlength:5 
                },
				
			reg_terms:{
				 required:true				
				},

            entered_OTP:{
                    required:true,
				    number:true				    			 
               }				
			},
			messages:{	

				registered_name:{					
                  required:"Enter name",
				  minlength : "Enter minimum 3 characters name",
				  maxlength : "Max 35 characters are allowed"  					
				},   
				
				registered_email:{
				 required:"Enter a valid email id",	
				 remote: "This email is already registered"							
				}, 
				
				registered_mob:{
				required:"Enter a valid mobile no",	
				minlength : "Enter minimum 10 digits",
				maxlength : "Max 10 digits are allowed",
				remote: "This number is already registered"				
			   },
			   
			   registered_password:{
				required:"Enter Password",
				minlength : "Enter minimum 5 charaters"
			   },
			   
			   reg_terms:{					
                  required:"Please select terms and conditions"				  		
				},

               entered_OTP:{
				 required:"Enter an OTP"					
			   }			   
            }			  
		});	
		
		
		$("#forgot_password_form").validate({ 
		    /*
			
			errorElement:'div',
			rules:{ 
		     forgot_pass:{
				 required:true,
				 email:true,
			     remote: CarURL+"/all-ajax/value_check.php"					  
				}   		
			},
			messages:{	

				forgot_pass:{					
                  required:"Please enter email id",
                  email:"Please enter valid email id",
                  remote:"Email id does not exist"
				 } 		   
            }		*/	  
		});	
		
		
		
		
		
	
	
     		
}); 