/*
 * Copyright (c) 2006 Sam Collett (http://www.texotela.co.uk)
*/

$.fn.ToolTipDemo = function(szerokosc)
{
	this.mouseover(
		function(e)
		{
			if((!this.title && !this.alt) && !this.tooltipset) return;
			// get mouse coordinates
			var mouseX = e.pageX || (e.clientX ? e.clientX + document.body.scrollLeft : 0);
			var mouseY = e.pageY || (e.clientY ? e.clientY + document.body.scrollTop : 0);
			mouseX += 10;
			mouseY += 10;
			szerokosc = szerokosc || "auto";
			// if there is no div containing the tooltip
			if(!this.tooltipdiv)
			{
				// create a div and style it
				var div = document.createElement("div");
				this.tooltipdiv = div;
				$(div).css(
				{
					fontSize: "10px",
					fontFamily: "Verdana",
					border: "1px solid #000000",
					padding: "4px",
					backgroundColor: "#DDDDDD",
					color: "#000000",
					width: szerokosc,
					position: "absolute"
				})
				// add the title/alt attribute to it
				.html((this.title || this.alt));
				this.title = "";
				this.alt = "";
				$("body").append(div);
				this.tooltipset = true;
			}
			$(this.tooltipdiv).show().css({left: mouseX + 1 + "px", top: mouseY + 2 + "px"});
		}
	).mouseout(
		function()
		{
			if(this.tooltipdiv)
			{
				$(this.tooltipdiv).hide();
			}
		}
	);
	return this;
}

$(document).ready(
	function()
	{
		$("#pogoda").ToolTipDemo();
		$("#info_abs,#info_asr,#info_eds,#info_esp,abs,#info_immobiliser,#info_tempomat").ToolTipDemo('250');
	}
	
);