var Dependency = new Class({
  setMasters: function(masters) {
    this._masters = masters;
  },
  getMasters: function() {
    return this._masters;
  },
  setEffect: function(effect) {
    this._effect = effect;
  },
  getEffect: function() {
    return this._effect;
  },
  _getWrappedElement: function(element) {
    if (element.type === 'text') {
      var wrappedElement = new TextInput();
      wrappedElement.setField(element);
    }
    if (element.type === 'checkbox') {
      var wrappedElement = new CheckboxInput();
      wrappedElement.setField(element);
    }
    return wrappedElement;
  },
  _getEnhancedSlaves: function(slaves) {
    var wrappedSlaves = [];
    var parentFunction = this;
    slaves.each(function (decoratedSlave) {
      wrappedSlave = parentFunction._getWrappedElement(decoratedSlave);
      wrappedSlaves.push(wrappedSlave);
    });
    return wrappedSlaves;
  },
  affectSlaves: function(slaves) {
    var parentFunction = this;
    slaves.each(function (currentSlave) {
      if (parentFunction.getEffect() === 'wipe') {
          currentSlave.wipe();
      } else {
        currentSlave.disable();
      }
    });
  },
  unaffectSlaves: function(wrappedSlaves) {
    wrappedSlaves.each(function (currentSlave) {
      currentSlave.enable();
    });
  },
  createDependency: function(master, slave, effect) {
    this.setEffect(effect);
    parentFunction = this;
    if (!master.length) {
      masters = [master];
    } else {
      masters = master;
    }

    var wrappedMasters = [];
    masters.each(function (currentMaster) {
      var wrappedMaster = parentFunction._getWrappedElement(currentMaster);
      wrappedMasters.push(wrappedMaster);
    });
    this.setMasters(wrappedMasters);
    var parentFunction = this;
    this.getMasters().each(function (currentMaster) {
      currentMaster.getField().addEvent('keyup', function() {
        if (!slave.length) {
          slaves = [slave];
        } else {
          slaves = slave;
        }
        wrappedSlaves = parentFunction._getEnhancedSlaves(slaves);
        var masterHasValue = false;
        if (currentMaster.hasValue()) {
          masterHasValue = true;
          parentFunction.affectSlaves(wrappedSlaves);
        } else {
          parentFunction.getMasters().each(function (otherMaster) {
            if (otherMaster.hasValue()) {
              masterHasValue = true;
              parentFunction.affectSlaves(wrappedSlaves);
            }
          });
        }
        if (!masterHasValue) {
          parentFunction.unaffectSlaves(wrappedSlaves);
        }
      });
    });
  }
});

var HtmlWrapper = new Class({
  setField: function(field) {
    this._field = field;
  },
  getField: function() {
    return this._field;
  }
});

var TextInput = new Class({
  Extends: HtmlWrapper,
  enable: function() {
    this._field.disabled = false;
  },
  disable: function() {
    this._field.disabled = "disabled";
  },
  wipe: function() {
    this.disable();
    this._field.value = "";
  },
  hasValue: function() {
    if (this._field.value) {
      return true;
    }
    return false;
  }
});

var CheckboxInput = new Class({
  Extends: TextInput,
  wipe: function() {
    this.disable();
    this._field.checked = false;
  }
});


var dep = new Dependency();
dep.createDependency($('foo'), $('slave'), 'wipe');
//dep.createDependency(text, slave);

//var depTextToCheckbox = new Dependency();
//depTextToCheckbox.createDependency(text, slaveCheckbox, 'wipe');

//var depTextToCheckbox2 = new Dependency();
 //depTextToCheckbox2.createDependency(text, slaveCheckbox2);

//var depTextToCheckbox = new Dependency();
//depTextToCheckbox.createDependency(text, document.getElements('.checkbox_class'), 'wipe');

var depTextToCheckbox = new Dependency();
depTextToCheckbox.createDependency(document.getElements('.text_class'), document.getElements('.checkbox_class'), 'wipe');

@@ -1081,24 +1081,111 @@
 ave.wipe();%0A
+      %7D else if (parentFunction.getEffect() === 'hide') %7B%0A        currentSlave.hide();%0A
       %7D else
@@ -1240,16 +1240,18 @@
 );%0A  %7D,%0A
+  
   unaffe
@@ -1282,24 +1282,51 @@
 edSlaves) %7B%0A
+    parentFunction = this;%0A
     wrappedS
@@ -1358,24 +1358,208 @@
 entSlave) %7B%0A
+      if (parentFunction.getEffect() === 'wipe') %7B%0A        currentSlave.wipe();%0A      %7D else if (parentFunction.getEffect() === 'hide') %7B%0A        currentSlave.show();%0A      %7D else %7B%0A  
       curren
@@ -1571,24 +1571,32 @@
 e.enable();%0A
+      %7D%0A
     %7D);%0A  %7D,
@@ -3047,16 +3047,159 @@
 _field;%0A
+  %7D,%0A  hide: function() %7B%0A    this._field.setStyle('display', 'none');%0A  %7D,%0A  show: function() %7B%0A    this._field.setStyle('display', 'block');%0A
   %7D%0A%7D);%0A
@@ -3768,24 +3768,16 @@
 'slave')
-, 'wipe'
 );%0A//dep
@@ -4311,28 +4311,28 @@
 .checkbox_class'), '
-wip
+hid
 e');%0A

Implement hiding