$(function () {
    if ($('#login').val() == '') $('#login').focus(); else $('#password').focus();
    localStorage.removeItem("firebaseMessageToken")
    navigator.serviceWorker.register("/firebase-messaging-sw.js", { scope: "/firebase-cloud-messaging-push-scope" }).then((reg) => { });
});


function SubmitLogOn() {
    $('#login').attr('name', 'login');
    $('#password').attr('name', 'password');
    $('form').submit();
    return false;
}

var loginFormValidator = $('form').validate()

$('.restorePasswordType').change(function () {
    $('.field-validation-error').hide();
});

$('form').submit(function () {
    if ($(this).valid()) {
        $(this).find('button[type="submit"]').attr('disabled', true);
    }
});

function refreshImg() {
    var img = $('img.captchaImg');
    var src = "/Login/Img?captchaKey=234sdf&r=" + uuidv4();
    $(img).attr("src", src);
    return false;
}

function uuidv4() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}