jQuery(function ($) {


$("#form_forgot_password").validate({
          
                rules:{
                        email:{
                            required : true,
                            email : true
                        }
                },
                messages:{
                       email:{
                            required : "Enter email",
                            email : "Enter Valid email"
                       }
                },
               errorPlacement: function(error, element) {
                         error.appendTo( element.next()).addClass('error');
                },
		submitHandler: function(form) {
                    
                  
                    
                        	$.ajax({
					type: 'POST',
					url: 'rpc.php',
					data: 'action=sign_up&mode=forgot_password&email='+$.URLEncode($('#email').val()),
                                        
					success: function(data){
                                            
                                            //alert(data);
                                            
                                            if($.trim(data) == 'true'){
                                              //$.prompt('Password has been Reset. New password sent to '+$('#email').val(),{ callback: redirecting });
                                              $('#forgot_password_error').html('Password has been reset. New password sent to <b>'+$('#email').val()+'</b>');
                                              $('#forgot_password_error').show();                                             
                                              $('#sent_eml').html($('#email').val());
                                              $('#forgot_password_error').addClass('info');
                                              $('#pgt_pwd_link').hide();
                                              $('#form_forgot_password').hide();
                                              $('#btn_submit').hide();
                                            }else{
                                              $('#forgot_password_error').html(data);
                                              $('#forgot_password_error').addClass('error');
                                              $('#forgot_password_error').show();
                                              
                                            }
					}
				})

                                function redirecting() {
				document.location.href = 'index.php';
			}


	    }

        });
        
        
        
  $("#form_forgot_password_preview").validate({
          
                rules:{
                        email:{
                            required : true,
                            email : true
                        }
                },
                messages:{
                       email:{
                            required : "Enter emaild ",
                            email : "Enter Valid email"
                       }
                },
               errorPlacement: function(error, element) {
                         error.appendTo( element.next()).addClass('error');
                },
		submitHandler: function(form) {
                    
                  
                    
                        	$.ajax({
					type: 'POST',
					url: 'rpc.php',
					data: 'action=sign_up&mode=forgot_password_preview&email='+$.URLEncode($('#email').val()),
                                        
					success: function(data){
                                            
                                            //alert(data);
                                            
                                            if($.trim(data) == 'true'){
                                              //$.prompt('Password has been Reset. New password sent to '+$('#email').val(),{ callback: redirecting });
                                              $('#forgot_password_error').html('Password has been reset. New password sent to <b>'+$('#email').val()+'</b>');
                                              $('#forgot_password_error').show();                                             
                                              $('#sent_eml').html($('#email').val());
                                              $('#forgot_password_error').addClass('info');
                                              $('#pgt_pwd_link').hide();
                                              $('#form_forgot_password').hide();
                                              $('#btn_submit').hide();
                                            }else{
                                              $('#forgot_password_error').html(data);
                                              $('#forgot_password_error').addClass('error');
                                              $('#forgot_password_error').show();
                                              
                                            }
					}
				})

                                function redirecting() {
				document.location.href = 'index.php';
			}


	    }

        });
        
        

});



