﻿function classAnimacao(parcolecaoImgs, parclassDisplay) {
    this.colecaoImgs = parcolecaoImgs; this.enumeradorImgs = this.colecaoImgs.getEnumerador(); this.display = parclassDisplay; this.parado = true; this.execAnimacao = function () {
        this.parado = false; Obj = this; if (this.enumeradorImgs.moveNext())
            this.display.exibirImg(this.enumeradorImgs.imgCurrent); setInterval(function () { execAnimacaImgs(Obj) }, 10000);
    }; this.pararAnimacao = function () { this.parado = true; };
}
function execAnimacaImgs(obj) {
    if (obj.parado)
        return; if (obj.enumeradorImgs.imgCurrent)
        obj.display.ocultarImg(obj.enumeradorImgs.imgCurrent); if (!obj.enumeradorImgs.moveNext()) {
        obj.enumeradorImgs = obj.colecaoImgs.getEnumerador(); if (obj.enumeradorImgs.moveNext())
            obj.display.exibirImg(obj.enumeradorImgs.imgCurrent);
    }
    else { obj.display.exibirImg(obj.enumeradorImgs.imgCurrent); } 
}
function colecaoImgs() {
    this.imgs = new Array(); this.add = function (img) { img[this.imgs.length - 1] = img; }; this.remove = function (img) {
        novoArray = new Array(); for (contador = 0; contador < this.imgs.length; contador++) {
            if (imgs[contador] != img)
                novoArray.push(imgs[contador]);
        }
        this.imgs = novoArray;
    }; this.getEnumerador = function () { return new enumeradorImgs(this.imgs); };
}
function enumeradorImgs(colecaoImgs) {
    this.imgs = colecaoImgs; this.index = -1; this.imgCurrent = null; this.moveNext = function () {
        if (this.index >= this.imgs.length - 1) { return false; }
        else { this.index++; this.imgCurrent = this.imgs[this.index]; return true; } 
    };
}
function animar(idDiv) { colecao = new colecaoImgs(); colecao.imgs = document.getElementById(idDiv).getElementsByTagName("img"); anima = new classAnimacao(colecao, { exibirImg: function (img) { img.style.display = "block" }, ocultarImg: function (img) { img.style.display = "none" } }); anima.execAnimacao(); }
