
Ynt=new Object();
Ynt.cloneObject=function(what) {
	if (typeof(what)!='object') return what;
	if (what==null) return what;
    for (i in what) {this[i] = what[i];};
	return this;
}


Array.prototype.iterate=function(func) {for (var i=0;i<this.length;i++) {if (func.call(this[i])===true) {return true;};};return false;};


Array.prototype.inArray=function(elt) {var _elt=elt;return this.iterate(function(){if (this==_elt) {return true;};});};


Ynt.getArray=function(arr) {
	arr.iterate=Array.prototype.iterate;
	arr.inArray=Array.prototype.inArray;
	return arr;
};


Ynt.getElement=function(elt) {
	
	elt.attachEvt=function(type,func){
		if (this.addEventListener) {
			this.addEventListener(type,func,false);
		} else if (this.attachEvent) {
			var tmp_func=func;this.attachEvent('on'+type,function() {tmp_func.call(event.srcElement);});
		};
	};
	
	
	elt.getParents=function(arr) {
		if (typeof(arr)=='undefined') {var arr=new Array();};
		arr.push(this);
		if (arr.length>7) {return arr;};
		if(typeof(this.parentElement)=='undefined') {var pe=this.parentNode;} else {var pe=this.parentElement;};
		if (pe==null) {return arr;};
		return Ynt.getElement(pe).getParents(arr);
	};
	
	elt=Ynt.Animation.getElement(elt);
	elt=Ynt.SelectBox.getElement(elt);	
	return elt;
};


Ynt.getElementById=function(id){
	var xelt=document.getElementById(id);
	if (xelt==null) {
		return false;
	} else if (typeof(xelt)!='object') {
		return false;
	} else {
		return Ynt.getElement(xelt);
	};
};


Ynt.getElementsByTagName=function(tagname){
	var _ans=new Array();
	Ynt.getArray(document.getElementsByTagName(tagname)).iterate(function(){_ans.push(Ynt.getElement(this));});
	return _ans;
};


Ynt.getElementsByClassName=function(tagname,csname) {
	var _csname=csname;
	var _ans=new Array();
	Ynt.getElementsByTagName(tagname).iterate(function(){if (this.className.split(' ').inArray(_csname)) {_ans.push(Ynt.getElement(this));};});
	return _ans;
};


Ynt.Timer=new Object();
Ynt.Timer._objs=new Array();
Ynt.Timer._last_time=0;
Ynt.Timer._iteraterunning=false;
Ynt.Timer._iterate_dontstop=false;
Ynt.Timer.Mode='internal';
//Ynt.Timer.Mode='interval';
Ynt.Timer.SetMode=function(mode){
	Ynt.Timer.Mode=mode;
};
Ynt.Timer.Register=function(obj){
	if (Ynt.Timer.Mode=='interval') {
		Ynt.TimerInterval.Register(obj);
		return;
	};
	obj.YntTimerStopped=true;
	obj.YntTimerStop=function(){
		this.YntTimerStopped=true;
	};
	obj.YntTimerStart=function(){
		this._YntTimerWastedTime=0;
		this.YntTimerStopped=false;
		Ynt.Timer._Restart();
	};
	obj._YntTimerId=Ynt.Timer._objs.length;
	Ynt.Timer._objs.push(obj);
};
Ynt.Timer._Restart=function(){
	if (Ynt.Timer._iteraterunning) {
		Ynt.Timer._iterate_dontstop=true;
	} else if (Ynt.Timer._last_time<1) {
		Ynt.Timer._iterate();
	};
};
Ynt.Timer._iterate=function(){
	if (Ynt.Timer._iteraterunning==true) {return;};
	Ynt.Timer._iteraterunning=true;
	Ynt.Timer._now_time=(new Date()).getTime();
	if (Ynt.Timer._last_time<1) {Ynt.Timer._last_time=Ynt.Timer._now_time;};
	if (Ynt.Timer._last_time>=Ynt.Timer._now_time) {
		Ynt.Timer._last_time=Ynt.Timer._now_time;
		Ynt.Timer._iteraterunning=false;
		setTimeout(Ynt.Timer._iterate,1);
		return;
	};
	Ynt.Timer._spent_time=Ynt.Timer._now_time-Ynt.Timer._last_time;
	var keeprunning=false;
	Ynt.Timer._objs.iterate(function(){
		Ynt.Timer._iteraterunning_objid=this._YntTimerId;
		if (this.YntTimerStopped==true) {return;};
		var spent_time=Ynt.Timer._spent_time+this._YntTimerWastedTime;
		var interval=this.YntTimerInterval;
		var iters=Math.floor(spent_time/interval);
		this._YntTimerWastedTime=spent_time-(iters*interval);
		for(var x=0;x<iters;x++){
			if ((this.YntTimerStopped==false)&&(typeof(this.YntTimerLoop)=='function')) {this.YntTimerLoop();};
		};
		if (this.YntTimerStopped==false) {keeprunning=true;};
	});
	Ynt.Timer._iteraterunning_objid=-1;
	if (Ynt.Timer._iterate_dontstop==true) {
		keeprunning=true;
		Ynt.Timer._iterate_dontstop=false;
	};
	if (keeprunning==true) {
		Ynt.Timer._last_time=Ynt.Timer._now_time;
		Ynt.Timer._iteraterunning=false;
		setTimeout(Ynt.Timer._iterate,1);
	} else {
		Ynt.Timer._last_time=0;
		Ynt.Timer._iteraterunning=false;
	};
};

Ynt.TimerInterval=new Object();
Ynt.TimerInterval.Register=function(obj){
	obj._YntTimerId=false;
	obj.YntTimerStop=function(){
		if (this._YntTimerId==false) {return;};
		clearInterval(this._YntTimerId);
		this._YntTimerId=false;
	};
	obj.YntTimerStart=function(){
		if (this._YntTimerId!=false) {return;};
		var _this=this;
		var interval=Math.round(this.YntTimerInterval/4);
		this._YntTimerId=setInterval(function(){
			Ynt.TimerInterval._Iterate(_this);
		},interval);
	};
};
Ynt.TimerInterval._Iterate=function(obj){
	if (obj._YntTimerId==false) {return;};
	obj.YntTimerLoop();
};

Ynt.Animation=new Object();
Ynt.Animation.getStylePx=function(str) {
	var i=str.search('px');
	if (i==-1) {return 0;};
	return (str.substr(0,i)*1);
};
Ynt.Animation.getElement=function(elt){
	elt.getTop=function(){return Ynt.Animation.getStylePx(this.style.top);};
	elt.getLeft=function(){return Ynt.Animation.getStylePx(this.style.left);};
	elt.setTop=function(top){this.style.top=top;};
	elt.setLeft=function(left){this.style.left=left;};
	elt.setOpacity=function(value){
		this.style.opacity = value/10;
		this.style.filter = 'alpha(opacity=' + value*10 + ')';
	};
	return elt;
};
Ynt.Animation.Tween=function(){
	this.init=function(){
		this.startVal=false;
		this.targetVal=false;
		this._paused=false;
	};
	this.initFull=function(){
		this.init();
		this.setOnEnd(false);
		this.setOnStep(false);
		this.setPreWait(0);
		this.setPostWait(0);
		this.setPauseHoldsOnEnd(false);
		this.setIgnorePause(false);
		this.setInterval(10);
	};
	this.transitionFunc=Ynt.Animation.Transitions.linear;
	this.setTime=function(tweenTime){this.tweenTime=tweenTime;};
	this.setType=function(tweenType){this.tweenType=tweenType;};
	this.setOnEnd=function(onEnd){this.onEnd=onEnd;};
	this.setOnStep=function(onStep){this.onStep=onStep;};
	this.setInterval=function(interval){this.interval=interval;};
	this.setTarget=function(targetVal){this.targetVal=targetVal;};
	this.setTransition=function(func){this.transitionFunc=func;};
	this.setPreWait=function(t){this.preWait=t;};
	this.setPostWait=function(t){this.postWait=t;};
	this.setPauseHoldsOnEnd=function(tof){this.PauseHoldsOnEnd=tof;};
	this.setIgnorePause=function(tof){this.ignorePause=tof;};
	this.setStart=function(startVal){
		this.startVal=startVal;
		this.tweenType.moveTo(startVal);
	};
	this.setDiff=function(diff){
		this._getStartVal();
		this.setTarget(this.startVal+diff);
	};
	this.getCopy=function(){
		var newObj=Ynt.cloneObject(this);
		newObj.tweenType=Ynt.cloneObject(this.tweenType);
		return newObj;
	};
	this._getStartVal=function(){
		if (this.startVal===false) {this.startVal=this.tweenType.getCurrVal();};
	};
	this.pause=function(){
		if (this.ignorePause) {return;};
		if (this.PauseHoldsOnEnd) {
			this._paused=true;
		} else {
			if (this.YntTimerStop) this.YntTimerStop();
		};
	};
	this.unpause=function(){
		if (this.ignorePause) {return;};
		if (this.PauseHoldsOnEnd) {
			this._paused=false;
		} else {
			if (this.YntTimerStart) this.YntTimerStart();
		};
	};
	this.run=function(){
		this._getStartVal();
		if (this.targetVal===false) {this.targetVal=this.tweenType.getTargetVal();};
		this.currVal=this.startVal;
		this.YntTimerInterval=this.interval;
		this.currTime=0;
		this.changeVal=this.targetVal-this.startVal;
		if (typeof(this._YntTimerId)=='undefined') {
			Ynt.Timer.Register(this);
			var waittimer=new Object();
			Ynt.Timer.Register(waittimer);
			this._WaitTimer=waittimer;
		};
		if (this.preWait>0) {
			this._WaitTimer.YntTimerInterval=this.preWait;
			var _this=this;
			this._WaitTimer.YntTimerLoop=function(){
				this.YntTimerStop();
				_this.YntTimerStart();
			};
			this._WaitTimer.YntTimerStart();
		} else {
			this.YntTimerStart();
		};
	};
	this.YntTimerLoop=function(){
		this.currTime=this.currTime+this.interval;
		if (this.currTime<this.tweenTime) {
			var newVal=this.transitionFunc(this.currTime,this.startVal,this.changeVal,this.tweenTime);
			this.tweenType.moveTo(newVal);
			this.currVal=newVal;
			if (this.onStep!=false){this.onStep();};
		} else {
			this.tweenType.moveTo(this.targetVal);
			this.currVal=this.targetVal;
			this.YntTimerStop();
			if (this.onEnd!=false){
				if ((this.PauseHoldsOnEnd)&&(this._paused)) {
					this._WaitTimer.YntTimerInterval=10;
					this._WaitTimer.YntTimerLoop=function(){
						if (this.tween._paused==false) {
							this.YntTimerStop();
							this.tween.onEnd();
						};
					};
					this._WaitTimer.YntTimerStart();
				} else if (this.postWait>0) {
					this._WaitTimer.YntTimerInterval=this.postWait;
					this._WaitTimer.YntTimerLoop=function(){
						this.YntTimerStop();
						this.tween.onEnd();
					};
					this._WaitTimer.YntTimerStart();
				} else {
					this.onEnd();
				};
			};
		};
	};
	this.initFull();
};
Ynt.Animation.Types=new Object();
Ynt.Animation.Types.Opacity=function(elt){
	this.elt=elt;
	this.moveTo=function(where){
		this.elt.setOpacity(where);
	};
};
Ynt.Animation.Types.Motion=function(elt,dir){
	this.elt=elt;
	this.setDir=function(dir){this.dir=dir;};
	if (typeof(dir)!='undefined') {this.setDir(dir);};
	this.getCurrVal=function(){
		if (this.dir=='top') {return this.elt.getTop();} else {return this.elt.getLeft();};
	};
	this.moveTo=function(where){
		if (this.dir=='top') {this.elt.setTop(where);} else {this.elt.setLeft(where);};
	};
};
Ynt.Animation.Transitions = {
	linear: function(t, b, c, d){
		return c*t/d + b;
	},
	quadIn: function(t, b, c, d){
		return c*(t/=d)*t + b;
	},
	quadOut: function(t, b, c, d){
		return -c *(t/=d)*(t-2) + b;
	},
	quadInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	cubicIn: function(t, b, c, d){
		return c*(t/=d)*t*t + b;
	},
	cubicOut: function(t, b, c, d){
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	cubicInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	quartIn: function(t, b, c, d){
		return c*(t/=d)*t*t*t + b;
	},
	quartOut: function(t, b, c, d){
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	quartInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	quintIn: function(t, b, c, d){
		return c*(t/=d)*t*t*t*t + b;
	},
	quintOut: function(t, b, c, d){
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	quintInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	sineIn: function(t, b, c, d){
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	sineOut: function(t, b, c, d){
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	sineInOut: function(t, b, c, d){
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	expoIn: function(t, b, c, d){
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	expoOut: function(t, b, c, d){
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	expoInOut: function(t, b, c, d){
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	circIn: function(t, b, c, d){
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	circOut: function(t, b, c, d){
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	circInOut: function(t, b, c, d){
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	elasticIn: function(t, b, c, d, a, p){
		if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (!a) a = 1;
		if (a < Math.abs(c)){ a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin(c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	elasticOut: function(t, b, c, d, a, p){
		if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (!a) a = 1;
		if (a < Math.abs(c)){ a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin(c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	elasticInOut: function(t, b, c, d, a, p){
		if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); if (!a) a = 1;
		if (a < Math.abs(c)){ a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin(c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	backIn: function(t, b, c, d, s){
		if (!s) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	backOut: function(t, b, c, d, s){
		if (!s) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	backInOut: function(t, b, c, d, s){
		if (!s) s = 1.70158;
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	bounceIn: function(t, b, c, d){
		return c - Ynt.Animation.Transitions.bounceOut (d-t, 0, c, d) + b;
	},
	bounceOut: function(t, b, c, d){
		if ((t/=d) < (1/2.75)){
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)){
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)){
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	bounceInOut: function(t, b, c, d){
		if (t < d/2) return Ynt.Animation.Transitions.bounceIn(t*2, 0, c, d) * .5 + b;
		return Ynt.Animation.Transitions.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
};


Ynt.SelectBox=new Object();
Ynt.SelectBox.getElement=function(elt){
	if (typeof(elt.options)=='undefined') {return elt;};
	elt.getOptions=function(){
		return Ynt.getArray(this.options);
	};
	elt.addOption=function(value,inner){
		var newopt=document.createElement("OPTION");
		this.options.add(newopt);
		newopt.innerHTML=inner;
		newopt.value=value;
		return newopt;
	};
	elt.getSelectedOption=function(){
		return this.options[this.selectedIndex];
	};
	return elt;
};

Ynt.DomReady=new Object();
Ynt.DomReady.addEvent=function(fn){
	if (Ynt.DomReady._loaded) {fn();return;};
	Ynt.DomReady._fns.push(fn);
};
Ynt.DomReady._fns=new Array();
Ynt.DomReady._loaded=false;
Ynt.DomReady._runEvents=function(){
	if (Ynt.DomReady._loaded) {return;};
	Ynt.DomReady._loaded = true;
	Ynt.DomReady._fns.iterate(function(){this();});
};
Ynt.DomReady._webkitTimeout=function(){
	if (/loaded|complete/.test(document.readyState)) {
		Ynt.DomReady._runEvents();
	} else {
		window.setTimeout(Ynt.DomReady._webkitTimeout,10);
	};
};
Ynt.DomReady._start=function() {
	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", Ynt.DomReady._runEvents, false);
	};
	/*@cc_on @*/
	/*@if (@_win32)
		var dummy = location.protocol == "https:" ? "https://javascript:void(0)" : "javascript:void(0)";
		document.write("<script id=__ie_onload defer src='" + dummy + "'></script>");
		document.getElementById("__ie_onload").onreadystatechange = function() {
			if (this.readyState == "complete") { Ynt.DomReady._runEvents(); }
		};
	/*@end @*/
	if (/WebKit/i.test(navigator.userAgent)) {
		window.setTimeout(Ynt.DomReady._webkitTimeout,10);
	};
	Ynt.getElement(window).attachEvt('load',Ynt.DomReady._runEvents);
};
Ynt.DomReady._start();

