
function lexicon_replace_handler(event) {
  // Disable superscript field if not selected.
  if ($("input[@name=lexicon_replace]:checked").val() == 'superscript') {
    $("input[@name=lexicon_superscript]").parents("div.lexicon_superscript").show();
  }
  else {
    $("input[@name=lexicon_superscript]").parents("div.lexicon_superscript").hide();
  }

  // Disable icon URL field if not selected.
  var selected = $("input[@name=lexicon_replace]:checked").val();
  if (selected == 'icon' || selected == 'iconterm') {
    $("input[@name=lexicon_icon]").parents("div.lexicon_icon").show();
  }
  else {
    $("input[@name=lexicon_icon]").parents("div.lexicon_icon").hide();;
  }
}

function lexicon_link_related_handler(event) {
  // Disable one-way field if not selected.
  if ($("input[@name=lexicon_link_related]:checked").val() == 1) {
    $("input[@name=lexicon_link_related_how]").parents("div.lexicon_link_related_how").show();
  }
  else {
    $("input[@name=lexicon_link_related_how]").val(0);
    $("input[@name=lexicon_link_related_how]").parents("div.lexicon_link_related_how").hide();
  }
}

// Run the javascript on page load.
if (Drupal.jsEnabled) {
  $(document).ready(function () {
    // On page load, determine the current settings.
    lexicon_replace_handler();
    lexicon_link_related_handler();
    // Bind the functions to click events.
    $("input[@name=lexicon_replace]").bind("click", lexicon_replace_handler);
    $("input[@name=lexicon_link_related]").bind("click", lexicon_link_related_handler);
  });
}