jQuery().ready(function () {

    jQuery('.teaserText .readMore').on('click', function () {
        var that = jQuery(this);
        var content = jQuery('.textInnerHidden');
        var current = that.parents('.teaserHiddenContent').find('.textInnerHidden');

        if (current.is(':hidden')) {
            jQuery('.readMore').html('weitere Informationen');
            content.hide();
            that.html('Schließen');
            current.show();
        } else {
            that.html('weitere Informationen');
            current.hide();
        }
    });

    if (jQuery('.watchword-slider').length) {
        jQuery(document).ready(function () {
            // Losung slider
            var images = jQuery('.watchword-slider .img'), imgIx = 0;
            (function nextImage() {
                jQuery(images[imgIx++] || images[imgIx = 0, imgIx++]).fadeIn(1000).delay(2500).fadeOut(500, nextImage);
            })();
        });
    }

    if (jQuery('.donation-sum').length) {
        jQuery('.donation-sum').each(function () {
            setSum(this, this.getAttribute('id'));
        });
    }

    function setSum(element, potUid){
        /* build up request url */
        path = window.location.protocol + '//' + window.location.host + '/index.php?id=7627';
        potUid = 'tx_donationbarometer_money[potUid]=' + potUid;
        controller = 'tx_donationbarometer_money[controller]=Money';
        action = 'tx_donationbarometer_money[action]=moneyCall';
        typeNum = 'type=1908';

        url = path + '&' + controller + '&' + action + '&' + typeNum;

        jQuery.ajax({
            url: url,
            data: potUid,
            datatype: "json",
            type: "post",
            success: function (value) {
                value = (value / 1000000).toFixed(2).toString().replace('.', ',');
                jQuery(element).text(value);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {

            }
        });
    }
});


