var shistory = [];
var index = -1;

function center(url) {
  sasserlay_close();
  $('center_loader').style.display = '';
  new Ajax.Updater("center_loader",url);
}

function sasserlay(url,reindex) {
  if (!reindex) {
    index++;
    shistory[index] = url;
  }
  $('back').className = index > 0 ? "" : "disabled";
  $('forward').className = index < shistory.length - 1 ? "" : "disabled";
  $('cover').style.display = 'block';
  $('cover_content').style.display = 'block';
  $('cover_nav').style.display = 'block';
  new Ajax.Updater("cover_content",url);
}

function sasserlay_close() {
  shistory = [];
  index = -1;
  $('cover_content').style.display = 'none';
  $('cover_nav').style.display = 'none';
  $('cover').style.display = 'none';
}

function sasserlay_back() {
  if (index > 0) {
    index--;
    sasserlay(shistory[index],true);
  }
}

function sasserlay_forward() {
  if (index < shistory.length - 1) {
    index++;
    sasserlay(shistory[index],true);
  }
}