$(function()
{
    $('#objectType').change(function()
    {
        var objectType = $(this).val();
        var link       = createLink('meeting', 'ajaxGetObjects' , 'projectID=' + projectID + '&objectType=' + objectType);
        $('#objectBox').load(link, function()
        {
            $('#objectID').chosen();
        });
    })
})

/**
 * Load executions of project.
 *
 * @param  int    $projectID
 * @access public
 * @return void
 */

function loadProjectExecutions(projectID = 0)
{
    var link = createLink('execution', 'ajaxGetProjectExecutions', "projectID=" + projectID);
    $.post(link, function(data)
    {
        $('#execution').replaceWith(data);
        $('#execution_chosen').remove();
        $('#execution').chosen();
    })
    loadTeamMembers(projectID)
}

/**
 * Load team.
 *
 * @param  int    $objectID
 * @access public
 * @return void
 */

function loadTeamMembers(objectID = 0)
{
    var projectID = $("#project").val();

    if(objectID == 0 && projectID) objectID = projectID;

    var link = createLink('meeting', 'ajaxGetTeamMembers', "objectID=" + objectID);

    $.post(link, function(data)
    {
        $('#participant').replaceWith(data);
        $('#participant_chosen').remove();
        $('#participant').chosen();
    })
}
