$(document).ready(function () {

    if ($('.external').prop('checked') === true){ // type 1
        $('.url_container').removeClass('d-none');
        $('.video_container').addClass('d-none');
        $('.image_container').addClass('d-none');
        $('.youtube_thumbnails').removeClass('d-none');
        $('.video_thumbnail').val('');
        $('.image_thumbnail').val('');
    }

    if ($('.local').prop('checked') === true){ // type 2
        $('.url_container').addClass('d-none');
        $('.video_container').removeClass('d-none');
        $('.image_container').removeClass('d-none');
        $('.youtube_thumbnails').remove();
        $('.url').val('');
    }

    $('.external').click(function () { // type 1
        $('.url_container').removeClass('d-none');
        $('.video_container').addClass('d-none');
        $('.image_container').addClass('d-none');
        $('.youtube_thumbnails').removeClass('d-none').children('.photos').removeClass('hide');
        $('.video_thumbnail').val('');
        $('.image_thumbnail').val('');
    });

    $('.local').click(function () { // type 2
        $('.url_container').addClass('d-none');
        $('.video_container').removeClass('d-none');
        $('.image_container').removeClass('d-none');
        $('.youtube_thumbnails').remove();

        $('.video_thumbnail').next().css({
            display: 'none'
        }).siblings('span').css({
            display: 'inline-block'
        });

        $('.image_thumbnail').next().css({
            display: 'none'
        }).siblings('span').css({
            display: 'inline-block'
        });

        $('.url').val('');
    })
})
