// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// treasure/control.js
//
// copyright (c) 2006-2010 drow <drow@bin.sh>
// all rights reserved.

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// configuration

var form = 'treasure_form';
var items = [ 'magic', 'psionic', 'chaositech' ];
var row_id = { };

items.each(function (type) {
  row_id[type] = 'tr_' + type + '_type';
});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// switch items

function switch_items () {
  var form_elem = $(form).elements;
  var chkd = $H();

  items.each(function (type) {
    chkd.set(type,form_elem[type].checked);
  });
  if (chkd.values().any()) {
    $('tr_item_opts').show();

    items.each(function (type) {
      if (chkd.get(type)) {
        $(row_id[type]).show();
      } else {
        $(row_id[type]).hide();
      }
    });
  } else {
    $('tr_item_opts').hide();
  }
  return;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// showtime

document.observe('dom:loaded',switch_items);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

