// JavaScript Document
(function($){
	$.fn.sugerencias = function(opciones) {
		
		var
		  defecto = {
		  	background: '#369', /* #FC3 */
			color: '#FFF',      /* #003 */
			rounded: true
		  },
		  settings = $.extend({}, defecto, opciones);
		  
		  this.each(function() {
		  	var $this = $(this);
			var titulo = this.title;
			
			if($this.is('img') && $this.attr('title') != '') {
				this.title = '';
				$this.hover(function(e) {
					// ratón over
					$('<div id="sugerencias" />')
					  .appendTo('body')
					  .text(titulo)
					  .hide()
					  .css({
					  	backgroundColor: settings.background,
						color: settings.color,
						top: e.pageY + 10,
						left: e.pageX + 20
					  })
					  .fadeIn(350);
					  
				  if(settings.rounded) {
				  	$('#sugerencias').addClass('rounded');
				  }
				}, function() {
					// ratón out
					$('#sugerencias').remove();
				});	
			}
			
			$this.mousemove(function(e) {
				$('#sugerencias').css({
					top: e.pageY +  40,
					left: e.pageX + -20
			     });
			});
			
		  });
		  // devolvemos el objeto jQuery para permitir su uso en cadena.
		  return this;
	}
})(jQuery);
