function Animator(object) {
	this.object = object;
	this.animationTime = 1000;
	
	this.animationQueue = [];
	this.animationQueueLength = 0;
	
	this.tempArray = [];
	
	this._setPropertyToValue = function(property, value) {
		var setName = "set";
		setName += property.charAt(0).toUpperCase() + property.substr(1);
		
		if(this.object[setName]) {
			this.object[setName](value);
		} else {
			this.object[property] = value;
		}
	}
	
	this._animate = function() {
		for(key in this.animationQueue) {
			var object = this.animationQueue[key];
			
			if(!object) {
				continue;
			}
			
			var time = new Date().getTime();
			var timeSinceStart = time - object.launchTime;
			
			if(timeSinceStart >= object.timeToRun) {
				this._setPropertyToValue(key, object.destination);
				var completeFunction = object.completeFunction;
				this.animationQueue[key] = null;
				if(completeFunction) {
					completeFunction();
				}
				this.animationQueueLength--;
				continue;
			}
			
			var percent = timeSinceStart / object.timeToRun;
			percent--;
			percent = 1 - percent * percent;
			var value = (object.destination - object.source) * percent;
			value += object.source;
			this._setPropertyToValue(key, value);
		}
		
		if(this.animationQueueLength > 0) {
			var obj = this;
			setTimeout(function() { obj._animate(); }, 17);
		}
	}
	
	this.setPropertyToValue = function(property, value, completeFunction) {
		var launchAnimator = this.animationQueueLength == 0;
		
		if(!this.animationQueue[property]) {
			this.animationQueueLength++;
		}
		
		this.animationQueue[property] = {
			source : this.object[property],
			destination : value,
			timeToRun : this.animationTime,
			launchTime : new Date().getTime(),
			completeFunction : completeFunction
		};
		
		if(launchAnimator == true) {
			this._animate();
		}
	}
}

function AnimatedDiv(div) {
	this.div = div;
	
	this.paddingTop = 0;
	this.paddingBottom = 0;
	
	var divWidth = div.style.width;
	if(divWidth.length > 0) {
		this.width = Math.floor(divWidth.substr(0, divWidth.length - 2));
	} else {
		this.width = 64;
	}

	var divHeight = div.style.height;
	if(divHeight.length > 0) {
		this.height = Math.floor(divHeight.substr(0, divHeight.length - 2));
	} else {
		this.height = 64;
	}
	
	this.opacity = 1.0;
	
	var divLeft = div.style.left;
	if(divLeft.length > 0) {
		this.left = Math.floor(divLeft.substr(0, divLeft.length - 2));
	} else {
		this.left = 8;
	}

	var divTop = div.style.top;
	if(divTop.length > 0) {
		this.top = Math.floor(divTop.substr(0, divTop.length - 2));
	} else {
		this.top = 8;
	}
	
	this.scale = 1.0;
	
	this.setPaddingTop = function(paddingTop) {
		this.paddingTop = paddingTop;
		div.style.paddingTop = paddingTop + "px";
	}
	
	this.setPaddingBottom = function(paddingBottom) {
		this.paddingBottom = paddingBottom;
		div.style.paddingBottom = paddingBottom + "px";
	}
	
	this.setWidth = function(width) {
		this.width = width;
		div.style.width = width * this.scale + "px";
	}
	
	this.setHeight = function(height) {
		this.height = height;
		div.style.height = height * this.scale + "px";
	}
	
	this.setOpacity = function(opacity) {
		this.opacity = opacity;
		div.style.opacity = opacity;
		div.style.filter = "alpha(opacity=" + opacity * 100 + ")";
	}
	
	this.setLeft = function(left) {
		this.left = left;
		div.style.position = "absolute";
		var width = this.width;
		var scale = this.scale;
		div.style.left = (left + (width - width * scale) / 2) + "px";
	}
	
	this.setTop = function(top) {
		this.top = top;
		div.style.position = "absolute";
		var height = this.height;
		var scale = this.scale;
		div.style.top = (top + (height - height * scale) / 2) + "px";
	}
	
	this.setScale = function(scale) {
		this.scale = scale;
		this.setWidth(this.width);
		this.setLeft(this.left);
		this.setHeight(this.height);
		this.setTop(this.top);
	}
}