﻿
YUI().use("node", "anim-base", "event", function (Y) {

    Y.on("domready", init);

    function init() {

        var timeOut = 5000;

        var start = new Y.Anim({
            node: '#topimageHolder2',
            duration: 0.05,
            to: { opacity: 0 }
        });
        start.run();

        var img = 0;
        var max = myimages.length;
        var first = true;
        function changeImage(e) {

            if (max > 1) {

                img++;
                if (img == max) {
                    img = 0;
                }
                first = !first;

                if (first == true) {
                    document.getElementById("topimageHolder").style.backgroundImage = "url(" + myimages[img].src + ")";
                    var anim = new Y.Anim({
                        node: '#topimageHolder2',
                        duration: 0.8,
                        to: { opacity: 0 }
                    });
                    anim.run();
                } else {
                    document.getElementById("topimageHolder2").style.backgroundImage = "url(" + myimages[img].src + ")";
                    var anim2 = new Y.Anim({
                        node: '#topimageHolder2',
                        duration:0.8,
                        to: { opacity: 1 }
                    });
                    anim2.run();
                }

            }

        }

        Y.later(timeOut, null, changeImage, [], true);
    }

});
