jQuery(document).ready(function($) {
	
	
	// Grüne Ränder
	$('#wrap').append('<div id="green_border_top_left">&nbsp;</div><div id="green_border_bottom">&nbsp;</div>');
	
	
	
	// Fancyzoom für Slides und .zoom
	$('#slides a, a.zoom').fancyZoom({scaleImg: false, closeOnClick: true, directory: '/img/fancyzoom'});
	
	
	
	// Hauptnavigation
	$('#nav_main > ul > li').hover(function() {
		$(this).addClass('hover');
		$(this).siblings('.webgen-menu-submenu-inhierarchy').find('ul').hide();
	}, function() {
		$(this).removeClass('hover');
		var $ul_to_show = $(this).siblings('.webgen-menu-submenu-inhierarchy').find('ul');
		if ($ul_to_show.children().length > 1) {
			$ul_to_show.show();
		};
	});
	$('#nav_main > ul > li > ul').each(function(index) {
		var number_of_children = $(this).children().length;
		if (number_of_children < 2) {
			$(this).hide();
		};
	});
	
	
	
	// pseudo-Klassen in richtige Klassen  für alte Browser
	$('#nav_main li:last-child').addClass('last-child');
	$('#nav_sec li:last-child').addClass('last-child');
	$('#nav_meta li:last-child').addClass('last-child');
	
	
	
	// TextZoom
	$('#wrap').append('<div id="text_zoom"><a href="#" id="zoom_in">A+</a> <a href="#" id="zoom_out">A-</a></div>');
	var $cookie_name = "novavita-FontSize";
	var originalFontSize = $('html').css('font-size');
	// $('#zoom_in, #zoom_out').corners('10px');
	// if exists load saved value, otherwise store it
	if($.cookie($cookie_name)) {
		var $getSize = $.cookie($cookie_name);
		$('html').css({fontSize : $getSize + ($getSize.indexOf('px')!=-1 ? '' : 'px')}); // IE fix for double "pxpx" error
		Cufon.replace('h1');
		Cufon.replace('h2');
	} else {
		$.cookie($cookie_name, originalFontSize);
	};
	// Increase Font Size
	$('#zoom_in').click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum+2;
		$('html').css('font-size', newFontSize);
		$.cookie($cookie_name, newFontSize);
		// $('#zoom_in, #zoom_out').corners(newFontSize+'px');
		Cufon.replace('h1');
		Cufon.replace('h2');
		return false;
	});
	// Decrease Font Size
	$('#zoom_out').click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum-2;
		$('html').css('font-size', newFontSize);
		$.cookie($cookie_name, newFontSize);
		// $('#zoom_in, #zoom_out').corners(newFontSize+'px');
		Cufon.replace('h2');
		Cufon.replace('h1');
		return false;
	});
});

