
$(document).ready(function(){

	initLightbox();
	initAkkordeon();
	
});


function initLightbox(){
	$("a[rel='lightbox']").colorbox({
		current : "",
		previous : "",
		next : "",
		close : " ",
		rel : 'nofollow'
	});	
}


var currentAkkordeons = new Object();

function initAkkordeon(){
		$('.blockcontainer').each(function(idx,elem){
			currentAkkordeons[$(elem).attr('id')] = 0;
			
			$('> .akkordeonblock',$(elem)).each(function(idx2,elem2){
				$('> .akkordeonblock-titel',$(elem2)).click(function(e){
					if(idx2 != currentAkkordeons[$(elem).attr('id')]){
						// alten ausblenden
						$('> .akkordeonblock',$(elem)).each(function(idx3,elem3){
							if(idx3 == currentAkkordeons[$(elem).attr('id')]){
								$('> .akkordeonblock-content',$(elem3)).slideUp('fast');
								$('> .akkordeonblock-titel',$(elem3)).removeClass('active');
							}
						});
						// neuen einblenden
						$('> .akkordeonblock-titel',$(elem2)).addClass('active');
						$('> .akkordeonblock-content',$(elem2)).slideDown('fast',function(){
							currentAkkordeons[$(elem).attr('id')] = idx2;
						});
					}
				});
				// akkordeonblock-content
				if(idx2 != 0){
					$('.akkordeonblock-content',$(elem2)).hide();
				}else{
					$('.akkordeonblock-titel',$(elem2)).addClass('active');
				}
			});
		});
}


