﻿$(document).ready(function () {
    if (location.host.toLowerCase() == "autotrader.mota.com")
        $('#header > .wrap').addClass("at-header");
if (location.host.toLowerCase() == "aaa.mota.com")
        $('#header > .wrap').addClass("aaa-header");
if (location.host.toLowerCase() == "carfax.mota.com")
        $('#header > .wrap').addClass("cf-header");
    validateReset();
});
function validateReset() {
    $('#form_rspwd').validate({
        hightlight: function (e) {
            $(e).addClass("error");
        },
        unhighlight: function (e) {
            $(this).removeClass("error");
        },
        onkeyup: false,
        submitHandler: function () {
            forgotPassword();
        }
    });
}
function forgotPassword() {
    $('#msg').html('').hide();
    $('#rspwd_btn').attr('disabled', true).addClass('loading').val('Processing...');

    $.ajax({
        type: "POST",
        url: ws_auth + "/resetPassword",
        data: '{"emailid":"' + $('#rspwd_userName').val() + '"}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#msg').html(msg.d.message);
            if (msg.d.message.indexOf('have sent you an email') > 0) {
                $('#msg').css("color", "#829B28");
                $('#form_rspwd').hide();
                $('#rspwd_btn').attr('disabled', true).removeClass('loading').val('Done');

            } else {
                $('#rspwd_btn').attr('disabled', false).removeClass('loading').val('Try Again');
            }
            $('#msg').show();
        }
    });

}

