var WIKI_FEA_CUR_POS = 0;

function wiki_change_fea(dir, tot) {
  var to_hide = WIKI_FEA_CUR_POS;
  var to_show = (WIKI_FEA_CUR_POS + dir) % tot
  to_show = to_show >= 0 ? to_show : to_show + tot

  $('wiki_fea_' + to_hide).style.display = 'none';
  $('wiki_fea_' + to_show).style.display = 'block';

  WIKI_FEA_CUR_POS = to_show;
}

function selectWikiAction(o) {
  var selectedOption = o.options[o.selectedIndex];

  //kinda hackish, but oh well
  if ((selectedOption.text == "Delete This Article") && (!confirm("Are you sure you want to delete this article?"))) {
    return;
  }

  location.href = o.options[o.selectedIndex].value;
}

function toggleWikiEditRegion(rgnId, ctlLabelId, hideLabel, showLabel) {
  var cur = $(rgnId).style.display;
  if (cur == 'none') {
    $(rgnId).style.display = 'block';
    $(ctlLabelId).innerHTML = hideLabel;
  } else {
    $(rgnId).style.display = 'none';
    $(ctlLabelId).innerHTML = showLabel;
  }
}

function toggleWikiEditAdvancedRgn() {
  toggleWikiEditRegion('wiki_edit_advanced_rgn', 'wiki_advanced_ctl_txt', '&#171; hide advanced options', 'show advanced options &#187;');
}

function toggleWikiEditLocalRgn() {
  toggleWikiEditRegion('wiki_edit_local_rgn', 'wiki_local_ctl_txt', '&#171; hide local guide categories', 'set local guide categories &#187;');
}

function toggleWikiEditMediaEmbedRgn() {
  toggleWikiEditRegion('wiki_edit_media_embed_rgn', 'wiki_media_embed_ctl_txt', '&#171; hide embed video options', 'embed a video &#187;');
}
