// class storing all info about the animation
function Animation(name, effectCount)
{
    this.name = name;
    this.effects = new Array(effectCount);
    this.effectIndex = 0;
    this.addEffect = addEffect;
    this.runAnimation = runAnimation;
    this.runEffect = runEffect;
    this.printEffects = printEffects;
}

// class storing all info about an effect
function Effect(name, elem, effect, duration, transition, start, end, delay)
{
    this.name = name;
    this.elem = elem;
    this.effect = effect;
    this.duration = duration;
    this.transition = transition;
    this.start = start;
    this.end = end;
    this.delay = delay;
}

// add an effect to the animation
function addEffect(name, elem, effect, duration, transition, start, end, delay)
{
    // add effect to animation
    this.effects[this.effectIndex] = new Effect(name, elem, effect, duration, transition, start, end, delay);
    
    // update effect array index
    this.effectIndex++;
    
}

// run the animation
function runAnimation()
{
    // loop through all effects of the animation
    for (var i=0; i < this.effects.length; i++)
    {
        // if the effect is set
        if (this.effects[i])
        {
            // run the effect with the specified delay
            setTimeout('this.runEffect(\'' + this.effects[i].elem + '\',\'' + this.effects[i].effect + '\',\'' + this.effects[i].duration + '\',\'' + this.effects[i].transition + '\',\'' + this.effects[i].start + '\',\'' + this.effects[i].end + '\')', this.effects[i].delay);
        }
    }
}

// run the specified effect
function runEffect(elem, effect, duration, transition, start, end)
{
    // if there is a start pos for the effect
    if (start != -1)
    {
        eval('var curEffect = $(\''+ elem +'\').effect(\'' + effect +'\', {duration: '+ duration +',transition: Fx.Transitions.' + transition + '}).start(' + start +','+ end +');');
    }
    else
    {
        eval('var curEffect = $(\''+ elem +'\').effect(\'' + effect +'\', {duration: '+ duration +',transition: Fx.Transitions.' + transition + '}).start(' + end +');');
    }
}

function printEffects()
{
    for (var i=0; i < this.effects.length; i++)
    {
        if (this.effects[i])
        {
            alert(this.effects[i].name);    
        }    
    }
}
