$(document).ready(function(){

	// Replace Font (Exclude IE5&6)
	if (/MSIE\s(5\.5|6\.)/.test(navigator.userAgent) == false) {
		Cufon
		.replace('h1',{
			fontFamily:'Berlin Sans FB'
		});
	}

	var first = 0;
	var speed = 3500;
	var pause = 5500;
	
		function removeFirst(){
			first = $('#tweet ul li:first').html();
			$('#tweet ul li:first')
			.fadeTo("slow", 0.01, function(){ //fade
				$(this).slideUp("slow", function() { //slide up
					$(this).remove(); //then remove from the DOM
				});
			});
			addLast(first);
		}
		
		function addLast(first){
			last = '<li style="display:none">'+first+'</li>';
			$('#tweet ul').append(last)
			$('#tweet ul li:last')
			.slideUp(speed).fadeIn(speed);
		}
	
	interval = setInterval(removeFirst, pause);

	setInterval( "slideSwitch()", 7000 );

});

function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
