	
	function grammlich(){
		
		// cont_wrap höhe: (footer nach unten)
		var newheight = $("#wrap").height()-110;
		if($("#cont_wrap").height()<newheight && newheight<$(window).height()) {
			//$("#cont_wrap").animate({height: newheight}, 2000, 'swing');
			$("#cont_wrap").css({height: newheight});
		}		
		
		/* Galerie: */
		if ($('.galeriebild').length > 0)
		{
			var imgCount = 0;
			var groupCount = 0;
			var curClassName = "group_0";
			$(".galeriebild").each(function(index) {
			   imgCount+= 1;
			   $(this).addClass(curClassName);
			   $("."+curClassName).equalizeCols();
			   if(imgCount==3)
			   {
				imgCount=0
				groupCount+= 1;
				curClassName = "group"+groupCount;
			   }
			});
		}
		
		//onTopLink: (fade in and out ;)
		var onTopLink = $("a[href=#wrap]");
		onTopLink.css("opacity", "0.001"); 
		$(window).scroll(function(){
		  var documentHeight = $(document).height(); 
		  var scrollPosition = $(window).height() + $(window).scrollTop(); 
		  if(documentHeight-100 > scrollPosition || $(window).scrollTop() == 0){
			onTopLink.stop().animate({opacity : 0.001}, 500); 
		  }
		  if(documentHeight == scrollPosition){ 
			onTopLink.stop().animate({opacity : 1}, 500); 
		  } 
		}); 
    onTopLink.click(function(){
       $('html, body').animate({scrollTop:0}, 'slow');
      return false;
    });
	}
	
	$(document).ready(function() {
		
		$.localScroll();
				
		//Hauptnavi Mouseover:
		$('#navi .nojs').removeClass("nojs");
		$('#navi li a').mouseover(function(){
			if($(this).parent().attr("class")!="active") {
				var newpos = $(this).css("background-position");
				newposArr = newpos.split(" ");
				newpos = newpos.replace(' '+newposArr[1], ' -90px');
				$(this).stop().animate(
					{backgroundPosition:"("+newpos+")"}, 
					{duration:400});
			}
		});
		$('#navi li a').mouseout(function(){
			if($(this).parent().attr("class")!="active") {
				var newpos = $(this).css("background-position");
				newposArr = newpos.split(" ");
				newpos = newpos.replace(' '+newposArr[1], ' 0px');
				$(this).stop().animate(
					{backgroundPosition:"("+newpos+")"}, 
					{duration:300})
			}
		});

		/* Fancy Holzkunde */
		if($("div.holzkundelist").length){
			$("div.holzkundelist a").fancybox({
				'autoScale'	: false,
				'type'		: 'iframe',
				'padding'	: 0,
				'width'		: 770,
				'height'	: 600,
				'showCloseButton' : true
			});
			
			$("dt a.standortLink").fancybox();
		}
		
		
		/* Fancy */
		if ($('.fancy').length > 0)
		{
			$(".fancy").fancybox();
		}
		
		/* Galerie: */
		if ($('.galeriebild').length > 0)
		{
			var imgCount = 0;
			var groupCount = 0;
			var curClassName = "group_0";
			$(".galeriebild").each(function(index) {
			   imgCount+= 1;
			   $(this).addClass(curClassName);
			   $("."+curClassName).equalizeCols();
			   if(imgCount==3)
			   {
				imgCount=0
				groupCount+= 1;
				curClassName = "group"+groupCount;
				$(this).addClass("last");
			   }
			});
			$(".galeriebild a").fancybox();
			
			$('.galeriebild').each(function(index) {
				$(this).hover(
				  function () {
					$(this).addClass('hover');
				  }, 
				  function () {
					$(this).removeClass('hover');
				  }
				);
			});
		}

		/* Suchfeld */
		$('#suchfeld input').click(function () {
			if($('#suchfeld input').val() == "Suche") $('#suchfeld input').val("");
		});
		$('#suchfeld input').focusout(function () {
			if($('#suchfeld input').val() == "") $('#suchfeld input').val('Suche');
		});
		
		/* Teaser: */
		if ($('.teaser').length > 0)
		{
			var teaserCount = 0;
			var groupCount = 0;
			var curClassName = "tgroup_0";
			$(".teaser").each(function(index) {
			   teaserCount+= 1;
			   $(this).addClass(curClassName);
			   $("."+curClassName).equalizeCols();
			   if(teaserCount%2==0)
			   {
				groupCount+= 1;
				curClassName = "tgroup"+groupCount;
				$(this).addClass("snd");
			   }
			});
		}
		
		/* Slider */
		if ($('#slider_wrap').length) {
      $('#slider_wrap div').nivoSlider({
        //effectToggle:'sliceDown', //overwrites effect! Specify sets like: 'sliceUp, sliceDown, sliceUpDown'
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:20,
        animSpeed:250,
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:false, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.7, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){} //Triggers after all slides have been shown
      });
      $('#slider_wrap div').data('nivo:vars').stop = true;
    }
  });
	
	window.onload = grammlich;

