﻿
var images = {
    img: [],
    pointer: 0,
    frame: "",
    timer: "",
    statu: false,
    init: function(id) {
        this.frame = document.getElementById(id);
        var obj = this;
        $("div[id='DELICIOUSWOWGOLD_show']", $("#DELICIOUSWOWGOLD_adv")).each(function(index, el) {
            obj.img.push(el);
        });
        this.show();
        this.play();
    },
    show: function() {
        for (var i = 0; i < this.img.length; i++) {
            this.img[i].style.display = "none";
        }
        this.img[this.pointer].style.display = "";
        document.getElementById('dlcount').innerHTML = this.pointer + 1 + "/" + this.img.length;
    },
    next: function(b) {
        this.pointer += 1;
        if (this.pointer >= this.img.length) {
            this.pointer = 0;
        }
        this.show();
        if (!b) this.clearTimer();
    },
    previous: function() {
        this.pointer -= 1;
        if (this.pointer < 0) {
            this.pointer = this.img.length - 1;
        }
        this.show();
        this.clearTimer();
    },
    clearTimer: function() {
        clearInterval(this.timer);
        this.statu = true;
        document.getElementById('btn_play').src = "images/pause.gif";

    },
    play: function() {
        var img_play = document.getElementById('btn_play');
        if (this.statu) {
            this.clearTimer();
            this.statu = true;
            img_play.src = "images/pause.gif";

        } else {
            this.timer = setInterval('images.next(true)', 3000);
            this.statu = false;
            img_play.src = "images/play.gif";

        }
    }
};
function next() {
    images.next(false);
}
function previous() {
    images.previous();
}
function play(o) {
    if (images.statu) {
        images.statu = false;
    } else {
        images.statu = true;
    }
    images.play(o);
}
$().ready(function() { images.init('DELICIOUSWOWGOLD_adv'); });
function transImg(obj, enable) {
    obj.filters.blendtrans.Apply();
    obj.filters[0].enabled = enable;
    obj.filters.blendtrans.Play();
}