/*
	JavaScript animations
*/
	/*
		step classes
	*/
		// functions:
			function animation_funcNone () {
				return;
			}
			// resolve objects:
				function animationStep_funcResolveIDsO() {
					this.o = document.getElementById(this.o);
					this.o.doClip = animationStep_funcClip;
					return;
				}
				function animationStep_funcResolveIDsA() {
					var i;
					for (i = this.a.length - 1; i >= 0; i --) {
						this.a[i].resolveIDs();
					}
					return;
				}
				function animationStep_funcResolveIDsLoop() {
					this.o.resolveIDs();
					return;
				}
			// do it:
				function animationStep_funcDoItNone(animationRunner) {
					return;
				}
				function animationStep_funcDoItC(animationRunner) {
					this.o.style.color = this.c;
					return;
				}
				function animationStep_funcDoItS(animationRunner) {
					this.o.style[this.n] = this.v;
					return;
				}
				function animationStep_funcDoItX(animationRunner) {
					this.o.x = this.x;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItXR(animationRunner) {
					this.o.x = this.o.x + this.x;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItY(animationRunner) {
					this.o.y = this.y;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItYR(animationRunner) {
					this.o.y = this.o.y + this.y;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItZ(animationRunner) {
					this.o.z = this.z;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItXY(animationRunner) {
					this.o.x = this.x;
					this.o.y = this.y;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItXYR(animationRunner) {
					this.o.x = this.o.x + this.x;
					this.o.y = this.o.y + this.y;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItW(animationRunner) {
					this.o.w = this.w;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItWR(animationRunner) {
					this.o.w = this.o.w + this.w;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItH(animationRunner) {
					this.o.h = this.h;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItHR(animationRunner) {
					this.o.h = this.o.h + this.h;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItWH(animationRunner) {
					this.o.w = this.w;
					this.o.h = this.h;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItWHR(animationRunner) {
					this.o.w += this.w;
					this.o.h += this.h;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItXYWH(animationRunner) {
					this.o.x = this.x;
					this.o.y = this.y;
					this.o.w = this.w;
					this.o.h = this.h;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItMaxW(animationRunner) {
					this.o.maxW = this.maxW;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItMaxH(animationRunner) {
					this.o.maxH = this.maxH;
					this.o.doClip();
					return;
				}
				function animationStep_funcDoItV(animationRunner) {
					this.o.v = this.v;
					this.o.style.display = (this.v ? "block" : "none");
					return;
				}
				function animationStep_funcDoItA(animationRunner) {
					var i;
					for (i = this.a.length - 1; i >= 0; i --) {
						this.a[i].doIt(animationRunner);
					}
					return;
				}
				function AnimationStep_funcDoItLoop(animationRunner) {
					if (this.count < 1) {
						return;
					}
					this.step ++;
					if (this.step < this.count) {
						animationRunner.step --;
					} else {
						this.step = 0;
					}
					this.o.doIt(animationRunner);
					return;
				}
				function animationStep_funcClip() {
					if (this.x) {
						this.style.left = this.x + "px";
					}
					if (this.y) {
						this.style.top = this.y + "px";
					}
					if (this.z) {
						this.style.zIndex = this.z;
					}
					if (this.w && this.h) {
						if (this.maxW && (this.w > this.maxW)) {
							this.w = this.maxW;
						} else if (this.w < 0) {
							this.w = 0;
						}
						if (this.maxH && (this.h > this.maxH)) {
							this.h = this.maxH;
						} else if (this.h < 0) {
							this.h = 0;
						}
						//this.style.width  = this.w + "px";
						//this.style.height = this.h + "px";
						this.style.clip   = "rect(0px," + this.w + "px," + this.h + "px,0px)";
					}
				}
				function animationStep_funcDoItBoolean(animationRunner) {
					this.o[this.n] = this.v;
					return;
				}
		AnimationStep_nop = function () {
			this.doIt = animationStep_funcDoItNone;
			this.resolveIDs = animation_funcNone;
			return;
		}
		AnimationStep_addClass = function (o, className) {
			this.o          = o;
			this.className  = className;
			this.doIt       = function (animationRunner) {
				classNames = this.o.className.split(" ");
				for (var i = 0; i < classNames.length; i ++) {
					if (classNames[i] == this.className) {
						return;
					}
				}
				classNames.push(this.className);
				this.o.className = classNames.join(" ");
				return;
			};
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_removeClass = function (o, className) {
			this.o          = o;
			this.className  = className;
			this.doIt       = function (animationRunner) {
				classNames = this.o.className.split(" ");
				for (var i = 0; i < classNames.length; i ++) {
					if (classNames[i] == this.className) {
						classNames.splice(i, 1);
						this.o.className = classNames.join(" ");
						return;
					}
				}
				return;
			};
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setC = function (o, c) {
			this.o = o;
			this.c = c;
			this.doIt = animationStep_funcDoItC;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setS = function (o, name, value) {
			this.o = o;
			this.n = name;
			this.v = value;
			this.doIt = animationStep_funcDoItS;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setX = function (o, x) {
			this.o = o;
			this.x = x;
			this.doIt = animationStep_funcDoItX;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setXR = function (o, x) {
			this.o = o;
			this.x = x;
			this.doIt =animationStep_funcDoItXR;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setY = function (o, y) {
			this.o = o;
			this.y = y;
			this.doIt = animationStep_funcDoItY;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setYR = function (o, y) {
			this.o = o;
			this.y = y;
			this.doIt = animationStep_funcDoItYR;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setZ = function (o, z) {
			this.o = o;
			this.z = z;
			this.doIt = animationStep_funcDoItZ;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setXY = function (o, x, y) {
			this.o = o;
			this.x = x;
			this.y = y;
			this.doIt = animationStep_funcDoItXY;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setXYR = function (o, x, y) {
			this.o = o;
			this.x = x;
			this.y = y;
			this.doIt = animationStep_funcDoItXYR;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setW = function (o, w) {
			this.o = o;
			this.w = w;
			this.doIt = animationStep_funcDoItW;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setWR = function (o, w) {
			this.o = o;
			this.w = w;
			this.doIt = animationStep_funcDoItWR;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setH = function (o, h) {
			this.o = o;
			this.h = h;
			this.doIt = animationStep_funcDoItH;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setHR = function (o, h) {
			this.o = o;
			this.h = h;
			this.doIt = animationStep_funcDoItHR;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setWH = function (o, w, h) {
			this.o = o;
			this.w = w;
			this.h = h;
			this.doIt = animationStep_funcDoItWH;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setWHR = function (o, w, h) {
			this.o = o;
			this.w = w;
			this.h = h;
			this.doIt = animationStep_funcDoItWHR;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setXYWH = function (o, x, y, w, h) {
			this.o = o;
			this.x = x;
			this.y = y;
			this.w = w;
			this.h = h;
			this.doIt = animationStep_funcDoItXYWH;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setMaxW = function (o, maxW) {
			this.o = o;
			this.maxW = maxW;
			this.doIt = animationStep_funcDoItMaxW;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setMaxH = function (o, maxH) {
			this.o = o;
			this.maxH = maxH;
			this.doIt = animationStep_funcDoItMaxH;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_setV = function (o, v) {
			this.o = o;
			this.v = v;
			this.doIt = animationStep_funcDoItV;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_array = function (a) {
			this.a = a;
			this.doIt = animationStep_funcDoItA;
			this.resolveIDs = animationStep_funcResolveIDsA;
			return;
		}
		AnimationStep_loop = function (o, count) {
			this.o = o;
			this.count = count;
			this.step = 0;
			this.doIt = AnimationStep_funcDoItLoop;
			this.resolveIDs = animationStep_funcResolveIDsLoop;
			return;
		}
		AnimationStep_setBoolean = function (o, n, v) {
			this.o = o;
			this.n = n;
			this.v = v;
			this.doIt = animationStep_funcDoItBoolean;
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
		AnimationStep_animateHeight = function (o, targetHeight, deltaFun) {
			this.o            = o;
			this.targetHeight = targetHeight;
			this.deltaFun     = deltaFun;
			this.doIt         = function (animationRunner) {
				if (this.o.h == this.targetHeight) {
					return;
				}
				this.o.h = this.deltaFun(this.o.h, this.targetHeight);
				this.o.doClip();
				if (this.o.h != this.targetHeight) {
					animationRunner.step --;
				}
				return;
			};
			this.resolveIDs = animationStep_funcResolveIDsO;
			return;
		}
	/*
		animator class
	*/
		// functions for Animation objects:
			function animation_getRunner() {
				runner = new AnimationRunner(this);
				return runner;
			}
			function animation_run() {
				runner = new AnimationRunner(this);
				runner.run();
				return runner;
			}
			function animation_resolveIDs () {
				var i;
				for (i = this.a.length - 1; i >= 0; i --) {
					this.a[i].resolveIDs();
				}
				this.resolve = false;
				return;
			}
		// Animation object:
			Animation = function (a) {
				this.a = a;
				this.frameLength = 25;
				this.resolve = true;
				this.resolveIDs = animation_resolveIDs;
				this.run = animation_run;
				this.getRunner = animation_getRunner;
				return;
			}
		// functions for AnimationRunner objects:
			function animationRunner_funcRun () {
				if (this.animation.resolve) {
					this.animation.resolveIDs();
				}
				this.complete = false;
				this.running = true;
				this.step = 0;
				this.onStart();
				this.runSub();
				return;
			}
			function animationRunner_funcRunSub () {
				if (!this.running) {
					return;
				}
				this.onStep();
				this.animation.a[this.step].doIt(this);
				this.step ++;
				if (this.step < this.animation.a.length) {
					window.setTimeout(this.runSubCallback, this.animation.frameLength);
				} else {
					this.complete = true;
					this.running = false;
					this.onEnd();
				}
				return;
			}
			function animationRunner_isComplete () {
				return this.complete;
			}
			function animationRunner_isRunning () {
				return this.running;
			}
			function animationRunner_stop () {
				this.running = false;
			}
		// AnimationRunner object:
			AnimationRunner = function (animation) {
				this.animation = animation;
				this.onStart = animation_funcNone;
				this.onStep = animation_funcNone;
				this.onEnd = animation_funcNone;
				this.step = 0;
				this.complete = false;
				this.running = false;
				this.run = animationRunner_funcRun;
				this.stop = animationRunner_stop;
				this.runSub = animationRunner_funcRunSub;
				var thisObject = this;
				this.runSubCallback = function() { thisObject.runSub(); };
				this.isComplete = animationRunner_isComplete;
				this.isRunning = animationRunner_isRunning;
				return;
			}
			
