$(document).ready(function(){
    
    $('#banner-text>div, #logo-wrapper a img, div.blogFeed div.item').hide();

    (function switchLogo(elem)
    {
        elem.fadeIn(1000,function()
        {
            setTimeout(function()
            {
                elem.fadeOut(1000,function()
                {
                    switchLogo($(this).next().length > 0?
                        $(this).next():
                        $(this).siblings().eq(0) );
                });    
            },1000);
        });
    })($('#logo-wrapper a img').eq(0));

	(function switchNews(elem)
    {
        elem.fadeIn(500,function()
        {
            setTimeout(function()
            {
                elem.fadeOut(500,function()
                {
                    switchNews($(this).next().length > 0?
                        $(this).next():
                        $(this).siblings().eq(0) );
                });
            },10000);
        });
    })($('div.blogFeed div.item').eq(0));

    (function switchQuote(elem)
    {
        if(elem.attr('id')=='banner-text')
        {
            range = $('#banner-text>div').length;
            slice = Math.floor(Math.random()*range).toFixed(0);
            elem = $('#banner-text>div').eq(slice);
        }
        elem.fadeIn(1000,function()
        {
            setTimeout(function()
            {
                elem.fadeOut(1000,function()
                {
                    range = $('#banner-text>div').length;
                    slice = Math.floor(Math.random()*range).toFixed(0);
                    while($('#banner-text>div').eq(slice).text()==elem.text())
                    {
                        slice = Math.floor(Math.random()*range).toFixed(0);
                    }
                    switchQuote($('#banner-text>div').eq(slice).length > 0?
                        $('#banner-text>div').eq(slice):
                        $('#banner-text>div').siblings().eq(0)
                    );
                });    
            },10000);
        });
    })($('#banner-text'));
});


