﻿jQuery(function() {
    var p = jQuery("#formPasswordPrensa").validate({
        submitHandler: function(form) {
            send.RecordatorioPassword();
        },
        errorLabelContainer: null
    });
    // show a simple loading indicator
    var loader = jQuery('<div id="loader">Enviando...</div>')
			    .css({ position: "fixed", top: "1em", textAlign: "center" })
			    .appendTo("body")
			    .hide();
    jQuery().ajaxStart(function() {
        var backItem = $("#BackAlertLay");
        backItem.show();
        loader.show();
    }).ajaxStop(function() {
        loader.hide();
        p.resetForm();
    }).ajaxError(function(a, b, e) {
        throw e;
    });
});


var send = {
    RecordatorioPassword: function() {
        var f = $("#formPasswordPrensa");
        var serializedForm = f.serialize();

        $.post("/Prensa/EnviarPassword", serializedForm, function(data) {
            if (data == "true") {
                openWin.init(['alertOK', 'Registro', 'Se ha enviado un mail con tu contraseña. Revisa tu correo.', ""]);
            } else {
                openWin.init(['alertKO', 'Registro', 'El usuario no se ha encontrado', ""]);
            }
        });
        return false;
    }
}


$(document).ready(function() {

});
