$(document).ready(function() {
    function getTime() {
        return parseInt(($(this).data('tm')), 10);
    }

    var panels = $('#animated_panels > div');
    panels.each(function() {
        var transitions = [];
        $(this).find('img').each(function() {
            transitions.push($(this).data('ttn'));
        });
        transitions.push(transitions[0]);
        options = { 
            nowrap: true,
            after: function (curr, next, opts) {
                opts.fx = transitions[opts.currSlide+1];
            },
            timeoutFn: getTime
        };
        if (this.id == 'front-left') {
            options.end = function () {
                panels.each(function() {$(this).cycle(0)});
            }
        }
        $(this).cycle(options);
    });
});

