Cycle through elements with fade in/out (+++)

Cycle through elements: Based on:: http://stackoverflow.com/questions/8469907/running-continuous-events-after-each-other

by lovromar

HTML

<div id="containerrr">
    <ul id="tweets">
    <li>tweet bat</li>
    <li>tweet bi</li>
    <li>tweet hiru</li>
    <li>tweet lau</li>
    <li>tweet bost</li>
    </ul>
</div>

CSS

#tweets{margin:0; padding:10px;}

#tweets li{margin:0; padding:10px; background-color:#d6d3ce; text-align:center;}

JavaScript

function switchElement() {
    $('#tweets li:visible').fadeOut(function () {
        $(this).next().length ? $(this).next().fadeIn() : $('#tweets li').eq(0).fadeIn();
    });
}
$('#tweets li').hide().eq(0).show(); // show only the first image
if ($('#tweets li').length >= 2) {
    setInterval(switchElement, 3000);
} 
else if ($('#tweets li').length === 0) {
    alert('noooooooorl...');
}