﻿// portada.js
// Mecanismo de animación para las imágenes centrales de la portada
// ================================================================================
    var MANIMACIO = "fade";
    var TANIMACIO = "1.5";
    var TIARRANQU = 4 * 1000; 
    var TREPETICI = 4 * 1000;
    var TimerRepe = null;

    var s01 = 1, imgs01 = ["img/home-01pae.gif",       "img/home-02pae.gif",       "img/home-03pae.gif"];
    var s02 = 1, imgs02 = ["img/home-01newland.gif",   "img/home-02newland.gif",   "img/home-03newland.gif"];
    var s03 = 1, imgs03 = ["img/home-01pfl.gif",       "img/home-02pfl.gif",       "img/home-03pfl.gif"];
    var s04 = 1, imgs04 = ["img/home-01whis.gif",      "img/home-02whis.gif",      "img/home-03whis.gif"];
    var s05 = 1, imgs05 = ["img/home-01excelcuts.gif", "img/home-02excelcuts.gif", "img/home-03excelcuts.gif"];

    function fade01() {
        Transitions.fade("#img01", imgs01[s01], "", TANIMACIO,
                function () {
                    if (++s01 == 3) { s01 = 0; }
                    TimerRepe = setTimeout("fade02();", TREPETICI);
                });
    }

    function fade02() {
        Transitions.fade("#img02", imgs02[s02], "", TANIMACIO,
                function () {
                    if (++s02 == 3) { s02 = 0; }
                    TimerRepe = setTimeout("fade03();", TREPETICI);
                });
    }

    function fade03() {
        Transitions.fade("#img03", imgs03[s03], "", TANIMACIO,
                function () {
                    if (++s03 == 3) { s03 = 0; }
                    TimerRepe = setTimeout("fade04();", TREPETICI);
                });
    }
    function fade04() {
        Transitions.fade("#img04", imgs04[s04], "", TANIMACIO,
                function () {
                    if (++s04 == 3) { s04 = 0; }
                    TimerRepe = setTimeout("fade05();", TREPETICI);
                });
    }
    function fade05() {
        Transitions.fade("#img05", imgs05[s05], "", TANIMACIO,
                function () {
                    if (++s05 == 3) { s05 = 0; }
                    TimerRepe = setTimeout("fade01();", TREPETICI);
                });
    }

    function wipe01() {
        Transitions.wipe("#img01", imgs01[s01], "", TANIMACIO, "LR", "0%", "No",
                function () {
                    if (++s01 == 3) { s01 = 0; }
                    TimerRepe = setTimeout("wipe02();", TREPETICI);
                });
    }

    function wipe02() {
        Transitions.wipe("#img02", imgs02[s02], "", TANIMACIO, "LR", "0%", "No",
                function () {
                    if (++s02 == 3) { s02 = 0; }
                    TimerRepe = setTimeout("wipe03();", TREPETICI);
                });
    }

    function wipe03() {
        Transitions.wipe("#img03", imgs03[s03], "", TANIMACIO, "LR", "0%", "No",
                function () {
                    if (++s03 == 3) { s03 = 0; }
                    TimerRepe = setTimeout("wipe04();", TREPETICI);
                });
    }
    function wipe04() {
        Transitions.wipe("#img04", imgs04[s04], "", TANIMACIO, "LR", "0%", "No",
                function () {
                    if (++s04 == 3) { s04 = 0; }
                    TimerRepe = setTimeout("wipe05();", TREPETICI);
                });
    }
    function wipe05() {
        Transitions.wipe("#img05", imgs05[s05], "", TANIMACIO, "LR", "0%", "No",
                function () {
                    if (++s05 == 3) { s05 = 0; }
                    TimerRepe = setTimeout("wipe01();", TREPETICI);
                });
    }

    function onLoad() {
        
        // Cache imágenes
        var listaImagenes = imgs01.join(",") + "," + imgs02.join(",") + "," + imgs03.join(",") + "," + imgs04.join(",") + "," + imgs05.join(",");
        var arrayImagenes = listaImagenes.split(",");
        Transitions.cache(arrayImagenes);

        if (MANIMACIO == "fade") {
            TimerRepe = setTimeout("fade01();", TIARRANQU);
        }

        if (MANIMACIO == "wipe") {
            TimerRepe = setTimeout("wipe01();", TIARRANQU);
        }

    }
