// search controls

function changePage(newpage) {
  // change the page
  window.location = '?page=' + newpage;
}

function changeIndex(newindex) {
  // switch to the specified index
  $('searchindex').value = newindex;
  // reset the page
  $('searchpage').value = 1;
  // reload the results
  $('searchform').submit();
}

function changeSort(newsort) {
  if ($('searchsortby').value == newsort) {
    // change the sort direction if it's the same kind of sort
    $('searchsortdir').value = ($('searchsortdir').value == 'desc') ? 'asc' : 'desc';
  } else {
    // change the sort and reset to asc
    $('searchsortby').value = newsort;
    $('searchsortdir').value = 'asc';
  }
  // reset the page
  $('searchpage').value = 1;
  // reload the results
  $('searchform').submit();
}

// todo: intercept the search form post and run through ajax if possible
