var objectId = '';
function sortFiles(dir_id, object_id, order) {
  objectId = object_id;
  doAjaxRequest('CoMeT_function=run_module&module=MediaBankPub&function=frontend&action=sort_files&dir_id=' + dir_id + '&object_id=' + object_id + '&order=' + order, '#mb_files_' + objectId, updateFilesList);
}

function doMbSearch(object_id) {

  objectId = object_id;

  var dir_id = jQuery("input#mb_dir_id_" + object_id).val();
  var searchstring = jQuery("input#mb_searchstring_" + object_id).val();

  //if(searchstring) {
    var dataString = '&dir_id=' + dir_id + '&object_id=' + object_id + '&searchstring=' + searchstring
    doAjaxRequest('CoMeT_function=run_module&module=MediaBankPub&function=frontend&action=search_files' + dataString, '#mb_files_' + object_id, updateFilesList);
  //}
}


function updateFilesList(html) {
  jQuery('#mb_files_' + objectId).html(html);
}


function checkEnter(e, object_id) {
  var key;
  if (window.event) {
    key = window.event.keyCode; //IE
  } else {
    key = e.which;
  }
  if (key == 13) {
    doMbSearch(object_id);
    return false;
  }
  return true;
}

