// jQuery script configuration

$(function() {
	// init the png-fix script
	$( 'img[src$="png"]' ).pngfix();
	
	// prepare the HTML components if the DOM is loaded
	$( '.full, .description, .einzeln .abstract, #busfahrplan' ).hide();
	$( '.einzeln .full, .einzeln .description' ).show();
	//$( '.entry-main-right-col > .abstract' ).append( '<span title="weitere Informationen anzeigen">(mehr)</span>' );
	//$( '.entry-main-right-col > .full' ).append( '<p class="collapse"><span title="Informationen ausblenden">(weniger)</span></p>' );
	
	// show Busfahrplan on clicking the "Busfahrplan" link
	$( '.download-bus' ).toggle(
		function() {
			$( '#busfahrplan' ).slideDown('slow');
			$(this).text( "Busfahrplan ausblenden" );
		},
		function() {
			$( '#busfahrplan' ).slideUp('slow');
			$(this).text( "Busfahrplan anzeigen" );
		}
	);

	// show the full event infos in the right-content-col on clicking the "mehr" link
	$( '.abstract' ).click(function() {
		$(this).hide();
		$(this).next().slideDown('slow');
	});
	$( '.abstract span' ).click(function() {
		$(this).parent().hide();
		$(this).parent().next().slideDown('slow');
	});

	// hide the full event infos in the right-content-col on clicking the "weniger" link
	$( '.collapse span' ).click(function() {
		$(this).parents( '.full' ).slideUp('slow');
		$(this).parents( '.full' ).prev().show();
	});
	$( '.full' ).click(function() {
		$(this).slideUp('slow');
		$(this).prev().show();
	});

	// change text in the "Details" link in the left-content-col
	//$( '.detail-link span' ).text( "(Details einblenden)" );
	
	// init and use the toggle event for the "Details" link
	/*$( '.detail-link span' ).toggle(
		function() {
			$(this).text( "(Details ausblenden)" ).parents( '.infos' ).prev().slideDown( 'slow' );
		},
		function() {
			$(this).text( "(Details einblenden)" ).parents( '.infos' ).prev().slideUp( 'slow' );
		}
	);*/
	$( '.entry-main-left-col h6, .entry-main-left-col ul.details' ).toggle(
		function() {
			$(this).next('div.description').slideDown('slow');
		},
		function() {
			$(this).next('div.description').slideUp('slow');
		}
	);
	$( '.entry-main-left-col .description' ).click(function() {
		$(this).slideUp('slow');
	});
});
