/*    $("#loader").addClass("se-pre-con");
    $(".se-pre-con").fadeOut("slow");*/
toastr.options = {
  "closeButton": true,
  "debug": false,
  "newestOnTop": false,
  "progressBar": true,
  "positionClass": "toast-top-right",
  "preventDuplicates": false,
  "onclick": null,
  "showDuration": "300",
  "hideDuration": "1000",
  "timeOut": "5000",
  "extendedTimeOut": "1000",
  "showEasing": "swing",
  "hideEasing": "linear",
  "showMethod": "fadeIn",
  "hideMethod": "fadeOut"
}

if(!app_url)
    swal(' Application url not found!');

function callAjaxErrorFunction(jqXHR, textStatus, errorThrown){

    if (jqXHR.status == 401) {
        toastr.error("Session Time Out", "Error");
        setTimeout(
            function () {
              /*  location.replace(frontEndURL + "/admin/login");*/
            }, 2000);
    }  else if(jqXHR.status == 404){
        toastr.warning("Page not Found", "Warning");
    }  else if(jqXHR.status == 0){
        toastr.warning("Please Check Net Connection", "Warning");
    } else {
        toastr.error("Opps! Something went wrong", "Error");
    }

}


$(function () {


    setTimeout(function () { $('.page-loader-wrapper').fadeOut(); }, 300);
});




 $("#checkAll").click(function () {
     $('input:checkbox').not(this).prop('checked', this.checked);
 });



$(document).ready(function () {
    $('.sidebarCollapse').on('click', function () {
        $('#sidebar').toggleClass('active');
/*        $(this).toggleClass('active');*/
        $('.sidebarCollapse').toggleClass('active');
    });
    
    
//    $('ul#sidebar-component li a').on('click',function(e){
//      
//        $('ul#sidebar-component').find("li.active").removeClass("active");
//        $(this).parent('li').addClass("active");
//    })
    
    
    
});


$('.program_delete').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.level_delete').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.level_activate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to activate this programe!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.level_deactivate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to deactivate this programe!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});







$('.program_activate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to activate this programe!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.program_deactivate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to deactivate this programe!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});



$('.function_deactivate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to deactivate this function!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.function_activate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to activate this function!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.privilege_deactivate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to deactivate this privilege!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.privilege_activate').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You want to activate this privilege!",
      type: 'success',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.privilege_delete').on('click',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          var link=$(this).attr('href');
          window.location.replace(link);
      }
    })

    
});


$('.delete_data').on('submit',function(e){
    e.preventDefault();
    
    swal({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes'
    }).then((result) => {
      if (result.value) {
          $(this)[0].submit();
      }
    })

    
});



  /*      $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#wrapper").toggleClass("active");
        alert(1);
    });*/

    
    
/*    $(document).ready(function () {
    $('#sidebarCollapse').on('click', function () {
        $('#wrapper').toggleClass('active');
        $(this).toggleClass('active');
    });
});*/



window.setTimeout(function() {
    $(".alert").fadeTo(500, 0).slideUp(500, function(){
        $(this).remove(); 
    });
}, 3000);








$(".select_all").change(function(){  
    var status = this.checked; 
    $(this).parents('.checkbox_all_div').find('.child_checkbox').each(function(){ 
        this.checked = status; 
    });

});

$('.child_checkbox').change(function(){ 

    if(this.checked == false){ 
         $(this).parents('.checkbox_all_div').find('.select_all')[0].checked = false; 
       /* $(this).parents('.select_all')[0].checked = false; */
    }
    
    if ( $(this).parents('.checkbox_all_div').find('.child_checkbox:checked').length == $(this).parents('.checkbox_all_div').find('.child_checkbox').length ){ 
        $(this).parents('.checkbox_all_div').find('.select_all')[0].checked = true;
    }

/*    if ($('.checkbox:checked').length == $('.checkbox').length ){ 
        $(this).parents('.select_all')[0].checked = true; 
    }*/
});
