/* Minification failed. Returning unminified contents.
(1,1): run-time error CSS1019: Unexpected token, found '$'
(1,2): run-time error CSS1019: Unexpected token, found '('
(1,12): run-time error CSS1031: Expected selector, found '('
(1,12): run-time error CSS1025: Expected comma or open brace, found '('
(6,2): run-time error CSS1019: Unexpected token, found ')'
(8,10): run-time error CSS1031: Expected selector, found 'register('
(8,10): run-time error CSS1025: Expected comma or open brace, found 'register('
(53,10): run-time error CSS1031: Expected selector, found 'openInputPrivacy('
(53,10): run-time error CSS1025: Expected comma or open brace, found 'openInputPrivacy('
 */
$(function ($) {
    var $inputs = $('input[name=inputPEC],input[name=inputSDI]');
    $inputs.on('input', function () {
        $inputs.not(this).prop('required', !$(this).val().length);
    });
});

function register() {
    var form = $("#register");
    var a = form.validate();
    if (form.valid()) {
        dataString = new FormData($("#register").get(0));
        $.ajax({
            url: '/Home/SubmitRegistrationAsync',
            type: "POST",
            data: dataString,
            cache: false,
            processData: false,
            contentType: false,
            success: function (result) {
                if (result === "") {
                    $.confirm({
                        title: 'Registrazione effettuata con successo!',
                        content: 'La tua registrazione è stata inoltrata con successo ai nostri sistemi, verrai contattato entro 24 ore lavorative.',
                        buttons: {
                            confirm: {
                                text: 'Chiudi',
                                action: function () {
                                    location.href = '/Article/Index';
                                }
                            }
                        }
                    });
                }
                else {
                    $.alert({
                        title: 'Errore',
                        content: 'Si è verificato un errore durante la registrazione. Controllare i campi inseriti.' + result,
                    });
                }
            },
            error: function () {
                $.alert({
                    title: 'Errore',
                    content: 'Si è verificato un errore durante la registrazione.',
                });
                console.log(errorMsg);
            }
        });
    }
}

function openInputPrivacy() {
    loadingJcModal.open();
    loadingJcModal.showLoading(true);
    var uri = baseUrl + "Home/TermsPartial/";
    $.ajax({
        url: uri,
        type: "POST",
        cache: false,
        processData: false,
        contentType: false,
        success: function (result) {
            $.alert({
                columnClass: 'col-md-12',
                title: 'CONDIZIONI GENERALI DI VENDITA ON LINE B2B',
                content: result,
                buttons: {
                    close: {
                        btnClass: 'pull-right',
                        text: 'Chiudi',
                        action: function () {
                        }
                    }
                }
            });
        },
        error: function () {
            $.alert({
                title: "Errore",
                content: "Spiacenti, al momento non è possibile visualizzare le condizioni generali di vendita, riprova più tardi.",
                type: errorColor
            });
        },
        complete: function () {
            loadingJcModal.close();
        }
    });
}
