var slideShow=function(){
	var bxs,bxe,fxs,fxe,ys,ye,ta,ia,ie,st,ss,ft,fs,xp,yp,ci,t,tar,tarl,state;
	ta=document.getElementById(thumbid);ia=$('#'+imgid); //ia=document.getElementById(imgid);
	t=ta.getElementsByTagName('li'); ie=document.all?true:false;
	st=3; ss=3; ft=10; fs=5; xp,yp=0;state=0;auto_slide=true;
	return{
		init:function(){
			//document.onmousemove=this.pos; 
			//window.onresize=function(){setTimeout("slideShow.lim()",500)};
			//ys=this.toppos(ta); ye=ys+ta.offsetHeight;
			len=t.length;tar=[];
			for(i=0;i<len;i++){
				var id=t[i].value; tar[i]=id;
				t[i].onclick=new Function("slideShow.getimg('"+id+"','click')");
				
			}
			
			if(len>1)
			{
				this.getimg(tar[1],'auto');	
			}
			tarl=tar.length;
		},
		cncl:function(){clearTimeout(ta.timer)},
		getimg:function(id,type){
			var o;
			if (state==1)
			{
				//this.cncl();
				//return;
				state = 0;
			}
			//if(!auto_slide){clearTimeout(ia.timer)}
			if(ci!=null){
				var ts,tsl,x;
				/*ts=ia.getElementsByTagName('img'); tsl=ts.length;x=0;
				for(x;x<tsl;x++){
					if(ci.id!=id){var o=ts[x]; clearInterval(o.timer); o.timer=setInterval(function(){slideShow.fdout(o)},fs)}
				}*/
				if (ci)
				{
				clearInterval(ci.timer); 	
				}
				
				ci.timer=setInterval(function(){slideShow.fdout(ci)},fs);
			}
			if(!document.getElementById(id)){
				//var box=document.createElement('a');
				var i=document.createElement('img');
				//var i = $('img');
				i.border='0';
				//box.href=imgsor[id];
				//box.id='f'+id;
				//box.appendChild(i);
				//ia.appendChild(box);
				//ia.appendChild(i);
				ia.append(i);
				i.id=id; i.av=0; i.style.opacity=0;
				//$('#f'+id).fancybox();
				if (type!='click')
				{
					i.style.filter='alpha(opacity=0)';
				}else
				{
					i.style.opacity=1;
				}
				//i.src=imgdir+'/'+id+imgext;
				i.src=imgs[id];
			}else{
				i=document.getElementById(id); clearInterval(i.timer);
			}
			
			
			
			i.timer=setInterval(function(){slideShow.fdin(i)},fs);
				
			if (type=='click')
			{
				if (ta )
				{
					clearInterval(ta.timer);
				}
				auto_slide = false;
			}else
			{
				//state=1;
			
			}
		},
		nav:function(d){
			var c=0;

			for(key in tar){if(tar[key]==ci.id){c=key}}
			if(tar[parseInt(c)+d]){
				this.getimg(tar[parseInt(c)+d],'auto');
			}else{
				if(d==1){
					this.getimg(tar[0],'auto');
				}else{this.getimg(tar[tarl-1],'auto');}
			}
		},
		auto:function(){if (auto_slide){ia.timer=setTimeout(function(){slideShow.nav(1)},autodelay*1000)}},
		fdin:function(i){
			if(i.complete){state=0;i.av=i.av+fs; i.style.opacity=i.av/100; i.style.filter='alpha(opacity='+i.av+')';}
			if(i.av>=100){ clearInterval(i.timer); ci=i;if(auto_slide){this.auto(); }if (t.length==1){auto_slide=false;clearTimeout(ta.timer)}}
			
		},
		fdout:function(i){
			i.av=i.av-fs; i.style.opacity=i.av/100;
			i.style.filter='alpha(opacity='+i.av+')';
			if(i.av<=0){clearInterval(i.timer); if(i.parentNode){i.parentNode.removeChild(i)}}
		}
	};
}();

