// Show/Hide Functions
function show_filter_window() {
  $('.filter-window').slideDown(550);
}

function hide_filter_window() {
  $('.filter-window').slideUp(150);
}
// ---

// Preview Filter Edit Request
function change_preview_value_status(element) {
  var is_column_checked = $(element).is(":checked");
  var linked_column = $(element).attr("linked_column");

  var request = {
    type: 'POST',
    url: urlroot + '/previewfilter/change_preview_value_status',
    data: {is_column_checked: is_column_checked, linked_column: linked_column},
    success: function(data) { handle_change_preview_response(data); }
  }

  $.ajax(request);
}

function handle_change_preview_response(data) {
  load_preview_filter();
  reload_preview();
}
// ---

// Preview Filter Loader
function load_preview_filter() {
   var request = {
     type: 'GET',
     url: urlroot + '/previewfilter/build',
     success: function(data) { $('.preview-filter-box').html(data); }
   }

   $.ajax(request);
}
