//Tween Object (v1.2.2, 21-07-2009)//Auteur:	Niels Riekert//Laatste update: callBack en timeOut toegevoegd als parameter bij de tweenNow methode//BUGFIX: -> this.returing <-////Properties//	- tween.object//	- tween.property//	- tween.time//	- tween.returning (boolean)//	- tween.easType (optional)//	- tween.unit (optional)////Methods//	- tweenNow(startValue, endValue, tweenTime(optional))function Tween(object, property, time, returning, easType, unit, callBack, timeOut){	this.object = object;	this.property = property;	(time)?this.time = time:this.time = 500;	(returning != undefined)?this.returning = returning:this.returning = true;	(easType)?this.easType = easType:this.easType = 'linear';	(unit)?this.unit = unit:this.unit = '';	if(callBack){this.callBack = callBack;};	(timeOut)?this.timeOut = timeOut: this.timeOut = 0;	//standaard waarden	this.isTweening = false;	this.timeLeft = time;	this.lastTime;		//als propery is opacity dan checken of browser IE is	if(this.property == 'opacity' && this.object.style.filter != undefined){		this.property = 'filter';	}		this.tweenNow = function(startValue, endValue, callBack, timeOut, tweenTime){		//checkt of het object al animeert en of het wel omgedraaid mag worden		if(this.isTweening == true && this.returning == false){			//alert('bezig met animatie');			return;		}		else if(this.isTweening == true){			//draai de animatie om			var startValueTemp = this.startValue;			this.startValue = this.endValue;			this.endValue = startValueTemp;			this.timeLeft = this.time - this.timeLeft;						return;		}		else {			//de animatie is nog niet gestart, reset de variabelen			this.isTweening = true;			if(startValue == "current"){				if(property == 'height'){					tempString = this.object.offsetHeight;				}				else if(property == 'width') {					tempString = this.object.offsetWidth;				}				else {					var tempString = this.object.style[this.property];				}				if(this.property == 'filter'){					tempString = this.object.style[this.property].substr(14);				}				this.startValue = parseFloat(tempString);				//alert(this.object.style[this.property] + ' endValue ' + endValue + ' this.startvalue ' + this.startValue);			}			else {				this.startValue = startValue;			}			this.endValue = endValue;									if(callBack){				this.callBack = callBack;			}			else {				this.callBack = false;				}						if(timeOut){				this.timeOut = timeOut;			}			else {				this.timeOut = 0;				}									//IE			if(this.property == 'filter'){				this.endValue *= 100;				if(this.startValue < 1){					this.startValue *= 100;				}			}						if(tweenTime){				var time = tweenTime;				this.timeLeft = tweenTime;			}			else {				this.timeLeft = this.time;				var time = this.time;			}		}				var easing = new Easing(this.easType);				function animateTween(){			//alert(object.object);			var curTime = new Date().getTime();			//voor de berekening			var ellapsedTime = curTime - lastTime;			object.animLength = object.endValue - object.startValue;						if(object.timeLeft <= ellapsedTime){				if(object.property == 'filter'){				//IE + opacity					object.object.style[object.property] = 'alpha(opacity=' + object.endValue + ')';					//alert(object.object.style[object.property] + ' in animateTween object.endValue ' + object.endValue);				}				else{					object.object.style[object.property] = object.endValue + object.unit;				}								object.isTweening = false;								if(object.callBack){					object.cTimeout = setTimeout(object.callBack, object.timeOut);					object.callBack = false;					object.timeOut = 0;					}				return;			}						//t: current time, b: beginning value, c: change in value, d: duration			var position = easing.selectedEase(time-object.timeLeft, object.startValue, object.animLength, time);			//alert("ellapsedTime = " + ellapsedTime + " this.startValue = " + object.startValue + " this.animLength = " + object.animLength + " this.time = " + object.time + " position = " + position);						if(object.property == 'filter'){				//IE + opacity				object.object.style[object.property] = 'alpha(opacity=' + position + ')';			}			else {				object.object.style[object.property] = position + object.unit;			}			//alert(object.object.style[object.property] + ' - ' + object.object.id);			//document.getElementById('outputwindow').innerHTML = position + ' animLength: ' + object.animLength + " startValue: " + object.startValue;						object.timeLeft -= ellapsedTime;			lastTime = curTime;			window.setTimeout(animateTween, 30);		}		var object = this;		var lastTime = new Date().getTime();		setTimeout(animateTween, 30);	}}