/**
 * @author Mark Erhard
 */
$(document).ready(function(){

	var fontsize = 100;
	var lineheight = 141;
	var newlineheight = 0;
	
    blurClass = "full";
    $("#suchfeld").blur(function(){
		
        if (this.value === '') {
            $("#suchfeld").removeClass(blurClass);
        }
    });
    
    $("#suchfeld").focus(function(){
        $("#suchfeld").addClass(blurClass);
    });
	
	$("#contrast a").click(function(){
		$("#main").toggleClass("contrast");
		if ($("#main").hasClass("contrast")){
		fontsize = fontsize + 5	
		}
		else {
			fontsize = fontsize - 5
			
		}
	});
	

	
	$("#a_plus a").click(function(){
		if (fontsize < 170) {
			fontsize = fontsize + 5;
			newlineheight = lineheight * (fontsize / 100);
		}
		
		$(".text, .text h1, .text h2, .text h3").css("font-size", fontsize + "%");
		$(".text, .text h1, .text h2, .text h3").css("line-height", newlineheight + "%");
	});
	$("#a_minus a").click(function(){
		if (fontsize > 70) {
			fontsize = fontsize - 5;
			newlineheight = lineheight * (fontsize / 100);
		}
		$(".text, .text h1, .text h2, .text h3").css("font-size", fontsize + "%");
		$(".text, .text h1, .text h2, .text h3").css("line-height", newlineheight + "%");
	});
	
	/*Wenn Anzahl der Menüpunkte auf subpage zu groß wird */
	
	var menu1_len = $("#subpage_menu1 li.mentry").length;
	if (menu1_len > 10) {
		var newheight = (298 - menu1_len) / menu1_len;
		$("#subpage_menu1 li.mentry").css("height", newheight + "px");
		$("#subpage_menu1 li.mentry a").css("height", newheight + "px");
		$("#subpage_menu1 li.mentry a").css("font-size", "15.5px");
		$("#subpage_menu1 li.mentry a").css("line-height", newheight + "px");
	}
	
	
	
	/*Wenn Anzahl der SubMenüpunkte auf subpage < 4 wird */
	
	var submenu_len = $("#subpage_submenu .td").length;
	if (submenu_len < 4) {
		
		$("#subpage_submenu #submenu").addClass("short");
	}
	
		
	/* class="tobottom" auf Startseite nach unten verschieben */
	 $(".tobottom").remove().prependTo("#menu2")
	
	
	
});


                            (function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);


