var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.fader=function(){
	function fade(n,p){this.n=n; this.init(p)}
	fade.prototype.init=function(p){
		var slides_container=T$(p.id), 
		slides=this.slides=T$$('li',slides_container), 
		l=slides.length, 
		i=this.l=this.c=this.z=0;
		if(p.navid&&p.activeclass){
			this.navi=T$$('li',T$(p.navid)); 
			this.slides_container=p.activeclass
		}
		slides_container.style.overflow='hidden'; 
		this.a=p.auto||0; 
		this.p=p.resume||0;
		for(i;i<l;i++){
			if(slides[i].parentNode==slides_container){
				slides[i].style.position='absolute'; 
				this.l++; 
				slides[i].o=p.visible?100:0;
				slides[i].style.opacity=slides[i].o/100; 
				slides[i].style.filter='alpha(opacity='+slides[i].o+')'
			}
		}
		this.pos(p.position||0,this.a?1:0,p.visible)
	},
	fade.prototype.auto=function(){
		this.slides.ai=setInterval(new Function(this.n+'.move(1,1)'),this.a*1000)
	},
	fade.prototype.move=function(d,a){
		var n=this.c+d, i=d==1?n==this.l?0:n:n<0?this.l-1:n; 
		this.pos(i,a)
	},
	fade.prototype.pos=function(i,a,v){
		var p=this.slides[i]; 
		this.z++;
		p.style.zIndex=this.z;
		clearInterval(p.si); 
		clearInterval(this.slides.ai); 
		this.slides.ai=0; 
		this.c=i;
		if(p.o>=100&&!v){
			p.o=0; p.style.opacity=0; 
			p.style.filter='alpha(opacity=0)'
		}
		if(this.navi){
			for(var x=0;x<this.l;x++){
				this.navi[x].className=x==i?this.slides_container:''
			}
		}
		p.si=setInterval(new Function(this.n+'.fade('+i+','+a+')'),20)
	},
	fade.prototype.fade=function(i,a){
		var p=this.slides[i];
		if(p.o>=100){
			clearInterval(p.si); 
			if((a||(this.a&&this.p))&&!this.slides.ai){
				this.auto()
			}
		}else{
			p.o+=5; 
			p.style.opacity=p.o/100; 
			p.style.filter='alpha(opacity='+p.o+')';
		}
		
	};
	return{fade:fade}
}();
