if(!kronos)
  kronos = {}

YUI.add('group', function(Y) {

kronos.GROUP_SHRUNK    = 0;
kronos.GROUP_EXPANDING = 1;
kronos.GROUP_EXPANDED  = 2;
kronos.GROUP_SHRINKING = 3;
kronos.HIDING          = 4;
kronos.HIDDEN          = 5;
kronos.SHOWING         = 6;

kronos.ROW_EXPANSION_TIME = 0.5;

var GroupItem = function(config) {
  this.name          = config.name;
  this.fileName      = config.fileName
  this.left          = config.left;
  this.width         = config.width;
  this.height        = config.height;
  this.previewWidth  = config.previewWidth;
  this.previewHeight = config.previewHeight;
  this.previewLeft   = config.previewLeft;
  this.filter        = config.filter
  this.description   = config.description;
  this.visible       = true;
  this.filterAnim    = null;
}

GroupItem.prototype.setupAnimation = function(config) {
  if(this._anim) {
    this._anim.stop();
    this._anim = null;
  }
  
  var node = Y.one('#' + this.name);
  var anim = new Y.Anim({
    duration : kronos.ROW_EXPANSION_TIME,
    node : node,
    from : config.from,
    to : config.to
  });
  this._anim = anim;
}

GroupItem.prototype.animate = function(forward) {
  // if(forward)
  //   this._anim.set('reverse', false);
  // else
  //   this._anim.set('reverse', true);
  this._anim.run();
}

var Group = function(config) {
  this.name = config.name;
  this.config = config;
  
  this.items = [];
  if(config.haveBackground) {
    this.backgroundUrl = 'backgrounds/' + config.name + '.png';
  }
}

Group.prototype.getName = function()
{
  return this.name;
}

kronos.Group = Group;
kronos.GroupItem = GroupItem;

}, '1.0.0' /* module version */, {
  requires: ['base', 'node']
});
