// ---- Class Animation ---------------------------------------------------------------------------
/**
 * Bibliothek erstellt von Lutz Hoffarth.
 * Voraussetzung sind die Bibliotheken: jQuere-1.4.4 und jQuere-ui-1.8.10
 * @version 15.03.2011
 * @author Lutz Hoffarth
 */

/**
 * Dieser None-Effect wird nur Intern verwendet.
 */
Animation.EASING_EFFECT_NONE = '';
/**
 * Der Effekt wird nur mit {@link Animation.EASING_LOCATION_NONE} verwendet.
 * @version 15.03.2011
 */
Animation.EASING_EFFECT_SWING = 'swing';
/**
 * Der lineare Effekt wird nur mit {@link Animation.EASING_LOCATION_NONE} verwendet.
 * @version 15.03.2011
 */
Animation.EASING_EFFECT_LINEAR = 'linear';
Animation.EASING_EFFECT_QUAD = 'Quad';
Animation.EASING_EFFECT_CUBIC = 'Cubic';
Animation.EASING_EFFECT_QUART = 'Quart';
Animation.EASING_EFFECT_QUINT = 'Quint';
Animation.EASING_EFFECT_SINE = 'Sine';
Animation.EASING_EFFECT_EXPO = 'Expo';
Animation.EASING_EFFECT_CIRC = 'Circ';
Animation.EASING_EFFECT_ELASTIC = 'Elastic';
Animation.EASING_EFFECT_BACK = 'Back';
Animation.EASING_EFFECT_BOUNCE = 'Bounce';

/**
 * Die Location wird nur bei den Effekten {@link Animation.EASING_EFFECT_SWING} und 
 * {@link Animation.EASING_EFFECT_LINEAR} verwendet.<br>
 * Ansonsten wird standartmäßig wenn nicht anders angegeben {@link Animation.EASING_LOCATION_INOUT} verwendet.
 * @version 15.03.2011
 */
Animation.EASING_LOCATION_NONE = '';
Animation.EASING_LOCATION_IN = 'easeIn';
Animation.EASING_LOCATION_OUT = 'easeOut';
Animation.EASING_LOCATION_INOUT = 'easeInOut';

Animation.prototype.animate = function(object, properties, complete){
	object.animate(properties, animation.getSpeed(), animation.getEasing(), complete);
};

/**
 * Setzt die Verlaufsparameter und liefert das Animations-Objekt.<br>
 * @param effect EASING_EFFECT_*, Default: EASING_EFFECT_SWING
 * @param location EASING_LOCATION_*, Default: EASING_LOCATION_NONE
 * @version 14.03.2011
 */
Animation.prototype.setEasing = function(effect, location){
	if(effect == null) effect = Animation.EASING_EFFECT_SWING;
	if(location == null) location = Animation.EASING_LOCATION_NONE;
	this.effect = effect;
	if(this.effect == Animation.EASING_EFFECT_SWING || this.effect == Animation.EASING_EFFECT_LINEAR){
		this.location = Animation.EASING_LOCATION_NONE;
	}else if(this.effect == Animation.EASING_EFFECT_NONE){
		this.effect = Animation.EASING_EFFECT_SWING;
		this.location = Animation.EASING_LOCATION_NONE;
	}else{
		if(location == Animation.EASING_LOCATION_NONE){
			this.location = Animation.EASING_LOCATION_INOUT;
		}else{
			this.location = location;
		}
	}
	return this;
};

/**
 * Liefert den Animationsverlauf.
 * @version 14.03.2011
 */
Animation.prototype.getEasing = function(){
	return this.location + this.effect;
};

/**
 * Liefert die Geschwindigkeit in Millisekunden
 * @version 14.03.2011
 */
Animation.prototype.getSpeed = function(){
	return this.speed;
};

/**
 * Setzt die Geschwindigkeit der Animation in Millisekunden und liefert das Animations-Objekt.<br>
 * @param speed in Millisekunden, Default: 700
 * @version 14.03.2011
 */
Animation.prototype.setSpeed = function(speed){
	if(speed == null) speed = 700;
	this.speed = speed;
	return this;
};

/**
 * @version 14.03.2011
 */
Animation.prototype.toString = function(){
	return "Animation(" + this.speed + ", '" + this.getEasing() + "')";
};

/**
 * Konstruktor der Klasse Animation<br>
 * @param effect EASING_EFFECT_*, Default: EASING_EFFECT_SWING
 * @param location EASING_LOCATION_*, Default: EASING_LOCATION_NONE
 * @param speed in Millisekunden, Default: 700
 * @version 14.03.2011
 */
function Animation(effect, location, speed) {
	this.setEasing(effect, location).setSpeed(speed);
}
