var TINY={};

function $(i){return document.getElementById(i)}
function $$(e,p){
p=p||document;
 return p.getElementsByTagName(e)
 }

TINY.slideshow=function(n){
	this.imgSpeed=this.speed=10;
	this.letterbox='#000';
	this.n=n;
	this.c=0;
	this.a=[]
};

TINY.slideshow.prototype={
	init:function(s,z){
		s=$(s);
		//var m=$$('li',s);
		var i=0;
		var m=s.getElementsByTagName('li');
		this.l=m.length;
		this.f=$(z);
		this.o=parseInt(TINY.style.val(z,'width'));
		for(i;i<this.l;i++){
			this.a[i]={};
			var h=m[i], a=this.a[i];
			a.p=h.innerHTML;
		}
		this.auto?this.is(0,0):this.is(0,1)
	},
	mv:function(d,c){
		var t=this.c+d;
		this.c=t=t<0?this.l-1:t>this.l-1?0:t;
		this.pr(t,c)
	},
	pr:function(t,c){
		clearTimeout(this.lt);
		if(c){
			clearTimeout(this.at)
		}
		this.c=t;
		this.is(t,c)
	},
	is:function(s,c){
		var i=new Image();
		i.style.opacity=0;
		i.style.filter='alpha(opacity=0)';
		this.i=i;
		i.onload=new Function(this.n+'.le('+s+','+c+')');
		i.src=this.a[s].p;
	},
	le:function(s,c){
		this.f.appendChild(this.i);
		var w=this.o-parseInt(this.i.offsetWidth);
		if(w>0){
			var l=Math.floor(w/2);
			this.i.style.borderLeft=l+'px solid '+this.letterbox;
			this.i.style.borderRight=(w-l)+'px solid '+this.letterbox
		}
		TINY.alpha.set(this.i,100,this.imgSpeed);
		if(!c){
			this.at=setTimeout(new Function(this.n+'.mv(1,0)'),this.speed*1000)
		}

		//var m=$$('img',this.f);
		var m=this.f.getElementsByTagName('img');
		if(m.length>2){
			this.f.removeChild(m[0])
		}
	},

};


TINY.alpha=function(){
	return{
		set:function(e,a,s){
			e=typeof e=='object'?e:$(e); var o=e.style.opacity||TINY.style.val(e,'opacity'),
			d=a>o*100?1:-1; e.style.opacity=o; clearInterval(e.ai); e.ai=setInterval(function(){TINY.alpha.tw(e,a,d,s)},20)
		},
		tw:function(e,a,d,s){
			var o=Math.round(e.style.opacity*100);
			if(o==a){clearInterval(e.ai)}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d; e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'}
		}
	}
}();

TINY.style=function(){return{val:function(e,p){e=typeof e=='object'?e:$(e); return e.currentStyle?e.currentStyle[p]:document.defaultView.getComputedStyle(e,null).getPropertyValue(p)}}}();
