// (c) 2009 - 2010 Mickael Riga - See MIT_LICENSE file for details
// Speechify.js version 2

;(function($) {
	$.fn.speechify = function(options) {
		
		// Settings
		var defaults = {
			color: 'white', backgroundColor: 'black', padding: '5px', fontFamily: 'sans-serif', fontSize: '11px', fontWeight: 'normal',
			'border-radius': '5px', '-moz-border-radius': '5px', '-webkit-border-radius': '5px',
		};
		var settings = $.extend({}, defaults, options);
		
		return this.each(function() {
			var $$ = $(this);
			if ($$.attr('title')!='') {
				$$.data('speech', this.title);
				this.title = ''; // Empty the title to disable the default tooltip
				$$.hover(function(e){ // Rollover
						$("body").append("<div id='speechify_wrapper'><div id='speechify'>" + $$.data('speech') + "</div><div id='speechify_spike'></div></div>"); // Add tooltip and spike to page
						$('#speechify_wrapper').css('position', 'absolute');
						var $speechify = $('#speechify').css(settings).css('border', '0px');
						$('#speechify_spike').css({
							position: 'relative', width: '0px', height: '0px', left: $speechify.css('padding-left'),
							borderStyle: 'solid', borderWidth: $speechify.css('padding-left'), borderColor: $speechify.css('background-color')+' transparent transparent transparent'
						});				  							  	
			    },
					function(){		
						$("#speechify_wrapper").remove();
			  });
				$$.mousemove(function(e){ // Position
					var $speechify = $('#speechify');
					$("#speechify_wrapper")
						.css("bottom",($(window).height() - ($$.offset().top)) + "px")
						.css("left",(e.pageX - parseInt($speechify.css('padding-left'))*2) + "px");
				});
				$$.click(function(e){ // Make it disapear on click to avoid it to stay on some Ajax tricks
					$$.mouseout();
				});
			}
		});
	}	
	$.speechify = function(options) {
		// Assign elements with a non-blank title field
		$(function() {
			if ($.fn.livequery) {
				$('*[title]').livequery(function() {
					$(this).speechify(options);
				});
			} else {
				$('*[title]').each(function() {
					$(this).speechify(options);
				});
			}
		});			
	}	
})(jQuery);
@@ -456,25 +456,26 @@
 %09%0A%09%09
-return this.each(
+var give_speech = 
 func
@@ -1790,317 +1790,267 @@
 %0A%09%09%7D
-);%0A%09%7D%09%0A%09$.speechify = function(options) %7B%0A%09%09// Assign elements with a non-blank title field%0A%09%09$(function() %7B%0A%09%09%09if ($.fn.livequery) %7B%0A%09%09%09%09$('*%5Btitle%5D').livequery(function() %7B%0A%09%09%09%09%09$(this).speechify(options);%0A%09%09%09%09%7D);%0A%09%09%09%7D else %7B%0A%09%09%09%09$('*%5Btitle%5D').each(function() %7B%0A%09%09%09%09%09$(this).speechify(options);%0A%09%09%09%09%7D);%0A%09%09%09%7D
+%0A%09%0A%09%09if ($.fn.livequery) %7B%0A%09%09%09return this.livequery(give_speech);%0A%09%09%7D%09else %7B%0A%09%09%09return this.each(give_speech);%0A%09%09%7D%0A%09%0A%09%7D%09%0A%09$.speechify = function(options) %7B%0A%09%09// Assign elements with a non-blank title field%0A%09%09$(function() %7B%0A%09%09%09$('*%5Btitle%5D').speechify(options);
 %0A%09%09%7D

Move livequery handler in the main function and do not re-create the tooltip for each entry