$(function() {
	
	/* Leeren die Auswahl der Drop-Down-Boxen, falls refreshed */
	
	$('.auswahlbox').val('');
	
	/* Dropmenü - Funktionalität */
	
	$('#dropmenue').hover(
		
		function() {
			$('#dropsubmenue').fadeIn();
			$('#dropmenue_title').addClass('hovered_drop');
		},
		function() {
			$('#dropsubmenue').fadeOut();
			$('#dropmenue_title').removeClass('hovered_drop');
		}
		
	);
	
	/* Close Window Link - Funktionalität */
	
	$('#closewindow').click(function() {
		window.close();
		return false;
	});
	
	/* Drop-Down Boxes - Funktionalität */
	
	$('.auswahlbox').change(function() {
		
		// bei leeren options oder monaten keine Reaktion
		if ($(this).val() == 0 || $(this).val() == '-1') {
			return 0;
		};
		
		// activestrips entfernen, falls nachträgliche auswahl
		$('.activestrip_on').removeClass('activestrip_on');
		
		// activestrip setzen
		var tdparent = $(this).parents('td:first');
		var i = $('#dropdowns td').index(tdparent);
		$('#activestrip td').eq(i).addClass('activestrip_on');

		var me = $(this);
		
		$('#loadingAnimation').show();
		
		$.get('ansicht.php', $(this).parent('form').serialize(), function(data) {
			
			$('.auswahlbox').not(me).val('-1');
			$('#content').html(data);
			
			// activating information switch behaviour
			$('.information_switch').toggle(function() {

				$(this).next('.detailed_information').slideDown();
				$(this).html('Weniger Informationen').addClass('rosa');

			}, function() {
				
				$(this).next('.detailed_information').slideUp();
				$(this).html('Mehr Informationen').removeClass('rosa');

			});
			
		});
		
	});	
	
		
});

