var Strike = function() {
	
	//to do: Stage scaling; fix inheritance issues, especially with SpriteSheet. 
	
	var idcount = 0;
	var IE = navigator.userAgent.indexOf('MSIE')>-1;
	
	Function.prototype.bind = function(obj) {
		var method = this, temp = function() {
			return method.apply(obj, arguments);
		};
		return temp;
	}
	Function.prototype.inherits = function(obj) {
		this.prototype = new obj;
		this.constructor = this.bind(this);
		this.parent = obj.prototype;
		return (this);
	}
	
	function getArrIdx(arr,obj) {
		for (var k=0;k<arr.length;k++) {
			if (arr[k]===obj) return (k);
		}
		return (-1);
	}
	
	var _MainEventList = [];
	
	function DivDisplay(w,h,scaleMode,backgroundColor,stageParent) {
		idcount = 1;
		this.stage = new Div(true,w,h,stageParent);
		this.stageParent = stageParent;
		this._listeners = {};
		setInterval(this.render.bind(this),15);
		
		this.stage._$.style.position = 'absolute';
		this.stage._$.style.width = w+'px';
		this.stage._$.style.height = h+'px';
		if (backgroundColor != null) {
			this.stage._$.style.backgroundColor = backgroundColor;
		}
		//this.stage._$.style.overflow = "hidden";
		
		if (scaleMode == "full") {
			this._fullsize();
			window.onresize = this._fullsize.bind(this);
		} else if (scaleMode == "proportional") {
			this._proportional();
			window.onresize = this._proportional.bind(this);
		} else if (scaleMode == "proportionalWidth") {
			this._proportionalWidth();
			window.onresize = this._proportionalWidth.bind(this);
		}
	}
	DivDisplay.prototype.render = function(evt) {
		if (s == null) {
            var s = this.stage;
        }
        s.dispatchEvent(new Event("enterframe"));
	}
	DivDisplay.prototype._fullsize = function(evt) {
		this.stage.setscaleX((IE?document.documentElement.clientWidth:window.innerWidth)/this.stage.scaleX()/this.stage.stageWidth);
		this.stage.setscaleY((IE?document.documentElement.clientHeight:window.innerHeight)/this.stage.scaleY()/this.stage.stageHeight);
	}
	DivDisplay.prototype._proportional = function(evt) {
		//var tosx = (IE?document.documentElement.clientWidth:window.innerWidth)/this.stage.scaleX()/this.stage.stageWidth;
		//var tosy = (IE?document.documentElement.clientHeight:window.innerHeight)/this.stage.scaleY()/this.stage.stageHeight;
		var tosx = (this.stageParent.offsetWidth)/this.stage.scaleX()/this.stage.stageWidth;
		var tosy = (this.stageParent.offsetHeight)/this.stage.scaleY()/this.stage.stageHeight;
		var tos = tosx>tosy?tosy:tosx;
		this.stage.setscaleX(tos);
		this.stage.setscaleY(tos);
	}
	DivDisplay.prototype._proportionalWidth = function(evt) {
		var tosx = (IE?document.documentElement.clientWidth:window.innerWidth)/this.stage.scaleX()/this.stage.stageWidth;
	//	var tosy = (IE?document.documentElement.clientHeight:window.innerHeight)/this.stage.scaleY()/this.stage.stageHeight;
		var tos = tosx;//tosx>tosy?tosy:tosx;
		this.stage.setscaleX(tos);
		this.stage.setscaleY(tos);
	}
	
	function Point(x,y) {
		this.x = x;
		this.y = y;
	}
	
	function Matrix(_a,_b,_c,_d,_tx,_ty,_u,_v,_w) {
		this.a = _a || 1;
		this.b = _b || 0;
		this.c = _c || 0;
		this.d = _d || 1;
		this.tx = _tx || 0;
		this.ty = _ty || 0;
		this.u = _u || 0;
		this.v = _v || 0;
		this.w = _w || 1;
	}
	Matrix.prototype.translate = function(x,y) {
		this.tx+=x;
		this.ty+=y;
	}
	Matrix.prototype.scale = function(sx,sy) {
		this.a *= sx;
		this.d *= sy;
		this.tx *= sx;
		this.ty *= sy;
	}
	Matrix.prototype.innerScale = function(sx,sy) {
		var m = new Matrix();
		m.scale(sx,sy);
		m = m.multiply(this);
		this.a = m.a;
		this.b = m.b;
		this.c = m.c;
		this.d = m.d;
		this.tx = m.tx;
		this.ty = m.ty;
	}
	Matrix.prototype.rotate = function(deg) {
		var sine = Math.sin(deg*(Math.PI/180));
		var cosine = Math.cos(deg*(Math.PI/180));
		var k = [this.a,this.b,this.c,this.d,this.tx,this.ty];
		this.a = k[0]*cosine - k[1]*sine;
		this.b = k[0]*sine + k[1]*cosine;
		this.c = k[2]*cosine - k[3]*sine;
		this.d = k[2]*sine + k[3]*cosine;
		//this.tx = k[4]*cosine - k[5]*sine;
		//this.ty = k[4]*sine + k[5]*cosine;
	}
	Matrix.prototype.transformPoint = function(point) {
		var prime = new Point(point.x*this.a+point.y*this.c+this.tx,point.x*this.b+point.y*this.d+this.ty);
		return (prime);
	}
	Matrix.prototype.deltaTransformPoint = function(point) {
		var prime = new Point(point.x*this.a+point.y*this.c,point.x*this.b+point.y*this.d);
		return (prime);
	}
	Matrix.prototype.multiply = function(m) {
		var mult = new Matrix(this.a*m.a+this.b*m.c+this.u*m.tx,
							  this.a*m.b+this.b*m.d+this.u*m.ty,
							  this.c*m.a+this.d*m.c+this.v*m.tx,
							  this.c*m.b+this.d*m.d+this.v*m.ty,
							  this.tx*m.a+this.ty*m.c+this.w*m.tx,
							  this.tx*m.b+this.ty*m.d+this.w*m.ty,
							  this.a*m.u+this.b*m.v+this.u*m.w,
							  this.c*m.u+this.d*m.v+this.v*m.w,
							  this.tx*m.u+this.ty*m.u+this.w*m.w);
		return (mult);
	}
	Matrix.prototype.inverse = function() {
		var n = this.a*this.d-this.b*this.c;
		var inv = new Matrix(this.d/n,
							 -this.b/n,
							 -this.c/n,
							 this.a/n,
							 (this.c*this.ty-this.d*this.tx)/n,
							 -(this.a*this.ty-this.b*this.tx)/n,
							 0,0,1);
		return (inv);
	}
	Matrix.prototype.getScaleX = function() {
		return (Math.sqrt(this.a * this.a + this.b * this.b));
	}
	Matrix.prototype.getScaleY = function() {
		return (Math.sqrt(this.c * this.c + this.d * this.d));
	}
	Matrix.prototype.getRotation = function() {
		var px = this.deltaTransformPoint(new Point(0,1));
		return ((180/Math.PI) * Math.atan2(px.y, px.x) - 90);	
	}
	
	///EVENTS///
	function Event(type,currentTarget,target) {
		this.type = type;
		this.currentTarget = currentTarget;
		this.target = target;
	}
	
	function EventDispatcher() {}
	EventDispatcher.prototype.dispatchEvent = function(evt) {
		for (var i in _MainEventList) {
			for (var k in _MainEventList[i]) {
				if (i == evt.type && _MainEventList[i][k].div == this) {
					evt.currentTarget = this; //switch this to currentTarget...?
					_MainEventList[i][k].fun(evt);
					return (true);
				}
			}
		}
	}
	EventDispatcher.prototype._addMainListener = function(type,fun) {
		if (_MainEventList[type]) {
			_MainEventList[type].push({div:this,fun:fun});
		} else {
			_MainEventList[type] = [{div:this,fun:fun}];
		}
	}
	EventDispatcher.prototype._removeMainListener = function(type,fun) {
		for (var k in _MainEventList[type]) {
			if (_MainEventList[type][k].div == this && _MainEventList[type][k].fun == fun) {
				delete (_MainEventList[type][k].div);
				delete (_MainEventList[type][k].fun);
				_MainEventList[type].splice(k,1);
				if (_MainEventList[type].length<1) {
					delete _MainEventList[type];
				}
			}
		}
	}
	EventDispatcher.prototype._detachFromMain = function() {
		//remove all listeners associated with this div from the main event list... 
		for (var j in _MainEventList) {
			for (var k in _MainEventList[j]) {
				if (_MainEventList[j][k].div == this) {
					var mlist = _MainEventList[j].splice(k,1);
					mlist = null;
					delete mlist;
				}
			}
		}
		for (var c=0;c<this.children.length;c++) {
			this.children[c]._detachFromMain();
		}
	}
	EventDispatcher.prototype.addEventListener = function(type,fun) {
		if (this._listeners[type]) {
			if (this.hasEventListener(type,fun)) {
				return (false);
			}
			this._listeners[type].push(fun);
		} else {
			this._listeners[type] = [fun];
		}
		this._addMainListener(type,fun);
	}
	EventDispatcher.prototype.hasEventListener = function(type,fun,pos) {
		//pos flag returns the index of the listener on success (used for removal). 
		if (!this._listeners[type]) return (false);
		var len = this._listeners[type].length;
		for (var i=0;i<len;i++) {
			if (this._listeners[type][i] == fun) return (pos?i:true);
		}
		return (false);
	}
	EventDispatcher.prototype.removeEventListener = function(type,fun) {
		var i = this.hasEventListener(type,fun,true);
		if (i !== false) {
			this._listeners[type].splice(i,1);
			this._removeMainListener(type,fun);
			if (this._listeners[type].length<1) {
				this._listeners[type] = null;
				delete this._listeners[type];
			}
		}
		for (var k in this._listeners) {
			return (true);
		}
		this._$.style.cursor = '';
	}
	EventDispatcher.prototype.destroyEventListeners = function() {
		//remove your listeners before calling this. Helps to free up memory. 
		this._listeners = {};
		this._detachFromMain();
	}
	
	//main graphic component//
	Div.inherits(EventDispatcher);
	function Div(isStage,w,h,stageParent) {
		this.id = 'sd'+idcount;
		this._listeners = [];
		
		idcount++;
		
		this.transform = new Matrix();
		this.children = [];
		this._rotation = 0;
		this._alpha = 1;
		this._$ = document.createElement('div');
		this.$ = document.createElement('div');
		if (!isStage) {
			this._$.style.position = 'absolute';//IE?'absolute':'absolute';
			//this._$.style.width = '100px'; //10px works nicely for firefox. 
			//this._$.style.height = '100px';//'1%';
			this._$.style.overflow='visible';// = 'visible';
		//	this.$.style.overflow='visible';
			this.$.style.position = 'absolute';
			//this.$.style.width = '100%'; //also can work as 1px. 
			//this.$.style.height = '100%';
		}
		this._$.appendChild(this.$);

		
		if (isStage) {
			//this._$.style.position = 'absolute';
			this.stage = this;
			this.stageWidth = w;
			this.stageHeight = h;
			stageParent ? stageParent.appendChild(this._$) : document.body.appendChild(this._$);
		}
		
		//create references in the dom objects to this. 
		this.$.div = this;
		this._$.div = this;			
	}
	Div.prototype.assignStage = function(s,st) {
		s.stage = st;
		for (var k=0;k<s.children.length;k++) {
			s.assignStage(s.children[k],st);
		}
	}
	Div.prototype._invalidate = function() {
		//align to transforms. 
		this._$.style.MozTransformOrigin = '0px 0px';//this.$.offsetWidth/2+'px '+this.$.offsetHeight/2+'px'; //matches IE's center origin. 
		this._$.style.webkitTransformOrigin = '0px 0px';
		this._$.style.OTransformOrigin = '0px 0px';
		//disabled for Mack.
		//this._$.style.MozTransform = 'matrix('+this.transform.a+','+this.transform.b+','+this.transform.c+','+this.transform.d+',0,0)';
		//this._$.style.webkitTransform = 'matrix('+this.transform.a+','+this.transform.b+','+this.transform.c+','+this.transform.d+',0,0)';
		//this._$.style.OTransform = 'matrix('+this.transform.a+','+this.transform.b+','+this.transform.c+','+this.transform.d+',0,0)';

		var conc = IE?this.concatMatrixIE():this.transform;
        var _truealpha = this._alpha;
        if (IE) {
            var n = this;
            while (n.parent) {
                n = n.parent;
                _truealpha *= n._alpha;
            }
        }
		if (this._$.style.overflow!='visible') {
			//this is basically a hack for SpriteSheet's purposes. With hidden overflow, or anything else, 
			//IE needs to scale the outer div; unfortunately, it can't understand the actual width of that outer div based on inner visible overflows. 
			//So IE scales and places each $ inner div separately in a hierarchy. However, with hidden overflow, this problem is solved, 
			//as is the case with the SpriteSheet. Then the outer div MUST be scaled, not the inner one. 
			this._$.style.filter = "progid:DXImageTransform.Microsoft.Matrix(SizingMethod = 'auto expand', M11='"+conc.a+"', M12='"+conc.c+"', M21='"+conc.b+"', M22='"+conc.d+"') progid:DXImageTransform.Microsoft.Alpha(opacity="+(_truealpha*100)+")";
		} else {
			this.$.style.filter = "progid:DXImageTransform.Microsoft.Matrix(SizingMethod = 'auto expand', M11='"+conc.a+"', M12='"+conc.c+"', M21='"+conc.b+"', M22='"+conc.d+"') progid:DXImageTransform.Microsoft.Alpha(opacity="+(_truealpha*100)+")";
		}
		//this.$.style.filter = this.$.style.filter;
		//this.$.style.filter = this._$.style.filter;
		
		/*if (IE) {
			if(!this.halfW) {
				this.halfW = (this._$.offsetWidth>this.$.offsetWidth?this._$.offsetWidth:this.$.offsetWidth)/2;
				this.halfH = (this.$.offsetHeight>this.$.offsetHeight?this._$.offsetHeight:this.$.offsetHeight)/2;
			}
			// determine how far origin has shifted
			var a = Math.abs(this.transform.a);  // or go ternary
			var c = Math.abs(this.transform.c);
			var sx = (a - 1)*(this.halfW) + c*(this.halfH);
			// vertical shift
			b = Math.abs(this.transform.b);
			d = Math.abs(this.transform.d);
			var sy = b*(this.halfW) + (d - 1)*(this.halfH);
		} else {*/
			var sx = 0;
			var sy = 0;
		//}
		
		if (IE) {
			this._$.style.left = Math.round(conc.tx-(this.parent?this.parent.transform.tx:0)-sx)+'px';
			this._$.style.top = Math.round(conc.ty-(this.parent?this.parent.transform.ty:0)-sy)+'px';
			for (var k in this.children) {
				this.children[k]._invalidate();
			}
		} else {
			this._$.style.left = Math.round(this.transform.tx)+'px';
			this._$.style.top = Math.round(this.transform.ty)+'px';
			/*if (IE) {
				for (var k in this.children) {
					this.children[k]._invalidate();
				}
			}*/
		}
		
		this._$.style.opacity = this._alpha;
		this._$.style.webkitOpacity = this._alpha;
	}
	Div.prototype.addChild = function(s) {
		if (!s) return (false);
		if (s.parent) {
			s.parent.removeChild(s,false);
		}
		s.parent = this;
		//recursively assign the stage to all children. 
		this.assignStage(s,this.stage);
		this.children.push(s);
		try {
			this._$.appendChild(s._$);
		} catch (err) {};
		s._$.style.zIndex = this.children.length;
	}
	Div.prototype.addChildAt = function(s,k) {
		s.parent = this;
		this.assignStage(s,this.stage);
		this.children.splice(k,0,s);
		this._$.appendChild(s._$);
		s._$.style.zIndex = k;
	}
	Div.prototype.getChildAt = function(k) {
		return (this.children[k]);
	}
	Div.prototype.removeChild = function(s) {
		var idx = !IE?this.children.indexOf(s):getArrIdx(this.children,s);
		if (idx==-1) {
			return (false);
		}
		s.parent._$.removeChild(s._$);
		s.parent = null;
		this.assignStage(s,null);
		this.children.splice(idx,1);
		try {
			this._$.removeChild(s);
		} catch (err) {}
		delete (s);
	}
	Div.prototype.removeChildAt = function(k) {
		this.removeChild(this.children[k]);
		this._$.removeChild(children[k]._$);
	}
	Div.prototype.setChildIndex = function(c,i) {
		var ix = !IE?this.children.indexOf(c):getArrId(this.children,s);
		if (ix>-1) {
			this.children.splice(ix,1);
			this.children.splice(i,0,c);
		}
		for (var ki = 0;ki<this.children.length;ki++) {
			this.children[ki]._$.style.zIndex = ki;
		}
	}
	Div.prototype.numChildren = function() {
		return (this.children.length);
	};
	
	Div.prototype.x = function() {
		return (this.transform.tx);
	}
	Div.prototype.setx = function(_x) {
		if (isNaN(_x)) return (false);
		this.transform.tx = Number(_x);
		this._invalidate();
	};
	Div.prototype.y = function() {
		return (this.transform.ty);
	}
	Div.prototype.sety = function(_y) {
		if (isNaN(_y)) return (false);
		this.transform.ty = Number(_y);
		this._invalidate();
	};
	Div.prototype.rotation = function() {
		return (this._rotation);
	}
	Div.prototype.setrotation = function(_r) {
		if (_r%90==0) _r+=.1;
		this.transform.rotate(_r-this.transform.getRotation());
		this._rotation = _r;
		this._invalidate();
	}
	Div.prototype.scaleX = function() {
		return (this.transform.getScaleX());
	}
	Div.prototype.setscaleX = function(_sx) {
		this.transform.innerScale(_sx,1);
		this._invalidate();
	}
	Div.prototype.scaleY = function() {
		return (this.transform.getScaleY());
	}
	Div.prototype.setscaleY = function(_sy) {
		this.transform.innerScale(1,_sy);
		this._invalidate();
	}
	Div.prototype.width = function() {
			return (this._getwidth());
	}
	Div.prototype.setwidth = function(_w) {
		if (this._getwidth()>1) {
			this.setscaleX(_w/this._getwidth());
		}
	}
	Div.prototype._getwidth = function() {
		var a = this._$.style.width.substr(0,this._$.style.width.length-2);
		var b = this.$.style.width.substr(0,this.$.style.width.length-2);
		var wstr = a>b?a:b;
		for (var c in this.children) {
			var k = this.children[c];
			var kr = (k._getwidth()+k.x());//*this.scaleX();
			if (k.x()<0) {
				kr+=-k.x()*this.scaleX();
			}
			if (kr>wstr) {
				wstr = kr;
			}
		}
		return (wstr*this.scaleX());
	}
	Div.prototype.height = function() {
		return (this._getheight());
	}
	Div.prototype.setheight = function(_h) {
		if (this._getheight()>1) {
			this.setscaleY(_h/this._getheight());
		}
	}
	Div.prototype._getheight = function() {
		var a = this._$.style.height.substr(0,this._$.style.height.length-2);
		var b = this.$.style.height.substr(0,this.$.style.height.length-2);
		var hstr = a>b?a:b;
		for (var c in this.children) {
			var k = this.children[c];
			var kb = k._getheight()+k.y();//*this.scaleY();
			if (k.y()<0) {
				kb+=-k.y()*this.scaleY();
			}
			if (kb>hstr) {
				hstr = kb;
			}
		}
		return (hstr*this.scaleY());
	}
	Div.prototype.alpha = function() {
		return (this._alpha);
	}
	Div.prototype.setalpha = function(_a) {
		this._alpha = _a;
		this._invalidate();
	}
	
	Div.prototype.localToGlobal = function(point) {
		return (this.concatMatrix().transformPoint(point));
	}
	Div.prototype.globalToLocal = function(point) {
		return (this.concatMatrix().inverse().transformPoint(point));
	}
	
	Div.prototype.concatMatrix = function(s,m) {
		if (s == null) {
			s = this;
			var m = new Matrix(this.transform.a,this.transform.b,this.transform.c,this.transform.d,this.transform.tx,this.transform.ty);
		}
		while (s = s.parent) {
			m = m.multiply(s.transform);
			this.concatMatrix(s,m); //was m=...but that changes the result... 
		}	
		return (m);
	}
	
	Div.prototype.concatMatrixIE = function(s,m) {
		if (s == null) {
			s = this;
			var m = new Matrix(this.transform.a,this.transform.b,this.transform.c,this.transform.d,this.transform.tx,this.transform.ty);
		}
		while (s = s.parent) {
			if (s ==this.stage) continue;
			m = m.multiply(s.transform);
			this.concatMatrix(s,m); //was m=...but that changes the result... 
		}	
		return (m);
	}
	
	//override EventDispatcher.addEventListener//
	Div.prototype.addEventListener = function(type,fun) {
		if (this._listeners[type]) {
			if (this.hasEventListener(type,fun)) {
				return (false);
			}
			this._listeners[type].push(fun);
		} else {
			this._listeners[type] = [fun];
		}
		this._addMainListener(type,fun);
		this._$.style.cursor = 'pointer';
		switch (type) {
			case "mouseOver": 
				this._$.onmouseover = this._gotJSEvent.bind(this);
				break;
			case "mouseOut":
				this._$.onmouseout = this._gotJSEvent.bind(this);
				break;
			case "mouseDown":
				this._$.onmousedown = this._gotJSEvent.bind(this);
				break;
			case "mouseUp": 
				this._$.onmouseup = this._gotJSEvent.bind(this);
				break;
			case "click": 
				this._$.onclick = this._gotJSEvent.bind(this);
				break;
		}
	}
	Div.prototype.contains = function(div) {
		for (var c in this.children) {
			var n = this.children[c];
			if (n==div) return (true);
			if (n.contains(div)) return (true);
		}
		return (false);
	}
	Div.prototype._containsElement = function(el) {
		for (var c in this.children) {
			if (this.children[c]._$ == el) return true;
			if (this.children[c]._containsElement(el)) return true;
		}
		return false;
	}
	Div.prototype._gotJSEvent = function(evt) {
		if (IE) evt = window.event;
		var targ = evt.toElement ? evt.toElement : evt.relatedTarget ? evt.relatedTarget : null;
		if (this._$ != targ && !this._containsElement(targ)) {
			var toType = "";
			switch (evt.type) {
				case "mouseover": 
					toType = "mouseOver";
					break;
				case "mouseout":
					toType = "mouseOut";
					break;
				case "mousedown": 
					toType = "mouseDown";
					break;
				case "mouseup":
					toType = "mouseUp";
					break;
				case "click": 
					toType = "click";
					break;
			}
			this.dispatchEvent(new Event(toType,this,this));
		}
	}
	
	LoadImage.inherits(EventDispatcher);
	function LoadImage(div,src) {
		this.div = div;
		this.src = src;
		this.img = null;
		this._listeners = [];
	}
	LoadImage.prototype.load = function() {
		var i = document.createElement('img');
		this.img = i;
		i.outer = this;
		i.onload = function(evt) {
			if (IE) {
				var t = this;
			} else {
				var t = evt.target;
			}
			t.outer.div.$.style.width = t.width+'px';
			t.outer.div.$.style.height = t.height+'px';
			t.outer.div.$.appendChild(t);
			t.outer.dispatchEvent(new Event('loaded',t.outer,t.outer));
		}
		i.src = this.src;
	}
	
	SpriteSheet.inherits(EventDispatcher);
	function SpriteSheet(src,w,h) {
		this.w = w;
		this.h = h;
		this._listeners = [];
		this._row = 0;
		this._col = -1;
		this._img = document.createElement('img');
		this._img.src = src;
		this.div = new Div();
		this.div.spritesheet = this;
		this.div.$.style.left = w+'px';
		this.div.$.appendChild(this._img);
		this.div._$.style.width = w+'px';
		this.div._$.style.height = h+'px';
		this.div._$.style.overflow = 'hidden';
	//	this.div._$.style.backgroundColor='#FF0000';
	}
	SpriteSheet.prototype.row = function() {
		return (this._row);
	}
	SpriteSheet.prototype.setrow = function(_r) {
		this.div.$.style.top = (-1*_r*this.h)+'px';
	}
	SpriteSheet.prototype.col = function() {
		return (this._col);
	}
	SpriteSheet.prototype.setcol = function(_c) {
		this.div.$.style.left = (-1*_c*this.w)+'px';
	}
	
	Tween.inherits(EventDispatcher);
	function Tween(div,prop,easing,from,to,seconds,display,nonSetter) {
		if (!div.stage) {
			//you must pass a display parameter unless it's a visual div on the stage. 
		//	return (false);
		}
		this.framerate = 30;
		
		this.div = div;
		this._listeners = {};
		this.prop = prop;
		this.easing = easing;
		this.from = from;
		this.to = to;
		this.seconds = seconds;
		this.ticks = (1000/this.framerate)*seconds;
		this.iterator = 0;
		this.running = true;
		this.pos = from;
		this.doFunction = this.doTween.bind(this);
		this.nonSetter = nonSetter==null?false:nonSetter;
		this.interval = setInterval(this.doFunction,1000/this.framerate);
	}
	Tween.prototype.doTween = function() {
		this.iterator++;
		if (this.iterator >= this.ticks) {
			this.dispatchEvent(new Event("motionFinished",this,this));
			this.stop();
		}
		this.pos = this.easing(this.from,this.to,this.iterator,this.ticks,this.pos);
		if (this.nonSetter != null && this.nonSetter != false) {
			this.div[this.prop] = this.pos+this.nonSetter;
		} else {
			this.div['set'+this.prop](this.pos);
		}
	}
	Tween.prototype.stop = function() {
		if (this.running) {
			clearInterval(this.interval);
		}
		this.running = false;
		delete (this.doFunction);
	}
	function EaseNone(f,t,i,tot,p) {
		return (f-((f-t)*(i/tot)));
	}
	function ei(r,p) {
		return Math.pow(r,p);
	}
	function eo(r,p) {
		return 1-ei(1-r,p);
	}
	function eio(r,p) {
		if (r<=.5) return (ei(2*r,p)/2);
		return (eo(2*(r-.5),p)/2+.5);
	}
	function EaseIn(f,t,i,tot,p) {
		return (f-ei(i/tot,2)*(f-t));
		//return (f-(Math.pow(i/tot,3))*(f-t));
	}
	function EaseOut(f,t,i,tot,p) {
		return (f-eo(i/tot,2)*(f-t));
	}
	function EaseInOut(f,t,i,tot,p) {
		return (f-eio(i/tot,2)*(f-t));
	}
	
	return {
		//public methods//
		IE:IE, 
		DivDisplay: DivDisplay, 
		Point: Point, 
		Matrix: Matrix, 
		Event: Event, 
		Div: Div, 
		LoadImage: LoadImage, 
		SpriteSheet: SpriteSheet, 
		Tween: Tween, 
		EaseIn: EaseIn, 
		EaseOut: EaseOut, 
		EaseInOut: EaseInOut, 
		EaseNone: EaseNone 
	}
}()
