/*
* @descrição Script slideshow feito carrosel não acaba ao chegar no último volta para o primeiro item e tal...
* @autor Tiago Finger
* @empresa FastCompras LTDA
* @data 25/12/2007
* @hora 01:31
*/

function SlideShow()
{
	//velocidade na interação das fotos
	this.SlideShowSpeed = 1000;

	//tempo do fade
	this.CrossFadeDuration = 0;

	//array de imagens e legendas
	this.Picture = new Array();
	this.Caption = new Array();
	this.showHot = false;

	//por padrão imagem não tem legenda
	this.isCaption = false;

	//pre-load de imagens
	//variável de controle do laço
	//tamanho do array de imagens
	this.preLoad = new Array();
	this.jss = 0;
	this.pss = 0;

	this.loadImages = function(){
		this.pss = this.Picture.length;
		for (iss = 0; iss < this.pss; iss++)
		{
			this.preLoad[iss] = new Image();
			this.preLoad[iss].src = this.Picture[iss];
		}
	}

	this.setIdCaption = function(valor){
		this.idCaption = valor;
	}

	this.setIdImage = function(valor){
		this.idImage = valor;
	}

	this.control = function(how){
		if (this.showHot)
		{
			if (how=="H") this.jss = 0;
			if (how=="F") this.jss = this.jss + 1;
			if (how=="B") this.jss = this.jss - 1;
			if (this.jss >= this.pss ) this.jss = 0;
			if (this.jss < 0 )
			{
			  this.jss = this.Picture.length - 1;
			}

			this.loadImages();

			if (document.all)
			{
				document.getElementById(this.idImage).style.filter="blendTrans(duration=1)";
				document.getElementById(this.idImage).style.filter="blendTrans(duration=this.CrossFadeDuration)";
				document.getElementById(this.idImage).filters.blendTrans.Apply();
			}

			var tamanhoPreload = this.preLoad.length;
			if( this.jss < tamanhoPreload )
				document.getElementById(this.idImage).src = this.preLoad[this.jss].src;

			//tem leganda na imagem? então manda ver
			if( this.isCaption )
			{
				if (document.getElementById)
					document.getElementById(this.idCaption).innerHTML = this.Caption[this.jss];
			}
			if (document.all)
				document.getElementById(this.idImage).filters.blendTrans.Play();
		}
	}
}

//instancia objeto
var SlideShow = new SlideShow();
SlideShow.showHot = true;