	$.fn.photoSlider = function(opts){
		var options = {
			"delay": 5000,
			"duration": 2000
		};
		options = $.extend(options, opts);

		return this.each(function(){
			var navigation = $("#foto_teaser_nav", this);
			var playPause = $("#foto_teaser_play_pause", this);
			var content = $("#foto_teaser_content", this);
			var special = $(".container_special", content);

			// position special and add animation
			$("li", content).each(function(){
				$(this).show();

				var height = $(".container_special", this).innerHeight();
				$(".container_special", this).css("top", (-(height))+25 );
				$(".container_special", this).data("topOffset", (-(height))+25);

				if(!$(this).hasClass("active")){
					$(this).hide();
				};

			});

			$(special).each(function(){

				$(this).hoverIntent(
						function(){
							$(this).stop(true, false).animate({
								"top": 0
							});
						},
						function(){
							$(this).stop(true, false).animate({
								"top": $(this).data("topOffset")
							});
						}
				);

			});


			var pause = false;

			var onClick = function(target){
				// return if active link was clicked
				if (!$(target).hasClass("active")) { 
				
					// change active state of the buttons
					$("a", navigation).removeClass("active");
					$(target).addClass("active");
	
					// animate content for the clicked link
					var indexOfButton = $("a", navigation).index(target);
	
					// stop running animations
					$("li", content).stop(true, true);
	
					// animate
					$(".active", content).fadeOut(
							(options.duration),
							function(){
								$(this).removeClass("active");
							}
					);
					$("li", content).eq(indexOfButton).fadeIn(
							(options.duration),
							function(){
								$(this).addClass("active");
							}
					);
				}
				return false;
			};


			// navigation click event
			$("a", navigation).hoverIntent(function(){
				$("ul", playPause).removeClass("playing").addClass("paused");
				pause = true;
				window.clearTimeout(timeout);
				onClick($(this));
				return false;
			} , function() {} );


			// play / pause click
			$("a", playPause).click(function(e){
				if($("ul", playPause).hasClass("playing")){
					$("ul", playPause).removeClass("playing").addClass("paused");
					pause = true;
					window.clearTimeout(timeout);
				}
				else {
					$("ul", playPause).removeClass("paused").addClass("playing");
					pause = false;
					timeout = window.setTimeout(animate, options.delay);
				}

				return false;
			});




			// trigger click-event on navigation if animation is set
			var timeout = null;
			var animate = function(){
				var tabIndex = $("a", navigation).index($("a.active", navigation));
				if(tabIndex === $("a", navigation).size() - 1) {
					tabIndex = -1;
				}
				onClick($("a", navigation).eq(tabIndex + 1));

				if(!pause){
					timeout = window.setTimeout(animate, options.delay);
				}
			};

			// check if animation is wanted
			if(options.delay !== null) {
				timeout = window.setTimeout(animate, options.delay);
			}
			else {
				$(playPause).hide();
			}
		});
	}; 
