﻿YAHOO.namespace("Animation");

YAHOO.Animation.Util = function(Container, Height, Width, CollapseHeight, CollapseWidth, Duration, CallbackItem) {
    this.Init(Container, Height, Width, CollapseHeight, CollapseWidth, Duration, CallbackItem);
}    

YAHOO.Animation.Util.prototype = {

    Container:null,
    MyAnimation:null,
    Height:null,
    Width:null,
    CollapseHeight:null,
    CollapseWidth:null,
    MovementDuration:null,
    CallbackItem:null,
   
    Init:function(Container, Height, Width, CollapseHeight, CollapseWidth, Duration, CallbackItem)
    {
        // set base vars
        this.Container = Container;
        this.Height = (Height == null) ? null : Height;
        this.Width = (Width == null) ? null : Width;
        this.CollapseHeight = (CollapseHeight == null) ? null : CollapseHeight;
        this.CollaspeWidth = (CollapseWidth == null) ? null : CollapseWidth;
        this.MovementDuration = (Duration == null) ? 0.5 : Duration;
        this.CallbackItem = CallbackItem;
        
        // set animation properties
        this.MyAnimation = new YAHOO.util.Anim(this.Container);
        this.MyAnimation.method = YAHOO.util.Easing.easeOut;

    },   
    
    // function stops the animation on whatever frame it is on
    Pause:function()
    {
        this.MyAnimation.stop( false );
    },
    
    
    // function advances the scroll effect
    Show:function()
    {
        // finish animation if it's not yet complete
        this.Pause();
        //Set Height for show
        if (this.Height != null) {
            this.MyAnimation.attributes.height = { to: this.Height };
        }
        if (this.Width != null) {
            this.MyAnimation.attributes.width = { to: this.Width };
        }
        this.MyAnimation.duration = this.MovementDuration;
        // perform animation
        this.MyAnimation.animate();
    },
    
    
    // function retreats the scroll effect
    Hide:function()
    {
        // finish animation if it's not yet complete
        this.Pause();
        //Set Height for hide
        if (this.CollapseHeight != null) {
            this.MyAnimation.attributes.height = { to: this.CollapseHeight };
        }
        if (this.CollapseWidth != null) {
            this.MyAnimation.attributes.width = { to: this.CollapseWidth };
        }
        this.MyAnimation.duration = this.MovementDuration;
        // perform animation
        this.MyAnimation.animate();
    }
   
}