/*
 * Accordion fuer Schwerpunkte und News initialisieren
 */

window.addEvent('domready', function() {

	var counter = 0;

	$$('ul.focus').each(function(item) { counter++; item.addClass('active'); });

	if (counter > 0) {
		var myAccordion = new Accordion($('.focus'), 'strong', 'em', {
			opacity: false,
			display: -1,
			alwaysHide: true,
			onActive: function(toggler, element){
				toggler.setStyle('color', '#FFF');
			},
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#FFF');
			}
		});
	}

	counter = 0;
	$$('ul.news').each(function(item) { counter++; item.addClass('active'); });

	if (counter > 0) {
		var myAccordion2 = new Accordion($('ul.news'), 'ul.news h3', 'ul.news div', {
			opacity: false,
			display: -1,
			alwaysHide: true,
			onActive: function(toggler, element){
				toggler.setStyle('color', '#FFF');
			},
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#FFF');
			}
		});
	}
});




/*
 * Theme bei Schwerpunkten wechseln
 */

var themes = [];
var currentTheme = 0;

window.addEvent('load', function() {

	themes.push($('themeImg').getProperty('src'));
	
	$$('.focus img').each(function(img) { 

		themes.push(img.getProperty('src'));
		img.dispose();

	});

	if (themes.length > 1) var myTimer = changeTheme.delay(5000)

});


function changeTheme () {

	var myFx = new Fx.Tween($('themeImg'), {property: 'opacity', duration: 'normal', onComplete: function () { changeThemeReal(); } }).start(1,0);

/*
	$('themeImg').fade('hide');
	$('themeImg').setProperty('src', themes[currentTheme]);
	$('themeImg').fade('in');
*/

}


function changeThemeReal () {

	currentTheme += 1;
	if (currentTheme == themes.length) currentTheme = 0;
	$('themeImg').setProperty('src', themes[currentTheme]);

	var myFx = new Fx.Tween($('themeImg'), {property: 'opacity', duration: 'long'}).start(0,1);

	changeTheme.delay(5000);

}
