

var slideshow_class = function() {
    this.ultimo = -1;
    this.total = 0;
}

var slideshow_foto_class = function(i,nome) {
    this.i = i;
    this.nome = nome;
    this.imgObj = findObj('tn'+i);
    if(!this.imgObj) alert('Erro ao adicionar a foto '+i);
}

//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

slideshow_class.prototype.exibir = function(i)
{

    if(this.ultimo > -1 && i != this.ultimo) {
        var ultimo = this.ultimo;
        this.ultimo = i;
        carrinho.atualizarIconeComprar(ultimo);
    }else{
        this.ultimo = i;
    }

    topPage(0);

    var tnZoom  = findObj('tnZoom');
    tnZoom.src =  this.fotos[i].imgObj.src.replace('thumbnails','images');
    layer.Show('slideshowDiv');
    layer.Hide('slideshowStartDiv');

    carrinho.atualizarIconeComprar(i);

    layer.setText('tnContador','Foto '+(i+1)+' de '+this.total);

}

slideshow_class.prototype.proxima = function () {

    if(this.ultimo+1 == this.total) return;
    this.exibir(this.ultimo+1);

}

slideshow_class.prototype.anterior = function () {

    if(this.ultimo-1 == -1) return;
    this.exibir(this.ultimo-1);

}
slideshow_class.prototype.definirAlbum = function(id,nome) {

    this.albumId = id;
    this.albumNome = nome;
    this.fotos = {};

}

slideshow_class.prototype.adicionarFoto = function(i,nome) {

    this.fotos[i] = new slideshow_foto_class(i,nome);
    this.total++;

}

slideshow_class.prototype.obterIFoto = function(nome) {

    for(var i in this.fotos) {
        if(this.fotos[i].nome == nome) {
            return i;
        }
    }
    return -1;
}

var slideshow = new slideshow_class();
