$.fn.onebillboard = function() {

	var changetime = 7000;



	//erstelle Thumbbox
	var thumbbox = $(this).append("<div class='thumbbox'></div>");
	
	//erstelle data
	var data = [];


	var actual = 0;
	var animating = 0;

	var _this = this;




	var switchBillboard = function(i) {

		if (actual != i && animating == 0) {
			var images = $("img.bb",_this);

			var olde = $(images[actual]);
			var newe = $(images[i]);

			olde.css('z-index', 0);
			newe.css('z-index', 1);

			animating = 1;
			newe.fadeIn(500, function() { olde.hide(); animating = 0; });


			actual = i;
		}

	};

	var autoswitchBillboard = function() {

		var next = actual + 1;
		if (next >= $("img.bb",_this).length) {
			next = 0;
		}
		switchBillboard(next);

	};

	var daInterval = setInterval( function() { autoswitchBillboard() }, changetime );

	$("img",this).each(function(i) {

		$(this).addClass("bb"); //klasse für bbs

		//thumb laden und einfügen
		var img = new Image();
		img.src = $(this).attr("data-thumb");

		$(img).addClass("bt");
		$(".thumbbox", _this).append(img);

		// Click-Event
		img.onclick = function() {
			switchBillboard(i);
		};

		// Enter-Event
		$(this).bind("mouseenter", function() {
			clearInterval(daInterval);
			daInterval = null;
		});

		// Leave-Event
		$(this).bind("mouseleave", function() {
			daInterval = setInterval( function() { autoswitchBillboard() }, changetime );
		});

		var _this = this;
		$(this).bind("click", function() {
			document.location.href = $(_this).attr("data-link");
		});


	});
	

    return this;
};

