/**
 * @author Michael Russell
 */
function subFadeElement(frameRate, increments,ID){
	var that = this;
	this.frameRate = frameRate || 30;
	this.increments = increments || 20;
	this.elem = getElement(ID);
	
	this.tValue;
	this.increase;
	this.x;
	//this.originalX;
	this.fadeSet = function(targetValue,increase){
		that.tValue = targetValue;
		that.increase = increase;
		this.originalX = getCurrentStyle(that.elem, 'opacity');
		that.x = parseFloat(this.originalX);
		that.animate();
	}
	this.fadeIn = function(){
		that.tValue = 1;
		that.increase = true;
		this.originalX = getCurrentStyle(that.elem, 'opacity');
		//alert(that.elem.id);
		//alert(parseFloat(this.originalX));
		//alert(that.increments);
		that.x = this.originalX;//parseFloat(this.originalX);
		that.animate();
	} 
	this.fadeOut = function(){
		that.tValue = 0;
		that.increase = false;
		this.originalX = getCurrentStyle(that.elem, 'opacity');
		that.x = parseFloat(this.originalX);
		that.animate();
	}
	this.animate = function(){
		if (that.increase) {
			that.x = (parseFloat(that.x) + parseFloat(that.increments));
			if ((that.tValue < that.x) || (that.tValue < 0)) {
				that.x = that.tValue;
			}
			else {
				setTimeout(that.animate, 1000 / that.frameRate);
			}
		}else {
			that.x = (parseFloat(that.x) - parseFloat(that.increments));
			if ((that.tValue > that.x) || (that.tValue < 0)) {
				that.x = that.tValue;
			}
			else {
				setTimeout(that.animate, 1000 / that.frameRate);
			}
		}
		that.elem.style.opacity = that.x;
		that.elem.style.filter = 'alpha(opacity='+(that.x*100)+')';
	}
}