// JavaScript Document
//x,y,p_fld=folder,p_vd=visibe durication,p_fd=fade durication,p_el=endless,p_stp=tooltip for stop,p_nxt=tooltip for next image,p_imgs= images in a array,p_flts=filter array
function Ds(p_id,p_vd,p_fd,p_el,p_stp,p_nxt,p_morei){	i
	var thisobj=this;
	thisobj.objcount=0;
	thisobj.vd=p_vd;
	thisobj.fd=p_fd;
	thisobj.el=p_el;
	thisobj.stp=p_stp;
	thisobj.nxt=p_nxt;
	thisobj.morei=p_morei;
	thisobj.imgs=new Array();
	thisobj.count=0;
	thisobj.stop=false;
	thisobj.fin=new FadeIn(0,100,thisobj.fd,thisobj);		
	thisobj.fout=new FadeOut(100,0,thisobj.fd,thisobj);
	thisobj.cont=document.getElementById(p_id);
	try{
		thisobj.cont.style.cursor="pointer";
	}catch(e){
		//nothing
	}
	this.nextDia=function(){
		if(thisobj.stop==false){
			window.clearTimeout(thisobj.tdia);
			try{
				if(thisobj.count+1<thisobj.imgs.length){
					thisobj.fout.start(thisobj.imgs[thisobj.count]);
					thisobj.count++;
				}else{
					thisobj.fout.start(thisobj.imgs[thisobj.imgs.length-1]);
					thisobj.count=0;
				}
				thisobj.fin.start(thisobj.imgs[thisobj.count]);	
			}catch(e){
				//no fade
				if(thisobj.count+1<thisobj.imgs.length){
					for(var i=0;i<thisobj.imgs[thisobj.count].length;i++){
						thisobj.imgs[thisobj.count][i].style.visibility="hidden";
					}
					thisobj.count++;
				}else{
					for(var i=0;i<thisobj.imgs[thisobj.imgs.length-1].length;i++){
						thisobj.imgs[thisobj.imgs.length-1][i].style.visibility="hidden";
					}
					thisobj.count=0;
				}
				for(var i=0;i<thisobj.imgs[thisobj.count].length;i++){
					thisobj.imgs[thisobj.count][i].style.visibility="visible";
				}
				thisobj.tdia=window.setTimeout(thisobj.fadeInFinished,Number(thisobj.vd));			
			}
		}
	};
	this.fadeInFinished=function(){		
		if(thisobj.objcount>-1){
			window.clearTimeout(thisobj.tdia);
			thisobj.addNextImage();
		}else{
			if(thisobj.stop==false){
				thisobj.tdia=window.setTimeout(thisobj.nextDia,Number(thisobj.vd));
			}
		}
	};
	this.fadeOutFinished=function(){
		//nothing
	};		
	var tmplength=thisobj.cont.childNodes.length;
	//init existing images
	for(var i=0;i<tmplength;i++){
		if(thisobj.cont.childNodes[i].tagName.toLowerCase()=="img"){
			img=thisobj.cont.childNodes[i];
			img.title=thisobj.stp;
			if(thisobj.objcount>0){
				img.style.visibility="hidden";
			}
			img.onclick=function(){
				if(thisobj.stop==false){
					window.clearTimeout(thisobj.tdia);
					thisobj.stop=true;
					thisobj.imgs[thisobj.count][0].title=thisobj.nxt;
				}else{
					thisobj.stop=false;
					thisobj.imgs[thisobj.count][0].title=thisobj.stp;
					thisobj.nextDia();
				}
			};
			thisobj.imgs.push(new Array(img));
			if(i+1<tmplength){
				if(thisobj.cont.childNodes[i+1].tagName.toLowerCase()=="p"){
					i++;
					if(thisobj.objcount>0){
						thisobj.cont.childNodes[i].style.visibility="hidden";	
					}
					thisobj.imgs[thisobj.objcount].push(thisobj.cont.childNodes[i]);
				}
			}
			thisobj.objcount++;
		}
	}
	if(thisobj.morei.length==0){
		thisobj.objcount=-1;	
	}else{
		thisobj.objcount=0;	
	}
	thisobj.tdia=window.setTimeout(thisobj.nextDia,Number(thisobj.vd));	
	//init rest images
	thisobj.addNextImage=function(){
		var img=new Image();	
		img.title=thisobj.stp;
		if(enPos()){
			img.style.position="absolute";
			img.style.left="0px";
			img.style.top="0px";
		}
		img.style.width="100%";
		img.style.height="100%";
		if((isIE())&&(!isIEM())&&(String(thisobj.morei[thisobj.objcount][0][0]).substring(String(thisobj.morei[thisobj.objcount][0][0]).length-4)==".png")){
				img.src=rtPh()+"scripts/ie/tmp.png";
				img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+cPh()+String(thisobj.morei[thisobj.objcount][0][0])+"',sizingMethod='scale')";
		}else{
			img.src=cPh()+String(thisobj.morei[thisobj.objcount][0][0]);
		}
		if(thisobj.morei[thisobj.objcount][0][1]!=null){
			img.className=String(thisobj.morei[thisobj.objcount][0][1]);	
		}
		thisobj.cont.appendChild(img);
		rs_rsObj(img);
		img.style.visibility="hidden";
		img.onclick=function(){
			if(thisobj.stop==false){
				window.clearTimeout(thisobj.tdia);
				thisobj.stop=true;
				thisobj.imgs[thisobj.count][0].title=thisobj.nxt;
			}else{
				thisobj.stop=false;
				thisobj.imgs[thisobj.count][0].title=thisobj.stp;
				thisobj.nextDia();
			}
		};
		thisobj.imgs.push(new Array(img));
		//text node
		if(thisobj.morei[thisobj.objcount].length>1){
			var txt=document.createElement("p");
			thisobj.cont.appendChild(txt);
			txt.style.visibility="hidden";
			if(isIEM()){
				txt.innerText=String(thisobj.morei[thisobj.objcount][1][0]);
			}else{
				var tn=document.createTextNode(String(thisobj.morei[thisobj.objcount][1][0]));
				txt.appendChild(tn);				
			}
			if(enPos()){
				txt.style.position="absolute";
				txt.style.left=String(Number(thisobj.morei[thisobj.objcount][1][1]))+"px";
				txt.style.top=String(Number(thisobj.morei[thisobj.objcount][1][2]))+"px";
			}		
			txt.style.width=String(Number(thisobj.morei[thisobj.objcount][1][3]))+"px";
			txt.style.height=String(Number(thisobj.morei[thisobj.objcount][1][4]))+"px";
			txt.style.fontSize=String(Number(thisobj.morei[thisobj.objcount][1][5]))+"px";
			if(thisobj.morei[thisobj.objcount][1][6]!=null){
				txt.className=String(thisobj.morei[thisobj.objcount][1][6]);
			}
			rs_rsObj(txt);
			thisobj.imgs[thisobj.imgs.length-1].push(txt);
		}
		if(thisobj.objcount+1<thisobj.morei.length){
			thisobj.objcount++;	
		}else{
			thisobj.objcount=-1;	
		}
		thisobj.tdia=window.setTimeout(thisobj.nextDia,Number(thisobj.vd));
	};
}