Poto.OnReady(function() {
    var flash = document.getElementById("flash");

    flash.pictures = flash.getElementsByTagName("A");
    flash.picture = flash.pictures[0];
    flash.pic_items = flash.getElementsByTagName("LI");
    flash.current_picture = flash.pic_items[0];
    flash.index = 0;

    for (var i = 0; i < flash.pictures.length; i++) {
        flash.pictures[i].image = flash.pictures[i].getElementsByTagName("IMG")[0];
    }

    for (var i = 0; i < flash.pic_items.length; i++) {
        flash.pic_items[i].index = i;
        flash.pic_items[i].picture = flash.pic_items[i].getElementsByTagName("IMG")[0];
        flash.pic_items[i].onclick = function() {
            flash.stop = true;
            flash.index = this.index;
            if (flash.current_picture != this) {
                flash.start = 10;
                flash.flag = -1;

                window.setTimeout(function anamorphism() {
                    flash.start += flash.flag;
                    flash.picture.image.style.cssText = "filter: Alpha(Opacity=" + (flash.start * 10) + "); opacity: " + (flash.start / 10);
                    if (flash.start != 10) {
                        if (flash.start == 0) {
                            flash.picture.style.cssText = "display: none";

                            flash.picture = flash.pictures[flash.index];
                            flash.picture.style.cssText = "display: block;";
                            flash.picture.image.style.cssText = "filter: Alpha(Opacity=0); opacity: 0;";
                            flash.flag *= -1;
                        }
                        window.setTimeout(function() { anamorphism() }, 10);
                    }
                }, 10);

                flash.current_picture.className = "";
                this.className = "current";
                flash.current_picture = this;
            }
        }
    }

    window.setTimeout(function roll() {
        if (!flash.stop) {
            flash.index++;
            if (flash.index == flash.pic_items.length) {
                flash.index = 0;
            }
            flash.pic_items[flash.index].onclick();
        }
        flash.stop = false;
        window.setTimeout(function() { roll(); }, 6000);
    }, 6000);

    var NewOrder = Poto.getElements(["pnlOrders"]);
    NewOrder.orders = NewOrder.pnlOrders.getElementsByTagName("LI");
    window.setTimeout(function beginUp() {
        var __current = NewOrder.orders[0];
        __current.start = 0;
        window.setTimeout(function up() {
            __current.start -= 2;
            __current.style.marginTop = __current.start + "px";
            if (__current.start <= -45) {
                NewOrder.pnlOrders.appendChild(__current);
                __current.style.marginTop = "0px";
            } else {
                window.setTimeout(function() { up(); }, 10);
            }
        }, 10);

        window.setTimeout(function() { beginUp(); }, 4000);
    }, 4000);

});
