function getDefaultIcon(type, icon) {

    if(!icon) {
        icon = 'icon-warning22';
        switch (type) {
            case 'success':
                icon = 'icon-checkmark3';
                break;
            case 'error':
                icon = 'icon-blocked';
                break;
            case 'warning':
                icon = 'icon-warning22';
                break;
            case 'info':
                icon = 'icon-info22';
                break;
        }
    }

    return icon;
}

function getType(type) {
    switch (type) {
        case 'success':
        case 'error':
        case 'info':
            break;
        case 'error':
        case 'warning':
            type = 'success';
            break;
    }
    return type;
}

$(document).ready(function() {

    if (typeof PNotify == 'undefined') {
        console.warn('Warning - pnotify.min.js is not loaded.');
        return;
    }

    let elementObjects = $('.LimitlessNotification');

    elementObjects.each(function() {

        let obj = $(this);

        let title = obj.attr('data-title');
        let msg = obj.attr('data-message');
        let type = obj.attr('data-type');
        let icon = obj.attr('data-icon');

        setTimeout(function() {
            new PNotify({
                title: title,
                text: msg,
                icon: getDefaultIcon(type, icon),
                type: getType(type)
            });
        },1);

    });

    // TRANSFER SAMPLES ON RESOURCES

    $('#notify_success').on('click', function () {
        new PNotify({
            title: 'Success!',
            text: 'This is a Success!',
            icon: 'icon-checkmark3',
            type: 'success'
        });
    });

    $('#notify_error').on('click', function () {
        new PNotify({
            title: 'Error!',
            text: 'This is an Error!',
            icon: 'icon-blocked',
            type: 'error'
        });
    });

    $('#notify_warning').on('click', function () {
        new PNotify({
            title: 'Warning!',
            text: 'This is a Warning!',
            icon: 'icon-warning22',
            type: ''
        });
    });

    $('#notify_info').on('click', function () {
        new PNotify({
            title: 'Info!',
            text: 'This is an Info!',
            icon: 'icon-info22',
            type: 'info'
        });
    });

})