// Diverse Javascriptfunktionen mit jQuery umgesetzt 

$(document).ready(function() {

	// BackgroundImage resizer
	var theWindow        = $(window),
		$bg              = $("#backgroundImage"),
		aspectRatio      = $bg.width() / $bg.height();

	function resizeBg() {

			if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
				$bg
					.removeClass()
					.addClass('bgheight');
			} else {
				$bg
					.removeClass()
					.addClass('bgwidth');
			}

	}

	theWindow.resize(function() {
			resizeBg();
	}).trigger("resize");


	// Toggle Teaser home
	$('#toggleClose').click(function(event){
		$('#toggleClose').hide();
		$('#teaserNews').fadeOut(1400);
		$('#header').css("margin-bottom","0");

		$('#teaserHome').slideToggle(1800,function() {
			$('#content').addClass('paddingTopBottom');
			$.cookie("doNotShowTeaser", "yes", { expires: 0, path: '/', domain: 'bisenoire.ch'});
			$('#toggleOpen').fadeIn(400);
		});

	});

	$('#toggleOpen').click(function(event){
		$('#toggleOpen').hide();
		$('#teaserNews').fadeIn(1400);
		$('#teaserHome').slideToggle(1800,function() {

			$.cookie("doNotShowTeaser", null, { expires: 0, path: '/', domain: 'bisenoire.ch'});
			$('#toggleClose').fadeIn(400);
		});

	});

	// Toggle Teaser small
	$('#toggleClose').click(function(event){
		$('#toggleClose').hide();
		$('#header').css("margin-bottom","0");

		$('#teaser').slideToggle(1800,function() {
			$('#content').addClass('paddingTopBottom');
			$.cookie("doNotShowTeaser", "yes", { expires: 0, path: '/', domain: 'bisenoire.ch'});
			$('#toggleOpen').fadeIn(400);
		});

	});

	$('#toggleOpen').click(function(event){
		$('#toggleOpen').hide();
		$('#teaser').slideToggle(1800,function() {

			$.cookie("doNotShowTeaser", null, { expires: 0, path: '/', domain: 'bisenoire.ch'});
			$('#toggleClose').fadeIn(400);
		});

	});

	// Bump text in Box
	$('ul.navigationContainer li').mouseenter(function(event){
		var caption = $(this).children('div').children('.caption');
		$(caption).effect("bounce", { times:1, distance:5 }, 200);
	});
});



