(function($){
	$.fn.tooltip = function(config){
		config = jQuery.extend({							   
			opacidade: 1,
			efeito: "slow",
			cursor: '',
			borda: '1px solid #000000',
			fundo: '#FFFFE1',
			cor: '#333333',
			tamanho: '11px',
			letra: 'Arial',
			espacamento: '2px 5px',
			quebralinha: '|',
			cima: 0,
			esquerda: 15
		   }, config);

		$(this).mouseover(function(e){
								   
			this.t = $(this).attr("title");
			this.tv = this.t;
			
			if(config.quebralinha!=""){
				this.tv = this.tv.replace(config.quebralinha,"<br />");
				this.tv = this.tv.replace(config.quebralinha,"<br />");
				this.tv = this.tv.replace(config.quebralinha,"<br />");
				this.tv = this.tv.replace(config.quebralinha,"<br />");
				this.tv = this.tv.replace(config.quebralinha,"<br />");
				this.tv = this.tv.replace(config.quebralinha,"<br />");
			}
			
			this.tv = this.tv.replace(RegExp("{","g"),"<b>");
			this.tv = this.tv.replace(RegExp("}","g"),"</b>");		
			
			if(this.t!=""){
				
				if(config.cursor!=""){
					$(this).css("cursor", config.cursor);
				}

				$(this).attr({"title": "", "alt": ""});
				
				$(this).find("*").each(function(){
					this.title	='';
					this.alt	='';
				});
				
				$("body").append("<div id='tooltip'>"+ this.tv + "</div>");				
				
				$("#tooltip").css({
					opacity: config.opacidade,
					position: 'absolute',
					display: 'none',
					backgroundColor: config.fundo,
					border: config.borda,
					padding: config.espacamento,
					color: config.cor,
					fontSize: config.tamanho,
					fontFamily: config.letra,
					zIndex: 2
				}).fadeIn(config.efeito);
				
			}
		});

		$(this).mouseout(function(){
			$(this).attr("title", this.t);
			$("#tooltip").remove();
			
		});

		$(this).mousemove(function(e){
			$("#tooltip").css({
				top: (e.pageY + config.cima) + "px",
				left: (e.pageX + config.esquerda) + "px"
			});
		});
		
	};
	
})(jQuery);
