
/** NEWS BOX FUNCTIONS **/

var currentNewsEntry = 0;

function showPreviousNewsEntry(){
	stopNewsRotation();
	rotateNewsPrevious();
}

function showNextNewsEntry(){
	stopNewsRotation();
	rotateNewsNext();
}

function rotateNewsNext(){
	document.getElementById('news_'+currentNewsEntry).style.display = "none";
	
	if( currentNewsEntry > 0 ){
		currentNewsEntry--;
	} else {
		//count news
		var lastEntryId = 0;
		for(var i = 0 ; i < 99 ; i++){
			if(	document.getElementById('news_'+i) == undefined ){
				lastEntryId = i-1;
				break;
			}
		}
		currentNewsEntry = lastEntryId;
	}	
	document.getElementById('news_'+currentNewsEntry).style.display = "block";
}

function rotateNewsPrevious(){
	document.getElementById('news_'+currentNewsEntry).style.display = "none";
	
	if( document.getElementById('news_'+(currentNewsEntry+1)) != undefined ){
		currentNewsEntry++;
	} else {
		currentNewsEntry = 0;
	}	
	document.getElementById('news_'+currentNewsEntry).style.display = "block";
}

var newsRotationIntervalId;

function startNewsRotation(){
	newsRotationIntervalId = window.setInterval('rotateNewsNext()', 10000);	
}

function stopNewsRotation(){
	window.clearInterval(newsRotationIntervalId);
}