function initTopnews() {
	topnews_show = 1;
	effectActive = false;
	topnewsPlay = true;
	setTimeout("showNextTopnews()", 8000);
}

function showNextTopnews() {
	if(topnewsPlay) {
		if(topnews_show == 1)
			changeTopnews(2, false);
		else if(topnews_show == 2)
			changeTopnews(3, false);
		else if(topnews_show == 3)
			changeTopnews(1, false);
		
		if(topnewsPlay)
			setTimeout("showNextTopnews()", 8000);
	}
}

function changeTopnewsMootools(topnews, pause) {
	if(pause)
		topnewsPlay = false;
	
	if(effectActive || topnews_show == topnews)
		return;
	
	effectActive = true;
	var headerOut = "topnews" + topnews_show + "_header";
	var headerIn = "topnews" + topnews + "_header";
	var topnewsOut = "topnews" + topnews_show;
	var topnewsIn = "topnews" + topnews;
	
	//$(headerOut).className = 'topnews_inactive';
	//$(headerIn).className = 'topnews_active';
	/*
	var fadeform = new Fx.Style(topnewsOut, 'opacity', {duration: 400,transition: Fx.Transitions.Quart.easeInOut} ); 
	fadeform.start(1,0).chain(function(){ 
	var fx = new Fx.Styles('addmessage', {duration:500, wait:false}); 
	fx.start({'height': 50}).delay(5000); 
	}).chain(function(){ 
	document.getElementById('message-success').innerHTML = result; 
	var div = $('review-success').setStyles({display:'block',opacity: 0}); 
	new Fx.Style('message-success', 'opacity', {duration: 400} ).start(1); 
	}); */
	/*
	$(topnewsOut).fade('out').chain(function() {
		$(topnewsOut).setStyle('display', 'none').chain(function() {
			$(topnewsIn).fade('hide').chain(function() {
				$(topnewsIn).setStyle('display', 'block').chain(function() {
					$(topnewsIn).fade('in').chain(function() {alert("Hallo")})				
				})
			})			
		})
	});
	*/
	//$(topnewsOut).fade('out').chain(function() {$(topnewsIn).fade('hide'); $(topnewsIn).setStyle('display', 'block'); $(topnewsIn).fade('in');});
	
	
	
	//$(topnewsOut).setStyle('display', 'none').chain(function() {});
	//$(topnewsIn).fade('in');
	/*new Fx.Style(topnewsIn, 'opacity', {duration: 0} ).start(0);	
	new Fx.Style(topnewsIn, 'opacity', {duration: 1000} ).start(1);
	*/
	//$(topnewsIn).fade('in'); 
	
	topnews_show = topnews;
	effectActive = false;	
}

function changeTopnews(topnews, pause) {
	if(pause)
		topnewsPlay = false;
	
	if(effectActive || topnews_show == topnews)
		return;
	
	effectActive = true;
	var headerOut = "topnews" + topnews_show + "_header";
	var headerIn = "topnews" + topnews + "_header";
	var topnewsOut = "topnews" + topnews_show;
	var topnewsIn = "topnews" + topnews;
	
	//$('topnews').style.height = "";
	//$('topnews').style.height = $('topnews').offsetHeight + "px";
	
	$(headerOut).className = 'topnews_inactive';
	$(headerIn).className = 'topnews_active';

	//new Effect.Fade(topnewsOut, {duration: 0.5, queue:'end'});
	//new Effect.Appear(topnewsIn, {duration: 0.5, queue:'end'});
	
	$(topnewsOut).style.display = "none";
	$(topnewsIn).style.display = "block";
	

	//new Effect.Fade(topnewsOut, {duration: 0.5, afterFinish: function() { $(headerOut).className = 'topnews_inactive';
	//$(headerIn).className = 'topnews_active'; }});
	//new Effect.Appear(topnewsIn, {duration: 0.3, queue:'end', afterFinish: function() {$('topnews').style.height = ""; $('topnews').style.height = $('topnews').offsetHeight + "px";}});
	
	
	//Effect.SlideRightIn('topnews2',{queue:{scope:'myscope', position:'end', limit: 1}});
	//SlideRightIn('demo-effect', {duration: 2, queue: 'end'});"" +
	//new Effect.SlideRightOut('topnews1', {duration: 2, queue: 'end'});
	//new Effect.SlideRightOut('topnews1', {duration: 1, queue: 'end'});
	//new Effect.SlideRightIn(topnewsIn, {duration: 1, queue: 'end'});
	//new Effect.SlideRightIn('topnews2', {duration: 2, queue: 'end'});
	//Effect.toggle('topnews1','slide');
	//Effect.SlideUp(topnewsOut,{duration:1.0});
	//Effect.toggle(topnewsIn,'slide');
	//new Effect.Fade(elementOut);
	
	topnews_show = topnews;
	effectActive = false;	
}

function changeDisplay(elementShow, elementHide, reiterActive, reiterInactive) {
	$(reiterActive).className = "reiter_text_active";
	$(reiterActive+"_end").className = "reiter_end_active";
	$(reiterInactive).className = "reiter_text_inactive";
	$(reiterInactive+"_end").className = "reiter_end_inactive";
	$(elementHide).style.display = "none";
	$(elementShow).style.display = "block";
}

function changeSpiele(elementShow) {
	var elementHide = "";
	if(elementShow == "delspiele") {
		elementHide = "ercspiele";
	}
	else {
		elementHide = "delspiele";
	}
	
	$(elementHide).style.display = "none";
	$(elementShow).style.display = "block";
}

initTopnews();

function changeMonth(monat, jahr) {
	//$('ajaxloadinggif').style.display = "block";
	new Ajax.Updater('kalender', 'content/home/kalender.php', {
		method: 'get',
		parameters: {monat: monat, jahr: jahr},
		onFailure: function(){ alert('Something went wrong...')}
	});
}
