/*
function tellerror(msg, url, linenumber){
	trace('Error message= '+msg+'\nURL= '+url+'\nLine Number= '+linenumber);
	trace((arguments.callee) ? inspect(arguments.callee) : inspect(arguments.caller));
	return true;
}
window.onerror=tellerror;
*/
function inspect(obj) {
    var s = "";
    for (var i in obj) {
        if (typeof(obj[i]) != "function") {
            s += (i + "=" + (obj[i]) + "\n");
        } else {
            var x = " " + (obj[i]);
            x = x.substring(0, Math.min(40, x.length));
            s += (i + "=" + x + "\n");
        }
    }
    return s;
}

var consoleWnd = null;
var consoleOpened = false;
var consoleObj;
function trace(msg, overwrite) {
  return;
  if (window.console && window.console.log) {
    console.log(msg);
    return;
  }
  if (!consoleOpened) {
    var CONSOLE_WINDOW_HTML = '<ht' + 'ml><head><title>logging</title>\</head>' + 
        '<bo ' + 'dy> ' + 
        '<form name="dbgFrm"> ' + 
        '<textarea name="console" rows="25" cols="85" scrolling="auto"></textarea> ' + 
        '<input type="button" name="clear" value="clear" onclick="this.form.console.value=\'\';"> ' + 
        '</form> ' + 
        '</bo' + 'dy></ht' + 'ml>';
    consoleWnd = window.open("", "tracer" /*+ (new Date()).getTime() */, "width=750,height=500,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0");
    consoleWnd.document.open("text/html");
    consoleWnd.document.write(CONSOLE_WINDOW_HTML);
    consoleWnd.document.close();
    consoleOpened = true;
    consoleObj = consoleWnd.document.forms["dbgFrm"].console;
  }
  if (consoleOpened) {
		if (overwrite == true) {
			consoleObj.value = (msg + "\n");
		} else {
			consoleObj.value += (msg + "\n");
		}
  }
}

jQuery.extend(
	jQuery.easing,
	{
		stepAtStart: function(x, t, b, c, d) {
			//trace('stepAtStart: ' + [x, t, b, c, d].join("//"));
			return (t < 1) ? 0 : 1;
		},
		stepAtEnd: function(x, t, b, c, d) {
			//trace('stepAtEnd: ' + [x, t, b, c, d].join("//"));
			return (t < 1) ? 0 : 1;
		},
		step: function(p, n, firstNum, delta, duration) {
			return firstNum;
		}
	}
);
jQuery.extend({
	/**
	 *
	 * 
	 */
	TimelinesManager: {
		threads : {},
		timelines : [],
		getTimeline: function(id) {
			for (var i=0; i < this.timelines.length; i++) {
				if (this.timelines[i].id == id)
					return this.timelines[i];
			}
			return null;
		},
		setupTimelines: function( settings ) {
			jQuery.extend( this.timelines, settings );
			// force execution of keyFrames //fix action-like tweens?
			
			for (var i=0, __TL = this.timelines.length; i < __TL; i++) {
				var tLine = this.timelines[i];
				
				for (var oi=0, __OL = tLine.oList.length; oi < __OL; oi++) {
					var o = tLine.oList[oi];
					if (!(o.transitions && o.transitions.length)) continue;
					var tKeyFrames = [];
					//iterate transitions collection
					for (var ai=0, __TRL = o.transitions.length; ai < __TRL; ai++) {
						var pps = o.transitions[ai];
						var ppst = pps.tweens;
						var foundTw = -1;
						var tw;
						var endTweenVal = null;
						for (var ti=0; ti < ppst.length; ti++) {
							tw = ppst[ti];
							//{ prop: 'position', dtype: "css:string", tweens:[ {t0: 0.00, tf: 0.00, startval: "relative", endval: "relative", easing: "step"} ] }, 
							//{ t: 0, name: 'setProperty', params: { prop: 'position', dtype: "css:string", value: "relative"} },
							if (tw.t0 == tw.tf) {
								if (jQuery.inArray( tw.t0, tKeyFrames ) < 0) {
									var _t = 0 + tw.t0;
									tKeyFrames.push(_t);
									o.actions.push({ t: _t, name: 'setProperty', params: { prop: pps.prop, dtype: pps.dtype, value: tw.endval}});
								}
							}
							
							
						}
					}
					/*
					if (tKeyFrames.length) {
						var thisInst = this;
						//add to actions list
						jQuery.each( tKeyFrames, function(indx, _t){
							o.actions.push({ t: _t, func: function() {
									var aEls = thisInst.getAnimatedElements(tLine, _t);
									trace("got to play kframe at " + _t);
									thisInst.updateAnimatedElements({
										animatedElements: aEls
									});
								}
							});
						});
						//
					}
					*/
				}
				
			}/* */
			//
		},
		layoutEnforcedObjs: {},
		enforceLayout: function( ids ) {
			this.layoutEnforcedObjs = ids;
		},
		getActions: function(tLine, /*Array*/ t) {
			//var zobj = this.threads[tLine.id];
			var backw = (t[0] > t[1]);
			var oneval = (t[0] == t[1]);
			//trace("ga " + t.join(",") );
			var aActs = [];
			var o;
			var a;
			for (var oi=0; oi < tLine.oList.length; oi++) {
				o = tLine.oList[oi];
				if (o.actions) {
				//iterate actions collection
					for (var ai=0; ai < o.actions.length; ai++) {
						a = o.actions[ai];
						if ( (oneval && (a.t == t[0])) || ( !backw && (t[0] <= a.t) && (a.t <= t[1]) )
							|| ( backw && (t[1] <= a.t) && (a.t <= t[0]) ) ) {
							//trace("act " + o.id + " at " + a.t + " " + a.name + " " + t.join(","));
							aActs.push(jQuery.extend({"id": o.id}, a));
						}
					}
				}
			}
			return aActs;
		},
		/**
		* @param tLine timeline 
		* @param t current time
		*/
		getAnimatedElements: function(tLine, /*Array*/ tinterval) {
			var zobj = this.threads[tLine.id];
			var fpsm = tLine.fps / 1000;
			var mfps = 1000/tLine.fps;
			var frms = Math.floor(Math.abs(tinterval[1] - tinterval[0]) / mfps);
			//trace("gae " + tinterval.join(",") + " / " + frms);
			var payload = [ tinterval[1] ];
			if (frms > 0) {
				//trace("gAE " + tinterval.join(",") + " - " + frms + " " + Math.floor(tinterval[1] * fpsm));
				var nft = Math.floor(tinterval[1] * fpsm) * mfps;
				while ( nft > tinterval[0] ) {
					if (nft != tinterval[1]) payload.push(nft);
					nft -= mfps;
				}
				if (zobj && zobj.backward) {
				} else {
					payload.reverse();
				}
				//trace("gAE p:" + payload.join(","));
			}
			
			var aEls = [];
			
			var inFFwd = false; //!(tinterval[0] == tinterval[1]);
			for (var _indx = 0; _indx < payload.length; _indx++) {
				var t = payload[_indx];
			var o;
			var pps;
			var ppst;
			
			for (var oi=0; oi < tLine.oList.length; oi++) {
				o = tLine.oList[oi];
				if (!(o.transitions && o.transitions.length)) continue;
				//iterate transitions collection
				for (var ai=0; ai < o.transitions.length; ai++) {
					pps = o.transitions[ai];
					ppst = pps.tweens;
					var foundTw = -1;
					var tw;
					var endTweenVal = null;
					for (var ti=0; ti < ppst.length; ti++) {
						tw = ppst[ti];
						var inside = ((tw.t0 <= t) && (t <= tw.tf));
						
						if (inside) {
							foundTw = ti;
							break;
						} else if (inFFwd) { 
							//trace("getAnimatedElements times: " + t + " vs " + tw.tf);
							if (t > tw.tf) { 
								//do not assume ordered list of tweens. must consider getting max tf lower than t
								if (endTweenVal == null || endTweenVal.tf < tw.tf) {
									endTweenVal = {id: o.id, prop: pps.prop, val: tw.endval, type: pps.dtype, tf: tw.tf};
									if (tw.mu) {
										endTweenVal.mu = tw.mu;
									}
								}
							}
						}
					}
					
					var now;
					if (foundTw != -1) {
						tw = ppst[foundTw];
						var twduration = (tw.tf - tw.t0); 
						var n = Math.abs(t - tw.t0);
						// Figure out where we are in the animation
						if (twduration == 0) twduration = 0.0000001;
						var p = n / twduration; //add something to avoid divide by 0 
						// If the easing function exists, then use it 
						if (!tw.easing || !jQuery.isFunction( jQuery.easing[tw.easing] )) tw.easing = "linear";
						//treat here special step-like easings
						if ((tw.easing == "stepAtStart") || (tw.easing == "stepAtEnd")) {
								var eps = (1000/tLine.fps);
								//try {
									if (tw.easing == "stepAtStart") {
										now = (n < eps) ? tw.startval : tw.endval;
									} else {
										now = (Math.abs(t - tw.tf) < eps) ? tw.endval : tw.startval;
									}
									//trace("at " + t + " " + tw.easing + " " + o.id + " " + pps.prop + " " + now);
								//} catch(e) {
									//trace(e.message);
								//}
							
						} else {
							if (pps.dtype.indexOf("custom:") == 0) {
								try {
									var cEasedVal = jQuery.easing[tw.easing](p, n, 0, 1, twduration);
									var hndln = pps.dtype.split(":")[1];
									var dotI = hndln.lastIndexOf(".");
									var getHndln = (dotI != -1) ? 
										(hndln.substring(0, dotI+1) + "get" +  hndln.substring(dotI+1)) :
										"get" +  hndln;
									var hnd;
									
									eval("hnd = " + getHndln);
									
									now = hnd({easedVal: cEasedVal, startval:tw.startval, endval:tw.endval});
									//trace(getHndln + " now = " + now.top + " x " + now.left);
								} catch(e) {
									//trace(e.message);
									continue;
								}
							} else {
								try {
									if (pps.dtype == "css:color") {
										var /*red, green, blue,*/ sr, sg, sb, er, eg, eb;
										var ishexa = (typeof(tw.startval) == "string");
										if (ishexa) { 
											tw.startval = [ parseInt(tw.startval.substr(1, 2), 16),
												parseInt(tw.startval.substr(3, 2), 16),
												parseInt(tw.startval.substr(5, 2), 16)];
										}
										sr = tw.startval[0]; sg = tw.startval[1]; sb = tw.startval[2];
										ishexa = (typeof(tw.endval) == "string");
										if (ishexa) { tw.endval = [ parseInt(tw.endval.substr(1, 2), 16),
												parseInt(tw.endval.substr(3, 2), 16),
												parseInt(tw.endval.substr(5, 2), 16)]; }
										er = tw.endval[0]; eg = tw.endval[1]; eb = tw.endval[2];
										//trace("rgb " + er + " " + eg + " " + eb);
										
										now = [(er-sr) ? parseInt(jQuery.easing[tw.easing](p, n, sr, (er-sr), twduration)) : er,
											(eg-sg) ? parseInt(jQuery.easing[tw.easing](p, n, sg, (eg-sg), twduration)) : eg,
											(eb-sb) ? parseInt(jQuery.easing[tw.easing](p, n, sb, (eb-sb), twduration)) : eb ];
										//trace("now " + now.join(",") + "--" + [p, n, sb, (eb-sb), twduration].join("/") + "==" + jQuery.easing[tw.easing](p, n, sb, (eb-sb), twduration));
										
									} else {
										now = jQuery.easing[tw.easing](p, n, tw.startval, (tw.endval-tw.startval), twduration);
										if (pps.dtype == "css:int") {
											//throw new Error("invalid eased value!");
											//trace('isNaN ' + isNaN(now));
											now = Math.round(now);
											//trace('now ' + [o.id,pps.prop, now].join());
											//continue;
										}
									}
								} catch(e) {
									trace(e.message);
									continue;
								}
							}
						}
						var aObj = {id: o.id, prop: pps.prop, val: now, type: pps.dtype};
						if (tw.mu) {
							aObj.mu = tw.mu;
						}
						aEls[aEls.length] = aObj;
					} else if (inFFwd) {
						if (endTweenVal != null) {
							aEls[aEls.length] = endTweenVal;
							//trace("getAnimatedElements ffwd "  + endTweenVal.prop + " - endValue: " + endTweenVal.val);
						}
					}
					
				}
			}
			}
			return aEls;
		},
		animationIsRunning: function(tLine) {
			if (typeof(tLine) == "string") {
				tLine = this.getTimeline(tLine);
			}
			return (this.threads[tLine.id] && this.threads[tLine.id].timer);
		},
		stopAnimation: function(tLine) {
			//if (this.threads[tLine.id] && this.threads[tLine.id].timer) {
			if (this.animationIsRunning(tLine)) {
				//animation is running. we'll stop it
				if (typeof(tLine) == "string") {
					tLine = this.getTimeline(tLine);
				}
				//trace("animation " + tLine.id + " is running. we'll stop it");
				window.clearInterval(this.threads[tLine.id].timer);
				this.threads[tLine.id].timer = null; //undefined;
				delete (this.threads[tLine.id]);
			}
		},
		cancelAnimation: function(tLine) {
			this.stopAnimation(tLine);
			this.gotoAnimationFrame(tLine, 1, true);
		},
		pauseAnimation: function(tLine) {
			if (typeof(tLine) == "string") {
				tLine = this.getTimeline(tLine);
			}
			if (this.animationIsRunning(tLine)) {
				var z = this.threads[tLine.id];
				var ct = z.lastAccess;
				tLine.tOffset = parseInt(ct) - z.startTime;
				//trace("pauseAnimation " + tLine.id + ", tOffset=" + tLine.tOffset);
				this.stopAnimation(tLine);
			}
		},
		executeAnimationActions: function(acts) {
			var hnd;
			if (acts && acts.length) {
				var ac;
				for (var ai=0; ai < acts.length; ai++) {
					ac = acts[ai];
					var acId = "" + ac.id;
					var acName = "" + ac.name;
					var acParams = ac.params; //clone them?
					var acFunc = ac.func;
					try {
						if ($.isFunction(acFunc)) {
							hnd = acFunc;
						} else {
							if (acName == "setProperty") {
								hnd = function(objectId, prms) {
									//trace("setProperty " + objectId + " : " + inspect(prms));
									$("#" + objectId).css(prms.prop, prms.value);
								}
							} else {
								eval("hnd = " + acName);
							}
						}
						hnd(acId, acParams);
					} catch(ex) {
						//to be or not to be?
						trace("actionThread err: " + inspect(ex));
					}
				}
			}
		},
		updateAnimatedElements: function(aEls) {
			//handle animated elems
			//var aEls = opts.animatedElements;
			if (aEls && aEls.length) {
				//trace("elems: " + aEls.length);
				var el;
				for (var ai=0; ai < aEls.length; ai++) {
					el = aEls[ai];
					//if ($.inArray( el.id, this.layoutEnforcedObjs ) != -1) {
					if (this.layoutEnforcedObjs[el.id]) {
						var elidv = this.layoutEnforcedObjs[el.id];
						if (!$("#wrapperOf" + elidv).is("div")) {
						//create a wrapper for the el to preserve its initial footprint
							var __elid = $("#"+ elidv);
							var __h = __elid.height();
							var __w = __elid.width();
							var elidp = __elid.parent();
							if (elidp.is("a")) {
								elidp = elidp.parent();
							}
							elidp.append("<div id='wrapperOf" + elidv + "'  style='width: " + __w + "px; height: " + __h + "px; '></div>");
							//trace("wrapper created for " + el.id);
							/*$('#wrapperOf' + elidv).click(function(event) {
								event.preventDefault(); event.stopPropagation(); return false;
							});*/
						}
					}
					if (el.type.indexOf("css") == 0) {
						if (el.type.indexOf("css:int") == 0) {
							$("#"+ el.id).css(el.prop, el.mu ? ("" + Math.round(el.val) + el.mu) : Math.round(el.val));
						} else if (el.type == "css:color") {
							$("#"+ el.id).css(el.prop, (typeof(el.val) == 'string') ? el.val : 'rgb(' + el.val.join(",") + ')');
						} else {
							$("#"+ el.id).css(el.prop, el.val);
						}
						
					} else if (el.type.indexOf("custom:") == 0) {
						
						var hndln = el.type.split(":")[1];
						var dotI = hndln.lastIndexOf(".");
						var setHndln = (dotI != -1) ? 
							(hndln.substring(0, dotI+1) + "set" +  hndln.substring(dotI+1)) :
							"set" +  hndln;
						var hnd;
						try {
							eval("hnd = " + setHndln);
							hnd(el.id, el.val);
						} catch(ex) {
							//to be or not to be?
						}
					}
					
				}
			}
		},
		normalizeFrameStep: function (tLine, params) {
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			if (typeof(params) == 'object') {
				if (typeof(params.frameStep) == "string") {
					params.frameStep = (params.frameStep.toLowerCase() == "start") ?
					 0 : ( (params.frameStep.toLowerCase() == "end") ? 
					 	((tLine.duration / 1000) * tLine.fps) : -1 );
				}
				
				params.frameStep = Math.max(0, Math.min(params.frameStep, (tLine.duration / 1000) * tLine.fps));
				//trace("normalizeFrameStep " + tLine.id + " frameStep=" + params.frameStep);
				return params.frameStep;
			} else {
				var normStep = { frameStep: params };
				this.normalizeFrameStep(tLine, normStep);
				return normStep.frameStep;
			}
		},
		gotoAnimationFrame: function(tLine, frameStep, fwd) {
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			
			frameStep = this.normalizeFrameStep(tLine, frameStep);
			//trace("gotoAnimationFrame " + tLine.id + " frameStep=" + frameStep);
			if ((0 <= frameStep) && (frameStep <= (tLine.duration / 1000) * tLine.fps)) {
				var ct = (frameStep * 1000)/tLine.fps;
				//trace(" ct = " + ct);
				
				var zobj = this.threads[tLine.id];
				if (zobj) {
					//trace(" gAF zobj ");
					(fwd) ? zobj.handleTimeFrame(0, ct) : zobj.handleTimeFrame(ct, ct);
				} else {
					//trace(" gAF !zobj ");
					var t = (fwd) ? [0, ct] : [ct, ct];
					var acts = this.getActions(tLine, t);
					var aEls = this.getAnimatedElements(tLine, t);
					if (acts) this.executeAnimationActions(acts);
					if (aEls) this.updateAnimatedElements(aEls);
				}
			}
		},
		gotoAnimationFrameAndPlay: function(tLine, params) {
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			this.normalizeFrameStep(tLine, params);
			this.gotoAnimationFrame(tLine, params.frameStep);
			var startArgs = jQuery.extend({ tOffset: (params.frameStep * 1000)/tLine.fps }, params);
			if (params.loopAtEnd == true) {
				startArgs.loopAtEnd = 'gotoAnimationFrameAndPlay';
			}
			this.startAnimation(tLine, startArgs);
		},
		gotoAnimationFrameAndPlayBackward: function(tLine, params) {
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			this.normalizeFrameStep(tLine, params);
			this.gotoAnimationFrame(tLine, params.frameStep);
			//trace("gotoAnimationFrameAndPlayBackward " + tLine.id + " frameStep=" + params.frameStep);
			var startArgs = jQuery.extend({ tOffset: /*tLine.duration - */(params.frameStep * 1000)/tLine.fps, backward: true}, params);
			if (params.loopAtEnd == true) {
				startArgs.loopAtEnd = 'gotoAnimationFrameAndPlayBackward';
			}
			this.startAnimation(tLine, startArgs);
		},
		ffwdAnimationFrame: function(tLine, frameStep) {
			this.gotoAnimationFrame(tLine, frameStep, true);
		},
		ffwdAnimationFrameAndPlay: function(tLine, params) {
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			this.normalizeFrameStep(tLine, params);
			this.ffwdAnimationFrame(tLine, params.frameStep);
			var startArgs = jQuery.extend({ tOffset: (params.frameStep * 1000)/tLine.fps }, params);
			if (params.loopAtEnd == true) {
				startArgs.loopAtEnd = 'gotoAnimationFrameAndPlay';
			}
			this.startAnimation(tLine, startArgs);
		},
		ffwdAnimationFrameAndPlayBackward: function(tLine, params) {
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			this.normalizeFrameStep(tLine, params);
			this.ffwdAnimationFrame(tLine, params.frameStep);
			var startArgs = jQuery.extend({ tOffset: /*tLine.duration - */(params.frameStep * 1000)/tLine.fps, backward: true}, params);
			if (params.loopAtEnd == true) {
				startArgs.loopAtEnd = 'ffwdAnimationFrameAndPlayBackward';
			}
			this.startAnimation(tLine, startArgs);
		},
		backAndForthAnimation: function(tLine, params) {
			var ps = {backAndForth: true};
			if (params) jQuery.extend(ps, params);
			//trace("backAndForthAnimation: " + inspect(params));
			this.startAnimation(tLine, ps);
		},
		loopAnimation: function(tLine, params) {
			var ps = {loopAtEnd: 'loopAnimation'};
			if (params) jQuery.extend(ps, params);
			//trace("loopAnimation: " + inspect(params));
			this.startAnimation(tLine, ps);
		},
		startAnimation: function(tLine, _args) { //tOffset, backward) {
			var params = {};
			if (_args) jQuery.extend(params, _args);
			
			if (params && params.delay) {
				var _delay = 0 + params.delay;
				params.delay = null;
				delete params.delay;
				var thisObj = this;
				window.setTimeout(function () {
					thisObj.startAnimation(tLine, params); 
				}, _delay);
				return;
			}
			if (typeof(tLine) == "string") { tLine = this.getTimeline(tLine); }
			//trace("startAnimation " + tLine.id + ", params=" + inspect(params));
			if (tLine.tOffset) {
				params.tOffset = 0 + tLine.tOffset;
				tLine.tOffset = null;
			} else {
				this.stopAnimation(tLine);
			}
			var thisInst = this;
			
			
			
			var z = {};
			z.timeline = tLine;
			z.params = params;
			z.startTime = (new Date()).getTime();
			//z.lastAccess = z.startTime - 1;
			if (params && params.backward) {
				z.backward = true;
				//acts.reverse();
			}
			
			if (params && params.tOffset) {
				if (z.backward) {
					z.startTime -= z.timeline.duration - params.tOffset;
				} else {
					z.startTime -= params.tOffset;
				}
				z.params.tOffset = params.tOffset = 0;
				delete z.params.tOffset; delete params.tOffset;
			}
			
			z.lfrt = 1000/tLine.fps;
			z.handleTimeFrame = function(t0, tf) {
				
				var acts = thisInst.getActions(this.timeline, [t0, tf]);
				var aEls = thisInst.getAnimatedElements(this.timeline, [t0, tf]);
				
				this.lastAccess = (new Date()).getTime();
				
				if (acts) thisInst.executeAnimationActions(acts);
				if (aEls) thisInst.updateAnimatedElements(aEls);
				//trace('htf: ' + t0 + " " + tf + " " + this.lastAccess%100000 + " " + acts.length + " "  + aEls.length);
			};
			z.enterFrame = function() {
				var ct = (new Date()).getTime();
				this.lfrt = (this.lastAccess) ? ct - this.lastAccess : 1000/tLine.fps;
				
				//trace("eF = " + this.lfrt);
				if (ct > this.timeline.duration + this.startTime) {
					//trace("* ct=" + ct + " duration=" + this.timeline.duration + " startTime=" +  this.startTime + " lfrt=" + this.lfrt);
					//finish handling last frame(s)
					//if (this.lastAccess - this.startTime > this.timeline.duration) {
					if (this.backward) {
						this.handleTimeFrame(0, 0);
					} else {
						this.handleTimeFrame(this.lastAccess - this.startTime, this.timeline.duration);
					}
					//}
					// Stop the timer 
					//$.TimelinesManager.stopAnimation(this.timeline);
					thisInst.stopAnimation(this.timeline);
					if (this.params && this.params.backAndForth) {
						if (this.params.backward) {
							this.params.backward = false;
						} else {
							this.params.backward = true;
						}
						this.params.cycles -= 0.5;
						if (this.params.cycles > 0) {
							thisInst.backAndForthAnimation(this.timeline.id, this.params);
						}
					} else if (this.params && this.params.loopAtEnd) {
						if (this.params.frameStep) {
							this.params.frameStep = (this.backward) ? "end" : "start";
						}
						this.params.cycles -= 1;
						if (this.params.cycles > 0) {
							thisInst[this.params.loopAtEnd](this.timeline, this.params);
						}
					} 
					/*
					window.clearInterval(this.timer);
					this.timer = null;
					*/
					return;
				}
				var cTime = ct - this.startTime;
				var lastCTime = (this.lastAccess) ? this.lastAccess - this.startTime : 0;
				if (this.backward) {
					cTime = this.timeline.duration - cTime;
					lastCTime = this.timeline.duration - lastCTime;
					this.handleTimeFrame(lastCTime, cTime);
				} else {
					this.handleTimeFrame(lastCTime, cTime);
				}
			}
			
			z.timer = window.setInterval(function(){
				z.enterFrame();
			}, (1000/tLine.fps) /*z.lfrt*/);
			this.threads[tLine.id] = z;
			z.enterFrame();
		}
	}
});
