function toggles(selector) {
    var elem = $(selector);
    var state = elem.css('display');
    if (state == 'none')
        elem.show(500);
    else
        elem.hide(500);
}

function selectCategory(catId) {
    $('.profileCoverSelectCategory').hide(500);
    toggles("#category" + catId);
}

function selectCover(coverId) {
    var cover = $(".profileCoverImage");
    $.ajax({
        url: '/ajax/profileCover/index.php',
        method: 'GET',
        data: {
            cover_id: coverId
        }
    }).done(function (data) {
        console.log(data);
        if (!data.error) {
            cover.animate({
                opacity: 0
            }, 300, function () {
                $(this).attr('src', data.coverSrc).animate({
                    opacity: 1
                }, 300);
            });
        } else {
            alert(data.error);
        }
    });
}