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));
						}
					switch (this.prop)
						{
							case 'days':
								this.obj.style.left = this.pos + 'px';

								var pos = -(this.pos / sliderRatio) + day1Offset;
								if (pos < day1Offset)
									{										pos = day1Offset;
									}
								else if (pos > scrollWidth - 12)
									{
										pos = scrollWidth - 12;
									}
								sliderObj.style.left = pos + 'px';
								doneObj.style.width = (pos + 7) + 'px';
							break;
							/*case 'color':
								this.obj.style.color = GetColor(this.pos, false);
								navObj.sel.style.color = GetColor(this.pos, true);
							break;*/
							case 'opacity':
								this.obj.style[this.prop] = this.pos / 100;
							break;
							case 'opacity_IE':
								this.obj.style.filter = 'Alpha(opacity=' + this.pos + ')';
							break;
							default :
								this.obj.style[this.prop] = this.pos + 'px';
							break;
						}
					var self = this;
					setTimeout(function() {self.ChangePos();}, 15);
					this.onChange();
				}
			else
				{
					this.Stop();
					this.onComplete();
				}
		}
}

/*
  Some functions from
  Easing Equations v1.5
  May 1, 2003
  (c) 2003 Robert Penner, all rights reserved.
  This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html.
*/

Math.easeOutQuad = function (t, b, c, d) {
	return -c *(t/=d)*(t-2) + b;
};


Math.easeOutExpo = function (t, b, c, d) {
	return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
};


Math.easeOutElastic = function (t, b, c, d, a, p) {
	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	if (a < Math.abs(c)) { a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
};
