$(function()
{
    /* Make cards clickable. */
    $('#mainContent').on('click', '.project-card', function(e)
    {
        if($(e.target).closest('.project-actions,[data-toggle],.btn,a').length) return;
        window.location.href = $(this).data('url');
    });

    $('.switchButton').click(function()
    {
        var projectType = $(this).attr('data-type');
        $.cookie('projectType', projectType, {expires:config.cookieLife, path:config.webRoot});
        window.location.reload();
    });

    $('.user-info').children('.avatar').addClass('avatar-shadow avatar-margin');

    var zdex = 99;
    projectList.forEach(function(project,index) {
        var id = project.id;
        $('#project' + id).children('.avatar').each(function() {
            $(this).css("z-index", zdex);
            zdex --;
        });

        $('#project' + id).children('.avatar').first().addClass("avatar-border");
        $('#project' + id).children('.avatar').first().find('span').addClass("avatar-span");
        $('#project' + id).children('.avatar').first().removeClass('avatar-shadow');
    });
});

/**
 * close menu.
 *
 * @param  obj $obj
 * @access public
 * @return void
 */
function closeMenu(obj)
{
    $(obj).find('.project-actions .dropdown').removeClass('open');
}
