$(function() {
	/* Function to switch Font Size of page*/
	$('#fontsize .increase, #fontsize .decrease').click(function() {
		var calc = $(this).attr('class');
		$('#main, #footer').css('font-size', function() { /* here you can specify which Elements should be included in font-switching !!! IMPORTANT: each element must have a font-size: ... attribute in css*/
			var size = $(this).css('font-size');
			size = parseInt(size.substr(0,size.length-2));
			if (calc === "decrease") {
				return size - 1;
			}
			else {
				return size + 1;
			}
		});
	});
	
	/* Functions for Image Switcher*/
	var i = 1;
	$('<div class="imageSwitcher"></div><div class="clearBoth"></div>').appendTo('.imageCollection');
	$('.imageCollection .images a').each(function() {
		$(this).addClass('image' + i);
		var active = '';
		if (i === 1) {
			active = ' active';
		}
		$('<span id="image' + i + '" class="imageSwitchButtons' + active + '">' + i + '</span>').appendTo('.imageSwitcher');
		i = i + 1;
	});
	$('.imageCollection .imageSwitchButtons').click(function() {
		$('.images a').hide();
		$('.imageCollection .imageSwitchButtons').removeClass('active');
		$(this).addClass('active');
		$('.' + $(this).attr('id')).show();
	});
	
	/* lightbox Einzelbild */
	$(function() {
		//$('a[@rel*=lightbox]').lightBox(); Select all links that contains lightbox in the attribute rel
		$('a.zoom').lightBox();
	});
	
	/* Functions for Download Archive*/
	$('.downloadArchiveTitle').click(function() {
		$(this).parent().toggleClass('open');
	});
	
	/* Functions for Swapcontent*/
	$('.swapContentTitle').click(function() {
		$(this).parent().toggleClass('open');
	});
	
	/* Functions for Swapcontent2*/
	$('.clickitem').click(function() {
		$(this).parent().toggleClass('open2');
	});
	
	/* Functions for Downloads - filter on load */
	if ($('#downloadNaviGroup a').length) {
		var elementToShow = $('#downloadNaviGroup a.active').attr('id');
		$('.downloadTable tbody tr').hide();
		
		//$('.downloadTable tbody tr.' + elementToShow).show();  //replaced by following if-block
		// show all table rows if default active selection on load is set to "all"
		// else show only those table rows according to default selection (element1, element2, element3)
		if (elementToShow == 'all')
			$('.downloadTable tbody tr').show();
		else
			$('.downloadTable tbody tr.' + elementToShow).show();
		
		
		
	}

	/* Function for Downloads - filter on click */
	$('#downloadNaviGroup a').click(function() {
		var elementToShow = $(this).attr('id');
		$('#downloadNaviGroup a').removeClass("active");
		$(this).addClass("active");
		$('.downloadTable tr').removeClass('last');
		$('.downloadTable tbody tr').hide();
		if (elementToShow != 'all') {
			elementToShow = 'tbody tr.' + elementToShow;
		}
		else {
			elementToShow = '.downloadTable tbody tr';
		}
		$(elementToShow + ':last').addClass('last');
		$(elementToShow).show();
		return false;
	});
	
	/* Functions for Home Main Navigation */
	$('#mainNavi li').mouseenter(function() {
		$(this).children('ul').addClass('open');
		//$(this).children('img').addClass('open');
	});
	$('#mainNavi li').mouseleave(function() {
		$(this).children('ul').removeClass('open');
		//$(this).children('img').removeClass('open');
	});
});

