// JavaScript Document

Fx.Group = new Class({
  Extends: Fx,

  initialize: function( options ) {
    this.rules = new Array;
    $splat( options.selector ).each( function( selector ) {
      var rules = CSS.findRules( selector );
      if ( !rules || rules.length!=1 )
        return;
      this.rules.push( rules[0] );
    }, this );
    this.parent( options );
  },

  set: function( now ) {
    var styles;
    if ( this.options.calc ) 
      styles = $type( this.options.calc )=='function' ? this.options.calc( now ) : eval( this.options.calc );
    this.rules.each( function( rule, index ) {
      this.rules[index] = rule.replace( styles );
    }, this );
    
    if ( !this.options.set || !this.options.elements )
      return;
          
    for ( var x=0; x<this.options.elements.length; x++ )
      this.options.set( this.options.elements[x], now );
  }
});


