YUI.add('ibe-anim', function(Y) {

  /**
   * Should be able to provide a config. For now it's static like this.
   *
   * @param id Dom element id.
   */
  Y.SlideDownUp = function(id) {
    this.id = id;
    this.node = Y.one('#' + this.id);
    this.node.setStyle('display', 'block');
    this.isOpened = true;

    this.anim = new Y.Anim({
      node: this.node,
      from: {
        width: '100%',
        height:0,
        opacity:0
      },
      to: {
        width: '100%',
        height: parseInt(this.node.get('offsetHeight')) + 'px',
        opacity:1
      },
      duration:0.2
    });

    this.open = function() {
      this.anim.set('reverse', false);
      this.anim.run();
      this.isOpened = true;
    };

    this.close = function() {
      if (this.isOpened) {
        this.anim.set('reverse', true);
        this.anim.run();
      }
      this.isOpened = false;
    };

    this.toggle = function() {
      if (this.isOpened) {
        this.close();
      } else {
        this.open();
      }
    };
  };


  Y.IBEFade = function(id, pConfig) {
    this.id = id;
    this.node = Y.one('#' + this.id);
    this.node.setStyle('display', 'block');
    this.from = undefined;
    this.to = undefined;
    this.duration = 0.5;

    this.anim = new Y.Anim({
      node : this.node,
      from: {opacity: 0},
      to: {opacity: 1},
      duration : 0.5
    });

    if (pConfig && typeof(pConfig) === 'object') {
      this.anim.setAttrs(pConfig);
    }

    this.fadeIn = function() {
      this.anim.run();
    };

    this.fadeOut = function() {
      this.anim.set('reverse', true);
      this.anim.run();
    };
  };

}, 'v0.1', { requires: ['anim', 'node-base'] });
