var recentThreadsSettings = {
	animationSpeed: 600,
	interval: 10000,
	totalNodes: 4,
	isPlaying: false,
	isTransitioning: false,
	rotate: function() {
	    if(!recentThreadsSettings.isPlaying && !recentThreadsSettings.isTransitioning) {
	        // Move last node to start and show it
        	// Re-compose onclick actions, as ie breaks when using clone(true)
        	$('#MessageBoardBox ul li:last').clone().hide().prependTo('#MessageBoardBox ul').css('cursor', 'pointer').click(function() {
        		window.location.href = $(this).find('h6 a').attr('href');}).animate({opacity: 0, top: -50, height: 0}, 1).animate({top: 0, height: '65px'}, recentThreadsSettings.animationSpeed).animate({opacity: 1}, recentThreadsSettings.animationSpeed);

        	$('#MessageBoardBox ul li:last').remove();
	    }
	}
};

function RRay_VideoStartedCallback() {
    recentThreadsSettings.isPlaying = true;
}

function RRay_VideoStoppedCallback() {
    recentThreadsSettings.isPlaying = false;
}

function RRay_StartFadingInImage() {
    recentThreadsSettings.isTransitioning = true;
}

function RRay_StopFadingInImage() {
    recentThreadsSettings.isTransitioning = false;
}

$(function(){
	// Hide everything after the first four
	$('#MessageBoardBox ul li').slice(recentThreadsSettings.totalNodes).hide();
	
	// Start rotating after a couple seconds
    setTimeout(function() {
        recentThreadsSettings.rotate();
        setInterval(recentThreadsSettings.rotate, recentThreadsSettings.interval);
    }, 3000);
});