//JQuery Quick Tip
//Author: Owain Lewis
//Author URL: www.Owainlewis.com

jQuery.fn.quicktip = function(options){

	var defaults = {
		speed: 500,
		xOffset: 10,
		yOffset: 10
	};

	var options = $.extend(defaults, options);
	
	return this.each(function(){

		var $this = jQuery(this)

		//Pass the title to a variable and then remove it from DOM
		if ($this.attr('title') != ''){
			var tipTitle = ($this.attr('title'));
		}else{
			//var tipTitle = 'Quick tip';
			var tipTitle = '';
		}

      // soh vai exibir o tooltip se o atributo title nao estiver vazio - Jorge Rodrigues - marco/2011
      if( tipTitle!='' ) {

      		//Remove title attribute - Jorge Rodrigues - fevereiro/2011
      		$this.removeAttr('title');

      		$(this).hover(function(e){
      			//$(this).css('cursor', 'pointer')
      			$(this).css('cursor', 'default')
                  $("body").append("<div id='tooltip'>" + tipTitle + "</div>");

                  $("#tooltip")

      				.css("top", (e.pageY + defaults.xOffset) + "px")
      	            .css("left", (e.pageX + defaults.yOffset) + "px")
      	            .fadeIn(options.speed);

      			}, function() {
      				//Remove the tooltip from the DOM
      				$("#tooltip").remove();
      			}
            );

      		$(this).mousemove(function(e) {
      			$("#tooltip")
      			.css("top", (e.pageY + defaults.xOffset) + "px")
      			.css("left", (e.pageX + defaults.yOffset) + "px");
      		});
      }

	});

};



