/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

SlideShow ={
	container:null,
	lastChild:null,
	inDisplay:null,
	nextDisplay:null,
	steps:50,
	st:0,
	timer:null,
	wait:50,
	DPause:5000,
	pp:0,
	setContainer:function(obj){
		this.container=obj;
		this.lastChild=obj.children.length-1;
		this.init();
	},
	init:function(){
		for(var i =1 ; i < this.lastChild+1;i++){
			var objChild = this.container.children[i];
			objChild.style.opacity=0;
		}
		this.inDisplay=0;
		this.nextDisplay=1;
		this.start();
	},
	
	fade:function(obj,type){
		if(type=="in"){
			obj.style.opacity=this.st/this.steps; 
		}else{
			obj.style.opacity=(this.steps -this.st)/this.steps; 			
		}
	},
	anime:function(anitype){
		if(SlideShow.pp ==0){
			SlideShow.st++;
			SlideShow[anitype](SlideShow.container.children[SlideShow.inDisplay],"out");
			SlideShow[anitype](SlideShow.container.children[SlideShow.nextDisplay],"in");
			if(SlideShow.st==SlideShow.steps){
				SlideShow.st=0;
				SlideShow.inDisplay=SlideShow.nextDisplay;
				SlideShow.nextDisplay=(SlideShow.nextDisplay==SlideShow.lastChild)?0:SlideShow.nextDisplay+1;
				SlideShow.pp=SlideShow.wait;
			}
		}
		else{
			if(SlideShow.pp == SlideShow.DPause)
				SlideShow.pp=0;
			else
				SlideShow.pp=SlideShow.pp+SlideShow.wait;
		}
		
	},
	start:function(){
		this.timer = window.setInterval(SlideShow.anime, this.wait,"fade");
	},
	stop:function(){
		window.clearInterval(this.timer);
	}
};

