/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

// ========================================================= */

// jquery.pota.innerfade.js

// Datum: 2008-08-15
// Autor: ikeda@midc.jp
// Mail: apachot@openstudio.fr
// Web: http://www.nissenren-sendai.or.jp/
(function ($)
{
    $.fn.nsInnerfade = function (options)
    {
        return this.each(function (){$.nsInnerfade(this, options);});
    };

    $.nsInnerfade = function (container, options)
    {
        var settings = {
            'speed':            1000,
            'timeout':          5000,
            'containerheight':  '197px',
            'runningclass':     'innerfade'
        };
        if (options) {
            $.extend(settings, options);
        }
        var elements = $(container).children();

        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0, n = elements.length; i < n; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            }

            $(container).append(animation);
            setTimeout(function ()
            {
                $(animation).remove();
                $(elements[0]).fadeIn(settings.speed, function ()
                {
                    removeFilter($(this)[0]);
                });
            }, delay);

            $.nsInnerfade.last  = 0;
            $.nsInnerfade.timer = setTimeout(function ()
            {
                $.nsInnerfade.next(elements, settings, 1, 0);
            }, settings.timeout + delay);
        }
    };

    $.nsInnerfade.timer = null;
    $.nsInnerfade.last  = null;

    $.nsInnerfade.next = function (elements, settings, current, last)
    {
        $(elements[last]).fadeOut(settings.speed);
        $(elements[current]).fadeIn(settings.speed, function ()
        {
            removeFilter($(this)[0]);
        });

        if ((current + 1) < elements.length) {
            current = current + 1;
            last    = current - 1;
        } else {
            current = 0;
            last    = elements.length - 1;
        }
        $.nsInnerfade.last = last;

        $.nsInnerfade.timer = setTimeout((function ()
        {
            $.nsInnerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };
}) (jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element)
{
    if (element.style.removeAttribute) {
        element.style.removeAttribute('filter');
    }
};
