/*	JSFader 2008 ver. 2.0 (23-03-2009)	Fading utility for image slideshow made by johnnyseyd@gmail.com		This tool fades an list of images fading in selected container (element).		-------------------------------------------------------------------------	-------------------------------------------------------------------------	-------------------------------------------------------------------------		Simply include this sctipt in your HTML, for example:	<script type="text/javascript" src="JSFader.js"></script>		and make an image container element, for example:	<div id="box" style="border: 1px solid black; float: right;"></div>		than include script like this:	<script>	<!--		var fader = new JSFader('box');		fader.setVisibleTime(2000);		fader.setFadeTime(1000);		fader.addImage('img/A.gif');		fader.addImage('img/B.gif');		fader.addImage('img/C.gif');		fader.addImage('img/D.gif');		fader.addImage('img/E.gif');		fader.addImage('img/F.gif');		fader.init();	//-->	</script>		... and thats all!		You have to create a new instance of JSFader object	width parameter ID of container element, or direct an element object.		Than you can set timing, visible time is how long will be visible each picture,	and fade time how long will take fade between two pictures.	It must be set in miliseconds (1000ms = 1sec).	Default visible time is 1000ms and fade time is also 1000ms.		Using method .addImage you can set an picture list (how many you want)	and it will fade in that order which you will add it. It takes an string url of a picture.		At last you have init (run) fader by method .init.		And thats all....		Recomendations:	All pictures must have the same size. Container element size will be set automaticaly.	If pictures are diffrent sized, container must be set at the minimum size (automaticaly).	If you want set your own size (less then optimal minimal) set it throught style.		You can make more instances of JSFader on one page and make more fading containers at same page.		Have a good time!	BASIC functions	.setVisibleTime		(Number ms)		:this		- setting interval of each frame (picture) visibility in animation (default 1000ms)	.setFadeTime		(Number ms)		:this		- setting interval of fading transition from frame to another frame (picture) (default 1000ms)	.addImage			(String url)	:this		- adds image to animation	.init				()				:this		- starts (inits) animation (after all images are added)	ADVANCED functions	.play				()				:this		- start animation if paused	.pause				()				:this		- pause (stop) animation if is playing	.isPlaying			()				:Boolean	- return information if animation is playing or paused	.next				()				:this		- show next frame (image)	.previous			()				:this		- show previous frame (image)	.gotoFrame			(Number frmNum)	:this		- show frame by	its number (1..n)	.getImageCount		()				:Number		- returns frame (image) count	.normalDirection	()				:this		- set normal animation direction	.reverseDirection	()				:this		- set reverse (backward) animation direction	.getDirection		()				:Number		- returns current animation direction (1=normal, -1=reverse)event handler	.onchange			(Object event)	client can rewrite by its own handler (function)										in e parameter is sent event object:											.target = current instance of JSFader [:Object]											.currentFrame = number of actual frame (image) 1..n [:Number]											.currentImage = current image object [:Image object]											.currentImageSrc = current image source [:String]*/var JSFader=function(_$z){if(typeof(_$z)=='string')_$z=document.getElementById(_$z);this._e=_$z;this._e.style.position='relative';this._e.style.overflow='hidden';this._n=new Array();this._$=new Array();};_j=JSFader.prototype;_j._e=null;_j._n=null;_j._$=null;_j._K=0;_j._z=1000;_j._M=1000;_j.__=0;_j._i=0;_j._d=false;_j._$o=function(_a,_o){_a.onload=_a.onerror=null;this._K++;_a._$t=true;_a._S=_a.width;_a._N=_a.height;this._P();this._T();};_j._P=function(){var _$a=10000;var _$d=10000;for(var _Q=0;_Q<this._$.length;_Q++){var _a=this._$[_Q];if(_a._$t){if(_a._S<_$a)_$a=_a._S;if(_a._N<_$d)_$d=_a._N;} };if(this._e.offsetWidth>_$a||!this._e.style.width)this._e.style.width=_$a+'px';if(this._e.style.height>_$d||!this._e.style.height)this._e.style.height=_$d+'px';this._D=parseInt(this._e.style.width);this._B=parseInt(this._e.style.height);};_j._$j=function(_a,_o){_a.onload=_a.onerror=null;this._n.splice(_o,1 );this._$.splice(_o,1 );this._T();};_j._T=function(){if(this._K==this._$.length)this._$A();};_j._C=function(_$h){for(var _Q=0;_Q<this._$.length;_Q++){var _$v=_$h&&_Q+1==this._$.length ?100 :0;if(_Q>0)_h(this._$[_Q],_$v);if(_$v==0&&_Q!=0)this._$[_Q].style.display='none';this._e.appendChild(this._$[_Q]);} };_j._$A=function(){this._C();this.__=0;this._i=0;this._U=this._g._X(this);this._H=this._$g._X(this);this._w(0,true);this._d=true;this._q();this._r();};_j._I=25;_j._w=function(_o,_L){var _a=this._$[_o];if(_a._S>this._D||_a._N>this._B){var _v=!_L ?Math.round(Math.random()) :0;var _A=!_L ?Math.round(Math.random()) :0;var _$D=_v==0 ?1 :-1;var _$G=_A==0 ?1 :-1;_a._x=_a._S-this._D;_a._y=_a._N-this._B;_a._G=_a._x*_v;_a._F=_a._y*_A;var _$k=(this._z + this._M*2) / this._I/1.1;_a._V=(_a._x*_$D) / _$k;_a._W=(_a._y*_$G) / _$k;if(Math.abs(_a._V)<0.2)_a._V=0;if(Math.abs(_a._W)<0.2)_a._W=0;_a.style.left=Math.round(-_a._G)+'px';_a.style.top=Math.round(-_a._F)+'px';if(_a._l){clearInterval(_a._l);_a._l=null;};if(_a._V!=0||_a._W!=0)_a._l=setInterval(this._mi._X(this,_o),this._I);} };_j._mi=function(_o){var _$f=false;var _a=this._$[_o];_a._G +=_a._V;_a._F +=_a._W;if(_a._G<0){_a._G=0;_$f=true;};if(_a._F<0){_a._F=0;_$f=true;};if(_a._G>_a._x){_a._G=_a._x;_$f=true;};if(_a._F>_a._y){_a._F=_a._y;_$f=true;};_a.style.left=Math.round(-_a._G)+'px';_a.style.top=Math.round(-_a._F)+'px';if(_$f||!this._d){clearInterval(_a._l);_a._l=null;} };_j._b=null;_j._r=function(){if(this._b||this._f)return;this._b=setTimeout(this._U,this._z);};_j._c=1;_j._g=function(){if(!this._d||this._f)return;this._i=this.__;this.__ +=this._c;if(this.__<0)this.__=this._$.length-1;if(this.__+1>this._$.length){this.__=0;this._C(true);};this._t();};_j._u=50;_j._t=function(){if(this._f)return;this._w(this.__);this._s=Math.round(this._M/this._u);this._p=0;this._m=this.__;this._k=this._i;for(var _Q=0;_Q<this._$.length;_Q++)if(_Q!=this._m&&_Q!=this._k)this._$[_Q].style.display='none';var _Z=this._$[this._k];_h(_Z,100 );_Z.style.display='block';_Z.style.zIndex=0;var _$b=this._$[this._m];_h(_$b,0 );_$b.style.display='block';_$b.style.zIndex=1;this._f=setTimeout(this._H,this._u);};_j._$g=function(){this._p++;var _$$=(this._p/this._s)*100;if(this._p==this._s)_$$=100;if(this._p>this._s/3)this._q();if(this._p<this._s)this._f=setTimeout(this._H,this._u);else {this._f=null;this._b=null;this._r();};_h(this._$[this._m],_$$);if(this._p==this._s)this._$[this._k].style.display='none';};_j._q=function(){this.onchange({target:this,currentFrame:this.__+1,currentImage:this._$[this.__],currentImageSrc:this._$[this.__].src } );};_j.setVisibleTime=function(_$F){this._z=_$F;return this;};_j.setFadeTime=function(_$F){this._M=_$F;return this;};_j.addImage=function(_$I){var _o=this._n.length;this._n[_o]=_$I;var _a=this._$[_o]=new Image();_a.onload=this._$o._X(this,_a,_o);_a.onerror=this._$j._X(this,_a,_o);var _$L=_a.style;_$L.position='absolute';_$L.left='0';_$L.top='0';return this;};_j.init=function(){for(var _Q=0;_Q<this._$.length;_Q++)this._$[_Q].src=this._n[_Q];return this;};_j.play=function(){if(!this._d){this._d=true;if(this._b){clearTimeout(this._b);this._b=null;};this._g();};return this;};_j.pause=function(){if(this._d){this._d=false;};return this;};_j.isPlaying=function(){return this._d;};_j.next=function(){if(!this._f){if(this._b){clearTimeout(this._b);this._b=null;};if(!this._d){this._d=true;this._g();this._d=false;}else this._g();};return this;};_j.previous=function(){if(!this._f){if(this._b){clearTimeout(this._b);this._b=null;};var _$H=this._c;this._c=-1;if(!this._d){this._d=true;this._g();this._d=false;}else this._g();this._c=_$H;};return this;};_j.gotoFrame=function(_E){if(_E<1) _E=1;if(_E>this._$.length) _E=this._$.length;this._i=this.__;if(this.__!=_E-1){this.__=_E-1;if(this.__+1>this._$.length){this.__=0;this._C(true);};this._t();};return this;};_j.getImageCount=function(){return this._$.length;};_j.normalDirection=function(){this._c=1;return this;};_j.reverseDirection=function(){this._c=-1;return this;};_j.getDirection=function(){return this._c;};_j.onchange=function(JSFader){};Function.prototype._X=function(_$u){var _$q=this;var _$a=Array._R(arguments);return function(){return _$q.apply(_$u,Array.concat(_$a,arguments));};};Array.concat=function(){var _J=[];for(var _Q=0;_Q<arguments.length;_Q++)for(var _$J=0;_$J<arguments[_Q].length;_$J++)_J.push(arguments[_Q][_$J]);return _J;};Array._R=function(_Y){var _J=[];for(var _Q=1;_Q<_Y.length;_Q++)_J.push(_Y[_Q]);return _J;};_h=function(_$_,_O){if(_O>100) _O=100;if(document.all&&!window.opera)_$_.style.filter='Alpha(Opacity='+parseInt(_O)+')';else _$_.style.opacity=parseFloat(_O)/100;};