function glidePath( nTime, nStart, nEnd, nDelay )
{
	if ( ( nTime /= nDelay / 2) < 1)
		return nEnd / 2 * Math.pow( nTime, 3 ) + nStart
	else
		return nEnd / 2 * ( ( nTime -= 2 ) * Math.pow( nTime, 2 ) + 2) + nStart;
}

function growthSpurt( sID )
{
	this._ancestor = dynamicElement;
	this._ancestor( sID );

	this._offsetHeight = this._height;
	this._offsetWidth  = this._width;
	this._offsetX      = this._x;
	this._offsetY      = this._y;
	this._shadowX      = 0;
	this._shadowY      = 0;
	this._slideSpeed   = 20;
	this._sizeSpeed    = 20;
	this._sizeTimer    = null;
	this._slideTimer   = null;

	return this;
}
growthSpurt.prototype.setPageDimensions = function()
{
	// document dimensions
	this._bodyWidth  = window.innerWidth || document.body.clientWidth;
	this._bodyHeight = window.innerHeight || document.body.clientHeight;
}
growthSpurt.prototype.centerPage = function( bSmooth )
{
	if ( bSmooth )
		this.slide( -Math.round( this._width / 2 ), -Math.round( this._height / 2  ) );
	else
		this.move( -Math.round( this._width / 2 ), -Math.round( this._height / 2  ) );
}
growthSpurt.prototype.smoothResize = function( nWidth, nHeight, sCallOnFinish )
{
	this.setPageDimensions();
	this._callSize = ( typeof sCallOnFinish != "undefined" ) ? sCallOnFinish : false;
	this._sizeTime = 0;

	this._heightStart = this._height;
	this._widthStart  = this._width;
	this._heightEnd   = nHeight - this._height;
	this._widthEnd    = nWidth - this._width;
	this.resizeAction();
}
growthSpurt.prototype.resizeAction = function()
{
	if ( ++this._sizeTime < this._sizeSpeed )
	{
		this._resizing  = true;
		var nHeight     = parseInt( glidePath( this._sizeTime, this._heightStart, this._heightEnd, this._sizeSpeed ) );
		var nWidth      = parseInt( glidePath( this._sizeTime, this._widthStart, this._widthEnd, this._sizeSpeed ) );
		this._sizeTimer = setTimeout( this._self + ".resizeAction()", 30 );
		this.resize( nWidth, nHeight );
	}
	else
	{
		if ( typeof this._callSize == "function" )
		{
			this._callSize();
			this._callSize = null;
		}
		this._resizing = false;
		clearTimeout( this._timer );
		this.resize( this._widthStart + this._widthEnd, this._heightStart + this._heightEnd );
	}
	if ( this._center )
		this.centerPage();
}
growthSpurt.prototype.slide = function( nX, nY, sCallOnFinish )
{
	this._callSlide = ( typeof sCallOnFinish != "undefined" ) ? sCallOnFinish : false;
	this._slideTime = 0;

	this._slideXstart = this._x;
	this._slideYstart = this._y;
	this._slideXend   = nX - this._x;
	this._slideYend   = nY - this._y;

	this.slideAction();
}
growthSpurt.prototype.slideAction = function()
{
	if ( ++this._slideTime < this._slideSpeed )
	{
		var nX = parseInt( glidePath( this._slideTime, this._slideXstart, this._slideXend, this._slideSpeed ) );
		var nY = parseInt( glidePath( this._slideTime, this._slideYstart, this._slideYend, this._slideSpeed ) );
		this.move( nX, nY );
		this._slideTimer = setTimeout( this._self + ".slideAction()", 30 );
	}
	else
	{
		if ( typeof this._callSlide == "function" )
		{
			this._callSlide();
			this._callSlide = null;
		}
		this.move( this._slideXstart + this._slideXend, this._slideYstart + this._slideYend );
		clearTimeout( this._timer );
	}
}

