function ShowNotifPopup(type, title, msg, target){
  if(type=='info'){
    $('#iconNotifPopup').html('<em class="nk-modal-icon icon icon-circle icon-circle-xxl ni ni-info bg-transparent text-info"></em>');
    $('#notifPopup').addClass('swal2-info').removeClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-error').removeClass('swal2-question');
  }else if(type=='warning'){
    $('#iconNotifPopup').html('<em class="nk-modal-icon icon icon-circle icon-circle-xxl ni ni-alert-circle bg-transparent text-warning"></em>');
    $('#notifPopup').addClass('swal2-warning').removeClass('swal2-success').removeClass('swal2-info').removeClass('swal2-error').removeClass('swal2-question');
  }else if(type=='success'){
    $('#iconNotifPopup').html('<em class="nk-modal-icon icon icon-circle icon-circle-xxl ni ni-check-circle bg-transparent text-success"></em>');
    $('#notifPopup').addClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-info').removeClass('swal2-error').removeClass('swal2-question');
  }else if(type=='error'){
    $('#iconNotifPopup').html('<em class="nk-modal-icon icon icon-circle icon-circle-xxl ni ni-cross-circle bg-transparent text-danger"></em>');
    $('#notifPopup').addClass('swal2-error').removeClass('swal2-warning').removeClass('swal2-info').removeClass('swal2-success').removeClass('swal2-question');
  }else if(type=='question'){
    $('#iconNotifPopup').html('<em class="nk-modal-icon icon icon-circle icon-circle-xxl ni ni-help bg-transparent text-secondary"></em>');
    $('#notifPopup').addClass('swal2-question').removeClass('swal2-warning').removeClass('swal2-info').removeClass('swal2-success').removeClass('swal2-error');
  }else if(type=='process'){
    $('#iconNotifPopup').html(Spinner());
    $('#notifPopup').addClass('swal2-info').removeClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-error').removeClass('swal2-question');
  }else if(type=='confirmation'){
    $('#iconNotifPopup').html('<em class="nk-modal-icon icon icon-circle icon-circle-xxl ni ni-help bg-transparent text-secondary"></em>');
    $('#notifPopup').addClass('swal2-question').removeClass('swal2-warning').removeClass('swal2-info').removeClass('swal2-success').removeClass('swal2-error');
  }
  if(type=='process'){$('.closeNotifPopup').addClass('hide_element');}else{$('.closeNotifPopup').removeClass('hide_element');}
  if(target==''){$('#actionNotifPopup').addClass('hide_element');}else{$('#actionNotifPopup').removeClass('hide_element');}
  $('.titleNotifPopup').html(title);$('.contentNotifPopup').html(msg);$('#NotifPopupArea').removeClass('hide_element');$('#actionNotifPopup').attr('target', target);
  if(type=='confirmation'){$('#actionNotifPopup').attr('type_data', 'ajax');}else{$('#actionNotifPopup').attr('type_data', '');}
}
$('#actionNotifPopup').click(function() {
  var target = $(this).attr('target');var type_data = $(this).attr('type_data');
  if(type_data=='ajax'){
    ShowNotifPopup('process', 'Proses Permintaan', 'Tunggu sebentar.....', '');
    $.ajax({
      type: 'get',url: base+'/'+target,
      success: function(respone) {
      	var respone = JSON.parse(respone);ClosenotifPopup();
        if(respone.error || respone.warning){
          ShowNotifPopup('error', 'Gagal proses', respone.msg, '');
        }else{
          if(respone.type=='call'){
            var thisFunction = respone.call;window[thisFunction](respone.content);
          }else if(respone.type=='remove'){
            $('#'+respone.data+'-'+respone.target).remove();$('#count-content-'+respone.data).html(respone.count);
          }else if(respone.type=='content'){
            LoadData(respone.load, respone.target);
          }else if(respone.type=='redirect'){
            OpenLink(); window.location.href = base+'/'+respone.load;
          }else if(respone.type=='status'){
            if(respone.status==1){
              var label_status = '<span class="tb-status text-success">Tayang</span>';var action_status = '<em class="icon ni ni-shield-star"></em><span>Draft</span>';
            }else{
              var label_status = '<span class="tb-status text-warning">Draft</span>';var action_status = '<em class="icon ni ni-shield-check"></em><span>Tayang</span>';
            }
            $('.labelstatus-'+respone.target).html(label_status);$('.actionstatus-'+respone.target).html(action_status);
          }
          Alert(respone.msg, 'success'); return false;
        }
      }
    });
  }else{OpenLink(); window.location.href = base+'/'+target;}
});
function ClosenotifPopup(){
  $('#NotifPopupArea').addClass('hide_element');
  $('#notifPopup').addClass('swal2-info').removeClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-error').removeClass('swal2-error');
  $('#iconNotifPopup').html('<em class="icon ni ni-info"></em>');$('#titleNotifPopup').html('');$('#contentNotifPopup').html('');$('#actionNotifPopup').attr('target', '');
}
$('.closeNotifPopup').click(function() { ClosenotifPopup(); });
function closenotifPopup(){ ClosenotifPopup(); };
function CloseNotifPopup(){ ClosenotifPopup(); };
function ShowNotif(){
  $('.notif').addClass('swal2-info').removeClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-error');
  $('.icon_notif').html('<i class="icon ni ni-info"></i>');$('.title_notif').html('Informasi');$('.text_notif').html('Tunggu sebentar, sedang memproses.....');$('#NotifArea').removeClass('hide_element');
}
function CloseAlert(){
  $('#NotifArea').addClass('hide_element');
  $('.notif').addClass('swal2-info').removeClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-error');
  $('.icon_notif').html('<i class="icon ni ni-info"></i>');$('.title_notif').html('Informasi');$('.text_notif').html('Tunggu sebentar, sedang memproses.....');
}
function ExitNotif(){ setTimeout(function () { CloseAlert(); }, 5000); }
function DestroyNotif(){ CloseAlert(); }
$('.close_alert').click(function(){ CloseAlert(); ClosenotifPopup(); });
function NotifInfo(){$('.notif').addClass('swal2-info').removeClass('swal2-success').removeClass('swal2-warning').removeClass('swal2-error');$('.icon_notif').html('<i class="icon ni ni-info"></i>');$('.title_notif').html('Informasi');}
function NotifSuccess(){$('.icon_notif').html('<i class="icon ni ni-check"></i>');$('.notif').addClass('swal2-success').removeClass('swal2-info').removeClass('swal2-warning').removeClass('swal2-error');$('.title_notif').html('Sukses Proses');}
function NotifWarning(){$('.icon_notif').html('<i class="icon ni ni-alert"></i>');$('.notif').addClass('swal2-warning').removeClass('swal2-info').removeClass('swal2-success').removeClass('swal2-error');$('.title_notif').html('Informasi');}
function NotifDanger(){$('.icon_notif').html('<i class="icon ni ni-cross"></i>');$('.notif').addClass('swal2-error').removeClass('swal2-info').removeClass('swal2-warning').removeClass('swal2-success');$('.title_notif').html('Gagal Proses');}
function DefaultAlert(text, type){ Alert(text, type); };
function Alert(text, type){
  $('.text_notif').html(text);
  if(type=='success'){NotifSuccess();}else if(type=='warning'){NotifWarning();}else if(type=='danger' || type=='error'){NotifDanger();}else{NotifInfo();}
  $('#NotifArea').removeClass('hide_element');ExitNotif();
};