var article_num = 1;
var prev_num = 1;
var current_tr = "";
var no_of_trs = 0;

function rotateNews() {
	// current tr
    current_tr = 'news_' + article_num;
	
	if ($(current_tr)) {
		hideNews();
		showNews.delay(500);
		window.setTimeout(rotateNews, 5000);
    } 
	else {
		article_num = 1;
		hideNews();
		showNews.delay(500);
		window.setTimeout(rotateNews, 5000);
    }
}

function hideNews(){
	var mySmoothShow = $('news_' + prev_num).smoothHide();
}

function showNews(){
	var mySmoothShow = $('news_' + article_num).smoothShow();
	prev_num = article_num;
	article_num++;
}

window.addEvent('domready', function() { 

    // Count the number of news item rows
    var news_trs = $$('tr[class=news-item]');
    no_of_trs = news_trs.length;
    window.setTimeout(rotateNews, 5000);
	
	if(no_of_trs >= 2){
		article_num++;
	}

});