var CTxMoocontEffect = new Class({
  Implements: [Options],
  options: {
    transitionStyle: 'sine',
    transitionPhase: 'in:out',
    effectStartDelay: 500,
    effectDuration: 1000
  },
  Element: null,
  Effect: null,
  startEffect: function(){
    if(!$chk(this.Effect)) return;
    this.Effect.start();
  }
});
var CTxMoocontMorph = new Class({
  Extends: CTxMoocontEffect,
  Implements: [Options],
  options: {
    aProperty: ['opacity'],
    aStartValue: [0],
    aEndValue: [1]
  },
  StartSet: {},
  EndSet: {},
  getPropertyVal: function(sProp,value){
    if(value == 'initVal'){
      var initVal = this.Element.getStyle(sProp);
      return initVal;
    };
    return value;
  },
  initialize: function(Element,options){ 
    if(!$chk(Element)) return;
    this.setOptions(options);
    var trans = this.options.transitionStyle;
    if(trans!='linear') trans += ':' + this.options.transitionPhase;
    this.Element = Element;
    this.Effect = new Fx.Morph(this.Element,{
      duration: this.options.effectDuration,
      transition: trans
    });
    this.options.aProperty.each(function(sProp,index){
      this.StartSet[sProp] = this.getPropertyVal(sProp,this.options.aStartValue[index]);
      this.EndSet[sProp] = this.getPropertyVal(sProp,this.options.aEndValue[index]);
    },this);
    this.Effect.set(this.StartSet);
  },
  startEffect: function(){
    if(!$chk(this.Effect)) return;
    this.Effect.start.pass(this.EndSet,this.Effect).delay(this.options.effectStartDelay);
  }
});

var CTxMoocont = new Class({
  aEffect: [],
  addMorph: function(Element,options){
    var NewEffect = new CTxMoocontMorph(Element,options);
    this.aEffect.push(NewEffect);
    NewEffect.startEffect();
  }
});

var TxMoocont = new CTxMoocont();
