jQuery(document).ready(function(){

	// Fontsize per cookie
	var fontsize = 0;
	var fontsizeStandard = 12;
	var COOKIE_NAME = 'fontsize';
	var COOKIE_OPTIONS = {path: '/', expires: 10};
	var getCookieValue = jQuery.cookie(COOKIE_NAME);
	if( !getCookieValue ){
		jQuery.cookie(COOKIE_NAME, fontsizeStandard, COOKIE_OPTIONS);
		jQuery('body').css('font-size',fontsizeStandard+'px');
	}else{
		jQuery('body').css('font-size',getCookieValue+'px');
	}

	// WAI
	jQuery('#fontsizeButton').click(function(){
		getCookieValue = parseInt( jQuery.cookie(COOKIE_NAME) );
		if( getCookieValue < 14 ){
			fontsize = getCookieValue + 1;
			jQuery.cookie(COOKIE_NAME, fontsize, COOKIE_OPTIONS);
			jQuery('body').css('font-size',fontsize+'px');
		}else{
			fontsize = 12;
			jQuery.cookie(COOKIE_NAME, fontsize, COOKIE_OPTIONS);
			jQuery('body').css('font-size',fontsize+'px');
		}
	});

	// Referenzen accordion
	var contentHeight = 0;
	jQuery(".accordion .head a").click(function() {
		// div for new loaded content
		var contentDiv = jQuery(this).parent().next('li');
		// close all div.content
		jQuery('.content').slideUp("fast");
		jQuery.get(jQuery(this).attr('href'), function(data){
			// get content from site
			var content = jQuery(data).find('#contentIn');
			if( content ){
				contentDiv.html(content);
			}else{
				contentDiv.html("Es sind kein Daten vorhanden!");
			}
			return false;
		});
		// open div for loaded content
		jQuery(this).ajaxComplete(function() {			
			jQuery(this).parent().next("li.content").slideDown('slow');
		});
		return false;
    });

	// Submenu Anim
	var start = 0;

	jQuery('.submenu_ul .submenu_li.menu a').hover( function(){
		if( start ){
			jQuery(this).css({ 'background-position': '0px bottom' });
			start = 0;
		}
		jQuery(this).animate({ 'background-position': '300px bottom' },400);
	},function(){
		jQuery(this).animate({ 'background-position': '600px bottom' },600);
		start = 1;
	});

	// Hmenu Anim
	jQuery('.hmenu_ul .hmenu_li.hmenu a')
	.css( {backgroundPosition: "0 0"} )
	.mouseover(function(){
		jQuery(this).stop().animate(
			{backgroundPosition:"(0 -138px)"},
			{duration:200})
		})
	.mouseout(function(){
		jQuery(this).stop().animate(
			{backgroundPosition:"(0 0)"},
			{duration:500})
		})

});
