
/****************************************/
/* Script-Copyright by Benjamin Buhler	*/
/* webmaster[at]freiken-douhl.de 		*/
/* www.freiken-douhl.de					*/
/****************************************/

// ani(objekt,eigenschaft,von,bis,einheit,schritte,zeit,dannach);

function animate(obj,styleAtt,von,bis,einheit,steps,speed,dannach){
 // Wenn Animation deaktiviert
	if(typeof JS_ANIMATIONS_ENABLED == 'undefined' || JS_ANIMATIONS_ENABLED == false){
		obj.style[styleAtt]= bis+einheit;
		if(typeof dannach=="function") dannach(obj);
		return false;
	}
	
 // Zähler
	var c= von;
	
 // Wenn runterzählen, down
	var d= von>bis;
	
 // Interval
	var timer= window.setInterval(
		function(){
			if( (d&&c<=bis) || (!d&&c>=bis) ){
				clearInterval(timer);
				setTimeout(function(){
					obj.style[styleAtt]= bis+einheit;
					if(typeof dannach=="function") dannach(obj);
				}, speed);
			}
			obj.style[styleAtt]= c+einheit;
			if(d) c-=steps;
			else  c+=steps;
		},
		speed
	);
	
	return timer;
}

function animate_obj(obj,att,von,bis,einheit,steps,speed,dannach){
 // Wenn Animation deaktiviert
	if(typeof JS_ANIMATIONS_ENABLED == 'undefined' || JS_ANIMATIONS_ENABLED == false){
		obj[att]= bis+einheit;
		if(typeof dannach=="function") dannach(obj);
		return false;
	}
	
 // Zähler
	var c= von;
	
 // Wenn runterzählen, down
	var d= von>bis;
	
 // Interval
	var timer= window.setInterval(
		function(){
			if( (d&&c<=bis) || (!d&&c>=bis) ){
				clearInterval(timer);
				setTimeout(function(){
					obj[att]= bis+einheit;
					if(typeof dannach=="function") dannach(obj);
				}, speed);
			}
			obj[att]= c+einheit;
			if(d) c-=steps;
			else  c+=steps;
		},
		speed
	);
	
	return timer;
}