var forgotPassword = {
    init:function()
    {
        $("#forgot-password").dialog({
            autoOpen: false,
            height: 300,
            width: 500,
            modal: true,
            resizable: false,
            title: 'Forgot Password',
            buttons: {
                'Reset Password': function() {
                    // Get the email
                    var email = $(this).find('#email').val();
                    var processing = $(this).find(".ajax-processing");
                    var error = $(this).find('.error-msg');
                    var owner = $(this);
                    // Send ajax request for reset
                    $.ajax({
                        url: '/ajax/reset-pass',
                        dataType: 'json',
                        data: 'email='+email,
                        type: 'POST',
                        success: function(data) {
                            // Remove processing message
                            processing.addClass('hidden');
                            if(data.success) { // Success
                                // Close out
                                owner.dialog("close");
                                // Inform of success
                                $("#forgot-password-reset").dialog('open');
                            } else { // Failure
                                // Inform of failure
                                error.html(data.msg);
                            }
                        }
                    });
                    // Show that we are processing
                    processing.removeClass('hidden');
                    error.html('<br />');
                },

                'Back to Login': function() {$(this).dialog("close");}

            },
            Cancel: function() {
                $(this).dialog('close');
            }
        });

        $("#login-module a.forgot-pass")
        .click(function() {
            $('#forgot-password').dialog('open');
            return false;
        });

    }
};
var passwordReset = {
    init:function()
    {

        $("#forgot-password-reset").dialog({
            autoOpen: false,
            height: 300,
            width: 500,
            modal: true,
            resizable: false,
            title: 'Password Changed',
            buttons: {
                'Home': function() {$(this).dialog("close");
                }
            }
        });
    }
};
