//
// Verschachteltes Mootools-Accordion
// Nested Mootools Accordion
//
// von / by Bogdan Günther
// http://www.medianotions.de
//

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

	//call multiBox

	var initMultiBox = new multiBox({
		mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
		container: $(document.body),//where to inject multiBox
		descClassName: 'multiBoxDesc',//the class name of the description divs
		//path: './Files/',//path to mp3 and flv players
		path: 'typo3conf/ext/ju_multibox/res/player/',
		useOverlay: true,//use a semi-transparent background. default: false;
		maxSize: {w:600, h:400},//max dimensions (width,height) - set to null to disable resizing
		movieSize: {w:600, h:350},//default width/height of movie
		addDownload: false,//do you want the files to be downloadable?
		pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
		addRollover: true,//add rollover fade to each multibox link
		addOverlayIcon: true,//adds overlay icons to images within multibox links
		addChain: true,//cycle through all images fading them out then in
		recalcTop: true,//subtract the height of controls panel from top position
		addTips: true//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
	});



    jQuery('.accordion_content_1').fadeIn(50);
    jQuery('.accordion_content_2').fadeIn(50);
    jQuery('.accordion_content_2').fadeOut();
    jQuery('.accordion_content_1').fadeOut();

    jQuery('.accordion_content_1').fadeOut();
    jQuery('.accordion_toggler_1').bind('click',function(){
        if (jQuery(this).next('.accordion_content_1').hasClass('open')) {
            jQuery(this).next('.accordion_content_1').fadeOut();
            jQuery(this).next('.accordion_content_1').removeClass("open");
            jQuery(this).removeClass("open");
        } else {
            jQuery(this).next('.accordion_content_1').fadeIn();
            jQuery(this).next('.accordion_content_1').addClass("open");
            jQuery(this).addClass("open");
        }
    });

    jQuery('.accordion_content_2').fadeOut();

    jQuery('#lexikon .accordion_content_2').fadeIn();
    jQuery('.accordion_toggler_2').bind('click',function(){
        if (jQuery(this).next('.accordion_content_2').hasClass('open')) {
            jQuery(this).next('.accordion_content_2').fadeOut();
            jQuery(this).next('.accordion_content_2').removeClass("open");
            jQuery(this).removeClass("open");
        } else {
            jQuery(this).next('.accordion_content_2').fadeIn();
            jQuery(this).next('.accordion_content_2').addClass("open");
            jQuery(this).addClass("open");
       }
    });


	return;
	// Anpassung IE6
	if(window.ie6) var heightValue='100%';
	else var heightValue='';

	// Selektoren der Container für Schalter und Inhalt
	var togglerName='.accordion_toggler_';
	var contentName='.accordion_content_';


	// Selektoren setzen
	var counter=1;
	var toggler=$$(togglerName+counter);
	var content=$$(contentName+counter);



	while(toggler.length>0)
	{

		// Accordion anwenden
		new Accordion(toggler, content, {
			opacity: false,
			display: -1,
			alwaysHide: true,
			onComplete: function() {
				var element=$(this.elements[this.previous]);
				if(element && element.offsetHeight>0) element.setStyle('height', heightValue);
			},
			onActive: function(toggler, content) {
				toggler.addClass('open');
			},
			onBackground: function(toggler, content) {
				toggler.removeClass('open');
			}
		});

		// Selektoren für nächstes Level setzen
		counter++;


		toggler=$$(togglerName+counter);
		content=$$(contentName+counter);
	}
});

