
  $(document).on("click","#send_link",function(){
    var checkValues = $('input[name="profileList[]"]:checked').length;
    var checkItems = $('input[name="permission[]"]:checked').length;
    var dropitem = $('#p_type').val();
    var dropitem1 = document.getElementById('p_type');
   
    //alert(checkItems);
      if(checkValues>10)
      {
        bootbox.alert("Up to 10 profile's share once");
      }
      else if(checkValues == 0)
      {
        bootbox.alert("Select atleast one profile");
      }
       else if(checkItems == 0 && dropitem == 'S')
      {
        bootbox.alert("Select atleast one specific item");
      }
      else if((checkValues >0 && checkItems > 0) || dropitem == 'P'  )
      {
        $("#shareLinkForm").submit();
      }
      else
      {
        bootbox.alert("Select atleast one profile");
      }
  });

$(document).on('change','#p_type',function(){
  if($(this).val()=='S')
    $('#specific_items_list').show();
  else
    $('#specific_items_list').hide();
});

/* User Inbox Datatables Load*/
if($('#users-share-table').length)
{
  $('#users-share-table').DataTable({
    "language": {
        "emptyTable":     "No share profiles found"
    },
	processing: true,
    serverSide: true,
    ajax: '/share/ajax_list?folder=S',
    filter: false,
    columns: [
      {data: 'sender', name: 'sender', width:'25%', orderable: false, searchable: false,class:'message_view_det'},
      {data: 'action', name: 'action', width:'60%', orderable: false, searchable: false,class:'message_view_det'},
      {data: 'created_at', name: 'created_at', width:'15%',class:'message_view_det'}
    ],
    "order": [[ 2, "desc" ]]
  });
}

if($('#users-shared-assets').length)
{
  var dt_assets = $('#users-shared-assets').DataTable({
    "language": {
        "emptyTable":     "No share items found"
    },
	processing: true,
    serverSide: true,
    ajax: '/share/assets_ajx_list?type=vid',
    filter: false,
    columns: [
      {data: 'sender', name: 'sender', width:'25%', orderable: false, searchable: false,class:'message_view_det'},
      {data: 'file', name: 'file', width:'20%', orderable: false, searchable: false,class:'message_view_det'},
      {data: 'action', name: 'action', width:'40%', orderable: false, searchable: false,class:'message_view_det'},
      {data: 'created_at', name: 'created_at', width:'15%',class:'message_view_det'}
    ],
    "order": [[ 2, "desc" ]]
  });

  // video btn click
  $('#users-shared-assets tbody').on( 'click', '.popup', function (e) {
      
      $.ajax({
        type: 'get',
        data: '',
        url: '/share/update_count/'+$(this).attr('data-id'),
        context:this,
        success: function(retVal) {      

          $('#modal-iframe').attr('src',$(this).attr('iframe-src'));
          $('#popup').modal('show');
          $( "#load-md-left" ).load( $(location).attr('href') + " #load-md-left-inner" );
          dt_assets.draw();          
        }
      });
  });  

  // pic btn click
  $('#users-shared-assets tbody').on( 'click', '.pic-popup', function (e) {
      e.preventDefault();
      $.ajax({
        type: 'get',
        data: '',
        url: '/share/update_count/'+$(this).attr('data-id'),
        context:this,
        success: function(retVal) {    

          $('#modal-pic').attr('src',$(this).attr('pic-src'));
          $('#pic-popup').modal('show');
          $( "#load-md-left" ).load( $(location).attr('href') + " #load-md-left-inner" );
          dt_assets.draw();
        }
      }); 

    });    

  // resume btn click
  $('#users-shared-assets tbody').on( 'click', '.download-popup', function (e) {
      e.preventDefault();
      $.ajax({
        type: 'get',
        data: '',
        url: '/share/update_count/'+$(this).attr('data-id'),
        context:this,
        success: function(retVal) {    

          $( "#load-md-left" ).load( $(location).attr('href') + " #load-md-left-inner" );
          dt_assets.draw();
          self.location = $(this).attr('download-url');
        }
      }); 

    });      

}