             });
            })
            .error(function (jqXHR, textStatus, errorThrown) {
                // TODO: Display a detailed error message. It will come from JSON.
                alert( 'Got an error while uploading images.' );
            })
        }
});

// See https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
function getCookie(name) {
    var cookieValue = null;
    if (document.cookie && document.cookie != '') {
        var cookies = document.cookie.split(';');
        for (v