$(document).ready(function () {
    initMouse();
    initClick();
});

function initMouse() {
    let topLinkClass = $('.buy-top-link');
    topLinkClass.on('mouseover', function () {
        $(this).children('i').animate({'margin-left': '13px'}, 200);
    })
    topLinkClass.on('mouseleave', function () {
        $(this).children('i').animate({'margin-left': '8px'}, 200);
    })

    let listRightClass = $('.listing-type-right');
    listRightClass.on('mouseover', '.line-content a', function () {
        $(this).children('i').animate({'margin-left': '13px'}, 200);
    })
    listRightClass.on('mouseleave', '.line-content a', function () {
        $(this).children('i').animate({'margin-left': '8px'}, 200);
    })

    let otherLinkClass = $('.listing-type-left, .method-buy-link');
    otherLinkClass.on('mouseover', 'a', function () {
        $(this).children('i').animate({'margin-left': '13px'}, 200);
    })
    otherLinkClass.on('mouseleave', 'a', function () {
        $(this).children('i').animate({'margin-left': '8px'}, 200);
    })
}

function initClick() {
    $('.listing-right-line').on('click', function () {
        var chevron = $(this).find('i.fa-chevron-down');
        var hidP = $(this).children('.line-content').children('p:last-of-type');
        var hidA = $(this).find('a');
        if (chevron.hasClass('fa-rotate-180')) {
            chevron.removeClass('fa-rotate-180');
            hidP.hide();
            hidA.hide();
        } else {
            chevron.addClass('fa-rotate-180');
            hidP.show();
            hidA.show();
        }
    })
}