﻿function slideSwitch() {

    var $old = null;
    var $next = null;

    $("#fa_container > DIV").each(function() {

        if ($old != null && $next == null) {

            $next = $(this);
        }

        if ($(this).attr('class') == 'fa_active') {

            $old = $(this);
        }
    });

    if ($next == null) {

        $next = $("#fa_container > DIV:first");
    }

    if ($old == null || $next == null) {
        return;
    }

    $next.fadeIn(1500, function() { $next.removeClass('fa_hidden').addClass('fa_active'); });
    $old.fadeOut(1500, function() { $old.removeClass('fa_active').addClass('fa_hidden'); });

    $old.children('.fa_background').css({ 'z-index': '30' });
    $old.children('.fa_textbox').css({ 'z-index': '40' });

    $next.children('.fa_background').css({ 'z-index': '60' });
    $next.children('.fa_textbox').css({ 'z-index': '70' });
}


$(document).ready(function() {

    if ($.browser.msie && $.browser.version < 7) {
        DD_belatedPNG.fix('.fa_background')
    }
    var first = true;

    $("#fa_container > DIV").each(function() {

        if (first) {

            $(this).removeClass('fa_hidden').addClass('fa_active').show();


            $(this).children('.fa_background').css({ 'z-index': '60' });
            $(this).children('.fa_textbox').css({ 'z-index': '70' });

            first = false;
        }
        else {

            $(this).hide();
            $(this).children('.fa_background').css({ 'z-index': '30' });
            $(this).children('.fa_textbox').css({ 'z-index': '40' });
        }


    });

    if (!first) {
        setInterval("slideSwitch()", 5000);
    }
});
