var tpsObjects = [];

// Deprecated. Use tpsObjects instead.
var tpsInstance = null;

jQuery(function ($) {
    $('[data-theiaPostSlider-sliderOptions]').each(function () {
        var o = {};

        o.definitionElement = $(this);
        o.sliderOptions = JSON.parse(o.definitionElement.attr('data-theiaPostSlider-sliderOptions'));
        o.onChangeSlide = JSON.parse(o.definitionElement.attr('data-theiaPostSlider-onChangeSlide'));

        $(document).bind('theiaPostSlider.changeSlide', function (event, slideIndex) {
            eval(o.onChangeSlide);
        });

        $(document).ready(function () {
            o.tpsInstance = new tps.createSlideshow(o.sliderOptions);

            if (tpsObjects.length == 0) {
                tpsInstance = o.tpsInstance;
            }

            tpsObjects.push(o);
        });
    });
});