function ObjectAnimation(id, node){
    XPlatform.call(this);
    //this.prototype = new XPlatform();
    this._id   = id;
    this._node = (typeof node == 'undefined') ? this.getElementById(id) : node;
    this._css  = this.getStyle(this._node);
    this._obj  = id+'Object'; eval(this._obj+'=this'); 
    this._isFadeActive = false;
    this._startFade    = false;

    if( typeof ObjectAnimation._initialized == "undefined"){
        //alert("init ObjectAnimation()");                    

        ObjectAnimation.prototype.show = function(){
            this._css.visibility = 'visible';
        }

        ObjectAnimation.prototype.hide = function(){
            this._css.visibility = 'hidden';
        }

        ObjectAnimation.prototype.setOpacity = function(opacity){ 
            // Fix for math error in some browsers
            opacity = (opacity == 100) ? 99.999 : opacity;
            // IE/Windows
            this._css.filter = "alpha(opacity:"+opacity+")";
            // Safari < 1.2, Konqueror
            this._css.KHTMLOpacity = opacity/100;   
            // Older Mozilla and Firefox
            this._css.MozOpacity = opacity/100;
            // Safari 1.2, newer Firefox and Mozilla, CSS3
            this._css.opacity = opacity/100;
        }

        // gradually decrease the opacity of the element
        ObjectAnimation.prototype.fadeOut = function(opacity, change, speed){ 
            // opacity: starting opacity of element
            // change: the size of the increments between steps
            // speed: the rate of the animation
            if (opacity >= 0){
                this._fadeRunning = true;
                this.setOpacity(opacity);
                opacity -= change;
                setTimeout(this._obj+'.fadeOut('+opacity+','+change+','+speed+')', speed);
            }else{
                this._fadeRunning = false;
                this.hide();
            }
        }

        // gradually increase the opacity of the element
        ObjectAnimation.prototype.fadeIn = function(opacity, change, speed){ 
            // opacity: starting opacity of element
            // change: the size of the increments between steps
            // speed: the rate of the animation 
            if (opacity <= 100){
                this.show();
                this._fadeRunning = true;
                this.setOpacity(opacity);
                opacity += change;
                setTimeout(this._obj+'.fadeIn('+opacity+','+change+','+speed+')', speed);
            } else {
                this._fadeRunning = false;
                this.setOpacity(100);
            }
        }

		ObjectAnimation.prototype.setWidth = function(width){ 
            this._css.width = width + "px";
        }
        
		ObjectAnimation.prototype.widthGrow = function(startWidth, stopWidth, speed, callback){
            if(startWidth < stopWidth){
                this.setWidth(startWidth);
                startWidth += 1;
                speed = speed > 1 ? 1 : speed - 1;
                setTimeout(this._obj+'.widthGrow('+startWidth+','+stopWidth+','+speed+',\''+callback+'\')', speed);
            }else{
                if(callback){
                   eval(callback+'()');
                }
            }
            
        }

        ObjectAnimation.prototype.widthShrink = function(startWidth, stopWidth, speed){
               if(startWidth > stopWidth){
                    this.setWidth(startWidth);
                    startWidth -= 1;
                    speed -= 5;
                    setTimeout(this._obj+'.widthShrink('+startWidth+','+stopWidth+','+speed+')', speed);
                }
        }        

        ObjectAnimation._initialized = true;
    }

}

ObjectAnimation.prototype = new XPlatform();

//------------------ ObjectAnimation ------------------------------------

