var gfxClass = function() {
	/*
	 * GFX-Class
	 * v1.0.6 0054
	 * 
	 * Copyright by OSwebstyle.de
	 * If you want to use this class pleas contact us at info@oswebstyle.de for further information.
	 * 
	 * Description
	 * //TODO write description
	 * 
	 * Important public-functions
	 * //TODO mention important public-functions
	 * 
	 */
	
	this.fades 	 = Array();
	this.smooths = Array();
	
	this.fader	 = null;
	this.smoother 
	
	this.fade = function(obj_id, start, end, asc) {
		this.fades[this.fades.length] = Array(obj_id, start, end, asc);
		
		if(this.fader == null) this.fader = window.setInterval(gfx.intervalHandler, 20);
	}
	
	this.smooth = function(obj_id, new_content, fixValue) {
		fixValue = typeof fixValue == "undefined" ? 0 : parseInt(fixValue);
		var obj		  = getObjectById(obj_id);
		var tmp		  = obj.innerHTML;
		var curHeight = obj.offsetHeight;
		obj.innerHTML += "<div id=\""+obj_id+"_tmp\" style=\"width: 930px; height: 0px; overflow: scroll;\">"+unescape(new_content)+"</div>";
		var newHeight = getObjectById(obj_id+"_tmp").scrollHeight;
		obj.style.height = curHeight+"px";
		obj.innerHTML = "";
		
		debug("elm: "+obj_id+"\ncurHeight: "+curHeight+" -- newHeight: "+newHeight);
		this.smooths[this.smooths.length] = Array(obj_id, curHeight, (newHeight+fixValue), ((newHeight+fixValue) > curHeight ? true : false));
		
		if(this.fader == null) this.fader = window.setInterval(gfx.intervalHandler, 20);
	}
	
	this.fadeHandler = function() {
		var obj;
		var fin = 0;
		
		for(var i = 0;i<gfx.fades.length;++i) {
			
			if(gfx.fades[i] == null) {
				++fin;
				continue;
			}
			
			obj = getObjectById(gfx.fades[i][0]);

			if(gfx.fades[i][3]) {
				//ascending
				if(gfx.fades[i][1] >= gfx.fades[i][2]) {
					gfx.fades[i][1] = gfx.fades[i][2];
					++fin;
				}
				else gfx.fades[i][1] += 5;
			}
			else {

				if(gfx.fades[i][1] >= gfx.fades[i][2])	gfx.fades[i][1] -= 5;
				else {
					gfx.fades[i][1] = gfx.fades[i][2]
					++fin;
				}
			}
				
			obj.style.opacity = (gfx.fades[i][1] / 100);
			obj.style.MozOpacity = (gfx.fades[i][1] / 100);
			obj.style.KhtmlOpacity = (gfx.fades[i][1] / 100);
			obj.style.filter = "alpha(opacity=" + gfx.fades[i][1] + ")";
			
			if(gfx.fades[i][1] == gfx.fades[i][2]) gfx.fades[i] = null;
			
		}
		
		debug("fadeHandler: finished: "+fin+" of "+gfx.fades.length+"\nstatus: "+(fin == gfx.fades.length));
		
		if(fin == gfx.fades.length) {
			//clear finished fades
			gfx.fades = Array();
			return true;
		}
		else						return false;
	}
	
	this.scrollHandler = function() {
		var obj;
		var fin = 0;
		
		for(var i = 0;i<gfx.smooths.length;++i) {
			
			if(gfx.smooths[i] == null) {
				++fin;
				continue;
			}
			
			obj = getObjectById(gfx.smooths[i][0]);
			
			if(gfx.smooths[i][3]) {
				//ascending
				
				debug("ascending: "+gfx.smooths[i][1]);
				if(gfx.smooths[i][1] >= gfx.smooths[i][2]) {
					gfx.smooths[i][1] = gfx.smooths[i][2];
					++fin;
				}
				else gfx.smooths[i][1] += 15;
			}
			else {
				
				debug("descending: "+gfx.smooths[i][1]);
				if(gfx.smooths[i][1] >= gfx.smooths[i][2])	gfx.smooths[i][1] -= 15;
				else {
					gfx.smooths[i][1] = gfx.smooths[i][2];
					++fin;
				}

				obj.style.height = gfx.smooths[i][1]+"px";
			}
			
			obj.style.height = gfx.smooths[i][1]+"px";
			
			//force re-draw
			obj.style.display="none";
			var redrawFix = obj.offsetHeight;
			obj.style.display="block";
			
			
			
			if(gfx.smooths[i][1] == gfx.smooths[i][2]) gfx.smooths[i] = null;
			
		}
		
		debug("scrollHandler: finisehd "+fin+" of "+gfx.smooths.length+"\nstatus: "+(fin == gfx.smooths.length));
		
		if(fin == gfx.smooths.length) {
			//clear finished smooths
			gfx.smooths = Array();
			return true;
		}
		else						return false;
	}
	
	this.running = function(obj_id, event) {
		var i;
		switch(event) {
			case "scroller":
				for(i = 0;i<this.smooths.length;++i) {
					if(this.smooths[i] == null) continue;
					
					if(this.smooths[i][0] == obj_id)	{
						return true;
					}
				}
			break;
			default:	//fader
				for(i = 0;i<this.fades.length;++i) {
					if(this.fades[i] == null) continue;
					
					if(this.fades[i][0] == obj_id)	{
						return true;
					}
				}
			break;
		}
		return false;
	}
	
	this.intervalHandler = function() {
		
		debug("fadeHander: "+gfx.fadeHandler()+"\nscrollHandler: "+gfx.scrollHandler()+"\n");
		
		if(
			gfx.fadeHandler() == true &&
			gfx.scrollHandler() == true
		) {
			gfx.fader = window.clearInterval(gfx.fader);
			debug("clear Interval");
		}
	}
	var debug = function(string) {
		if(this.debug == true)
			console.log(string);
	}
}