var mvObject;

function mvObject(elem, stProp, esName, esStart, esEnd, esDur, esAmp, esPer, esOvs)
{
	this.obj = elem;
	this.prop = stProp;
	this.pos = esStart;
	this.time = 0;
	this.func = esName;
	this.start = esStart;
	this.change = esEnd - esStart;
	this.dur = esDur;
	this.amp = esAmp;
	this.per = esPer;
	this.ovs = esOvs;
	this.moving = false;
}

mvObject.prototype.Start = function()
{
	this.pos = this.start;
	this.moving = true;
	this.time = 0;
	this.ChangePos();
}

mvObject.prototype.Stop = function()
{
	this.moving = false;
}

mvObject.prototype.Resume = function()
{
	this.moving = true;
	this.ChangePos();
}

mvObject.prototype.onChange = function()
{
	return;
}

mvObject.prototype.onComplete = function()
{
	return;
}

mvObject.prototype.ChangePos = function()
{
	if (this.moving)
		{
			if (this.time < this.dur)
				{
					this.time++;
					if (this.amp != null && this.per != null)
						{
							this.pos = Math.round(this.func(this.time, this.start, this.change, this.dur, this.amp ,this.per));
						}
					else if (this.ovs != null)
						{
							this.pos = Math.round(this.func(this.time, this.start, this.change, this.dur, this.ovs));
						}
					else
						{
							this.pos = Math.round(this.func(this.time, this.start, this.change, this.dur));
						}
					this.obj.style[this.prop] = this.pos + 'px';
					var self = this;
					setTimeout(function() {self.ChangePos();}, 15);
					this.onChange();
				}
			else
				{
					this.Stop();
					this.onComplete();
				}
		}
}

Math.easeOutQuart = function (t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

