(function($)
{
	$.fn.infodiv = function() 
	{
		if($('#infodiv').length == 0)
		{
			$('body').append('<div id="infodiv" />');
			$('#infodiv').html( '<div class="topleft"></div>'
							+ '<div class="topmiddle" style="background-color:#3399FF"></div>'
							+ '<div class="topright"></div>'
							+ '<div class="roundclear"></div>'
							+ '<div class="infocontent"><div id="infodivclose" title=""></div>'
							+ '<div id="infodivcontent">'
							+ '</div>'
							+ '</div>'
							+ '<div class="roundclear"></div>'
							+ '<div class="bottomleft"></div>'
							+ '<div class="bottommiddle" style="background-color:#3399FF"></div>'
							+ '<div class="bottomright"></div>'
							
							 );
			
			if($.browser.msie && $.browser.version < 7)
			{

				$('#infodiv').css('position', 'absolute')
				$(window).scroll(function() {
				    $('#infodiv').css('top', $(this).scrollTop()+20 + "px");
				});
			}
			
			$('#infodivclose').click(function() {
				$('#infodiv').fadeOut(500);
			});
			
			$(document).keypress(function(e)
			{
				if (e.keyCode == 27)
				{
					$('#infodiv').fadeOut(500);
				}
			});
		}
		
		var aktuellerText = "";
		
		return this.each(function() 
		{
			var infotext;
			if(this.title.charAt(0) == '#')
			{
				infotext = ($(this.title)).html();
			}
			else
			{
				infotext = this.title;	
			}
			
			this.title = "";
			//this.title = "";
			var eventHandler = ($(this).hasClass('infoclick')) ? "click" : "mouseover" ;

				this.title = "";
				$(this).bind(eventHandler,function() 
				{
					if(aktuellerText != infotext || (document.getElementById('infodiv').style.display == 'none'))
					{
						$('#infodiv').fadeOut(500);
						$("#infodiv").queue(function () 
						{
							$('#infodivcontent').html(infotext);
							$('#infodiv').fadeIn(500); // nur hier geändert
							$(this).dequeue();
						});
						//$('#infodiv').fadeIn(500); // nur hier geändert
					}
					aktuellerText = infotext;
				});

			
	    });
 	};
})(jQuery);

$(document).ready(function(){
	$('.infodiv').infodiv();
});
