$.fn.carouselTo = function(toPage){
			var top = $(this).offset().top-$(">a:nth-child("+toPage+")",$(this)).offset().top;
			$(this).animate({"top":top});
			return this;
		}
	
		$(function(){
			$('.slideshow').nivoSlider({
				controlNavThumbs:true,
				controlNavThumbsFromRel:true,
				pauseTime: 10000,
				directionNav:false,
				afterChange: function(){
					// Bilder in Graustufen wandeln, nur nicht IE, der hat filter
					if(!$.browser.msie){
						$(".nivo-controlNav img").each(function(){
							$(this).grayScale(!$(this).parent().hasClass("active"));
						});
					}
				},
				afterLoad: function(){
					// Bilder in Graustufen wandeln, nur nicht IE, der hat filter
					if(!$.browser.msie){
						var imgs = $(".nivo-controlNav img");
						imgs.each(function(){
							$(this).grayScale(!$(this).parent().hasClass("active"));
						});
					}
					var position = 1;
					var cnt = $(".nivo-controlNav a").length;
					if(cnt > 4) { // Nur wenn mehr Bilder sind als auf eine Seite passen
						$(".nivoSlider").after("<div class='prevNav'>&nbsp;</div><div class='nextNav'>&nbsp;</div>");
						$(".nivoSlider~.prevNav").click(function(){
							$(".nivo-controlNav").carouselTo(position>1?--position:1);
						});
						$(".nivoSlider~.nextNav").click(function(){
							$(".nivo-controlNav").carouselTo(position<cnt-3?++position:position);
						});
					}
				}
			});
			/* Im IE wird das ganze über filter:gray im CSS gelöst, deshalb braucht der das hier nicht */
			if(!$.browser.msie){
				$(".nivo-controlNav img").hover(function(){
				// Bei hover das Bild in Graustufen umwandlen (Caching dieser Logik erfolgt in .grayScale)
					$(this).grayScale(false);
				}, function(){
				// Bei mouseOut das Bild wieder zurücksetzen
					if(!$(this).parent().hasClass("active")){
						$(this).grayScale(true);
					}
				})
			}
			
			
					//$(".nivo-controlNav").carouselTo($(".nivo-controlNav .active").index()+1);
		});
