﻿TSlider = function(aImgIdArr, aSepImgId, aStartTicks){
	this.id = 'slider';
	this.parentIndex = 0;
	this.state = 0; // 0 - start timeout, 1 - separator image, 2 - image;
	this.stateIndex = 0;
	
	this.startTicks = aStartTicks;
	this.slideTicks = 40;
	this.sepTicks = 5;

	this.ticker = new TTicker(10, false);
	
	//this.sepImg = document.getElementById(aSepImgId);
	this.imgArr = aImgIdArr ;
	//this.imgArr = new Array(aImgIdArr.length);
	//for(var i=0; i<aImgIdArr.length;i++){
		//this.imgArr[i] = document.getElementById(aImgIdArr[i]);
	//	this.imgArr[i] = aImgIdArr[i];
	//}
}

TSlider.prototype.setParentIndex = function(aIdx){
	this.parentIndex = aIdx;
	this.id += aIdx +'';
}

TSlider.prototype.switchOff = function(obj){
	if(obj) obj.style.display = 'none';
}

TSlider.prototype.switchOn = function(obj){
	if(obj) obj.style.display = '';
}

TSlider.prototype.switchObj = function(){
	/*if(this.state==1){
		this.state = 2;
		this.switchOff(this.sepImg);
	    this.switchOn(this.imgArr[this.stateIndex]);
	} else {
		this.state = 1;*/
		this.state = 2;
	    this.switchOff( document.getElementById(this.imgArr[this.stateIndex]) );
	    if((++this.stateIndex) >= this.imgArr.length) this.stateIndex = 0;
	    this.switchOn( document.getElementById(this.imgArr[this.stateIndex]) );
	    //this.switchOn(this.sepImg);
	//}
}

TSlider.prototype.next = function(){
	if(this.ticker.tick()){
		if(this.state==0){
			this.ticker.setValue(this.startTicks);
			this.state = 2;
		} else {
			//if (this.state==1) {
				this.switchObj();
				this.ticker.setValue(this.slideTicks);
			/*} else {
				this.switchObj();
				this.ticker.setValue(this.sepTicks);
			}*/
		}
	}	
}